1e2a1072f9bf224b44d86bd8cf8b0ef8145ff0da
[osm/RO.git] / osm_ro / wim / schemas.py
1 # -*- 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
35 from ..openmano_schemas import (
36 description_schema,
37 name_schema,
38 nameshort_schema
39 )
40
41 # WIM -------------------------------------------------------------------------
42 wim_types = ["ietftapi", "onos", "odl", "dynpac", "fake"]
43
44 dpid_type = {
45 "type": "string",
46 "pattern":
47 "^[0-9a-zA-Z]+(:[0-9a-zA-Z]+)*$"
48 }
49
50 port_type = {
51 "oneOf": [
52 {"type": "string",
53 "minLength": 1,
54 "maxLength": 5},
55 {"type": "integer",
56 "minimum": 1,
57 "maximum": 65534}
58 ]
59 }
60
61 wim_port_mapping_desc = {
62 "type": "array",
63 "items": {
64 "type": "object",
65 "properties": {
66 "datacenter_name": nameshort_schema,
67 "pop_wan_mappings": {
68 "type": "array",
69 "items": {
70 "type": "object",
71 "properties": {
72 "pop_switch_dpid": dpid_type,
73 "pop_switch_port": port_type,
74 "wan_service_endpoint_id": name_schema,
75 "wan_service_mapping_info": {
76 "type": "object",
77 "properties": {
78 "mapping_type": name_schema,
79 "wan_switch_dpid": dpid_type,
80 "wan_switch_port": port_type
81 },
82 "additionalProperties": True,
83 "required": ["mapping_type"]
84 }
85 },
86 "anyOf": [
87 {
88 "required": [
89 "pop_switch_dpid",
90 "pop_switch_port",
91 "wan_service_endpoint_id"
92 ]
93 },
94 {
95 "required": [
96 "pop_switch_dpid",
97 "pop_switch_port",
98 "wan_service_mapping_info"
99 ]
100 }
101 ]
102 }
103 }
104 },
105 "required": ["datacenter_name", "pop_wan_mappings"]
106 }
107 }
108
109 wim_schema_properties = {
110 "name": name_schema,
111 "description": description_schema,
112 "type": {
113 "type": "string",
114 "enum": ["tapi", "onos", "odl", "dynpac"]
115 },
116 "wim_url": description_schema,
117 "config": {
118 "type": "object",
119 "properties": {
120 "wim_port_mapping": wim_port_mapping_desc
121 }
122 }
123 }
124
125 wim_schema = {
126 "title": "wim information schema",
127 "$schema": "http://json-schema.org/draft-04/schema#",
128 "type": "object",
129 "properties": {
130 "wim": {
131 "type": "object",
132 "properties": wim_schema_properties,
133 "required": ["name", "type", "wim_url"],
134 "additionalProperties": True
135 }
136 },
137 "required": ["wim"],
138 "additionalProperties": False
139 }
140
141 wim_edit_schema = {
142 "title": "wim edit information schema",
143 "$schema": "http://json-schema.org/draft-04/schema#",
144 "type": "object",
145 "properties": {
146 "wim": {
147 "type": "object",
148 "properties": wim_schema_properties,
149 "additionalProperties": False
150 }
151 },
152 "required": ["wim"],
153 "additionalProperties": False
154 }
155
156 wim_account_schema = {
157 "title": "wim account information schema",
158 "$schema": "http://json-schema.org/draft-04/schema#",
159 "type": "object",
160 "properties": {
161 "wim_account": {
162 "type": "object",
163 "properties": {
164 "name": name_schema,
165 "user": nameshort_schema,
166 "password": nameshort_schema,
167 "config": {"type": "object"}
168 },
169 "additionalProperties": True
170 }
171 },
172 "required": ["wim_account"],
173 "additionalProperties": False
174 }
175
176 wim_port_mapping_schema = {
177 "$schema": "http://json-schema.org/draft-04/schema#",
178 "title": "wim mapping information schema",
179 "type": "object",
180 "properties": {
181 "wim_port_mapping": wim_port_mapping_desc
182 },
183 "required": ["wim_port_mapping"]
184 }