blob: a040405b574a960cabd8ef78ff0e3a10d3dd6bda [file] [log] [blame]
Anderson Bravalheri0446cd52018-08-17 15:26:19 +01001# -*- coding: utf-8 -*-
2##
3# Copyright 2018 University of Bristol - High Performance Networks Research
4# Group
5# All Rights Reserved.
6#
7# Contributors: Anderson Bravalheri, Dimitrios Gkounis, Abubakar Siddique
8# Muqaddas, Navdeep Uniyal, Reza Nejabati and Dimitra Simeonidou
9#
10# Licensed under the Apache License, Version 2.0 (the "License"); you may
11# not use this file except in compliance with the License. You may obtain
12# a copy of the License at
13#
14# http://www.apache.org/licenses/LICENSE-2.0
15#
16# Unless required by applicable law or agreed to in writing, software
17# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19# License for the specific language governing permissions and limitations
20# under the License.
21#
22# For those usages not covered by the Apache License, Version 2.0 please
23# contact with: <highperformance-networks@bristol.ac.uk>
24#
25# Neither the name of the University of Bristol nor the names of its
26# contributors may be used to endorse or promote products derived from
27# this software without specific prior written permission.
28#
29# This work has been performed in the context of DCMS UK 5G Testbeds
30# & Trials Programme and in the framework of the Metro-Haul project -
31# funded by the European Commission under Grant number 761727 through the
32# Horizon 2020 and 5G-PPP programmes.
33##
34
35from ..openmano_schemas import (
36 description_schema,
37 name_schema,
38 nameshort_schema
39)
40
41# WIM -------------------------------------------------------------------------
42wim_types = ["tapi", "onos", "odl"]
43
44wim_schema_properties = {
45 "name": name_schema,
46 "description": description_schema,
47 "type": {
48 "type": "string",
49 "enum": ["tapi", "onos", "odl"]
50 },
51 "wim_url": description_schema,
52 "config": {"type": "object"}
53}
54
55wim_schema = {
56 "title": "wim information schema",
57 "$schema": "http://json-schema.org/draft-04/schema#",
58 "type": "object",
59 "properties": {
60 "wim": {
61 "type": "object",
62 "properties": wim_schema_properties,
63 "required": ["name", "type", "wim_url"],
64 "additionalProperties": True
65 }
66 },
67 "required": ["wim"],
68 "additionalProperties": False
69}
70
71wim_edit_schema = {
72 "title": "wim edit information schema",
73 "$schema": "http://json-schema.org/draft-04/schema#",
74 "type": "object",
75 "properties": {
76 "wim": {
77 "type": "object",
78 "properties": wim_schema_properties,
79 "additionalProperties": False
80 }
81 },
82 "required": ["wim"],
83 "additionalProperties": False
84}
85
86wim_account_schema = {
87 "title": "wim account information schema",
88 "$schema": "http://json-schema.org/draft-04/schema#",
89 "type": "object",
90 "properties": {
91 "wim_account": {
92 "type": "object",
93 "properties": {
94 "name": name_schema,
95 "user": nameshort_schema,
96 "password": nameshort_schema,
97 "config": {"type": "object"}
98 },
99 "additionalProperties": True
100 }
101 },
102 "required": ["wim_account"],
103 "additionalProperties": False
104}
105
106dpid_type = {
107 "type": "string",
108 "pattern":
109 "^[0-9a-zA-Z]+(:[0-9a-zA-Z]+)*$"
110}
111
112port_type = {
113 "oneOf": [
114 {"type": "string",
115 "minLength": 1,
116 "maxLength": 5},
117 {"type": "integer",
118 "minimum": 1,
119 "maximum": 65534}
120 ]
121}
122
123wim_port_mapping_schema = {
124 "$schema": "http://json-schema.org/draft-04/schema#",
125 "title": "wim mapping information schema",
126 "type": "object",
127 "properties": {
128 "wim_port_mapping": {
129 "type": "array",
130 "items": {
131 "type": "object",
132 "properties": {
133 "datacenter_name": nameshort_schema,
134 "pop_wan_mappings": {
135 "type": "array",
136 "items": {
137 "type": "object",
138 "properties": {
139 "pop_switch_dpid": dpid_type,
140 "pop_switch_port": port_type,
141 "wan_service_endpoint_id": name_schema,
142 "wan_service_mapping_info": {
143 "type": "object",
144 "properties": {
145 "mapping_type": name_schema,
146 "wan_switch_dpid": dpid_type,
147 "wan_switch_port": port_type
148 },
149 "additionalProperties": True,
150 "required": ["mapping_type"]
151 }
152 },
153 "oneOf": [
154 {
155 "required": [
156 "pop_switch_dpid",
157 "pop_switch_port",
158 "wan_service_endpoint_id"
159 ]
160 },
161 {
162 "required": [
163 "pop_switch_dpid",
164 "pop_switch_port",
165 "wan_service_mapping_info"
166 ]
167 }
168 ]
169 }
170 }
171 },
172 "required": ["datacenter_name", "pop_wan_mappings"]
173 }
174 }
175 },
176 "required": ["wim_port_mapping"]
177}