Adds initial implementation of ONOS VPLS SDN plugin
[osm/RO.git] / RO / 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 = ["tapi", "onos", "onos_vpls", "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 "device_id": nameshort_schema,
73 "device_interface_id": nameshort_schema,
74 "service_endpoint_id": name_schema,
75 "switch_dpid": dpid_type,
76 "switch_port": port_type,
77 "service_mapping_info": {
78 "type": "object",
79 "properties": {
80 "mapping_type": name_schema,
81 },
82 "additionalProperties": True,
83 "required": ["mapping_type"]
84 }
85 },
86 "required": ["service_endpoint_id"]
87 }
88 }
89 },
90 "required": ["datacenter_name", "pop_wan_mappings"]
91 }
92 }
93
94 wim_schema_properties = {
95 "name": name_schema,
96 "description": description_schema,
97 "type": {
98 "type": "string",
99 # "enum": ["tapi", "onos", "odl", "dynpac", "fake"]
100 },
101 "wim_url": description_schema,
102 "config": {
103 "type": "object",
104 "properties": {
105 "wim_port_mapping": wim_port_mapping_desc
106 }
107 }
108 }
109
110 wim_schema = {
111 "title": "wim information schema",
112 "$schema": "http://json-schema.org/draft-04/schema#",
113 "type": "object",
114 "properties": {
115 "wim": {
116 "type": "object",
117 "properties": wim_schema_properties,
118 "required": ["name", "type", "wim_url"],
119 }
120 },
121 "required": ["wim"],
122 }
123
124 wim_edit_schema = {
125 "title": "wim edit information schema",
126 "$schema": "http://json-schema.org/draft-04/schema#",
127 "type": "object",
128 "properties": {
129 "wim": {
130 "type": "object",
131 "properties": wim_schema_properties,
132 }
133 },
134 "required": ["wim"],
135 }
136
137 wim_account_schema = {
138 "title": "wim account information schema",
139 "$schema": "http://json-schema.org/draft-04/schema#",
140 "type": "object",
141 "properties": {
142 "wim_account": {
143 "type": "object",
144 "properties": {
145 "name": name_schema,
146 "user": nameshort_schema,
147 "password": nameshort_schema,
148 "config": {"type": "object"}
149 },
150 }
151 },
152 "required": ["wim_account"],
153 }
154
155 wim_port_mapping_schema = {
156 "$schema": "http://json-schema.org/draft-04/schema#",
157 "title": "wim mapping information schema",
158 "type": "object",
159 "properties": {
160 "wim_port_mapping": wim_port_mapping_desc
161 },
162 "required": ["wim_port_mapping"]
163 }