blob: 1e739559f6ac077b65d91f01a3e612d66041ca65 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
Zack Williams9a42f872019-02-15 17:56:04 -070016from __future__ import absolute_import
Matteo Scandolo67654fa2017-06-09 09:33:17 -070017import unittest
Scott Baker1f7791d2018-10-04 13:21:20 -070018from xosgenx.generator import XOSProcessor, XOSProcessorArgs
19from helpers import XProtoTestHelpers
Sapan Bhatia943dad52017-05-19 18:41:01 +020020
Zack Williams045b63d2019-01-22 16:30:57 -070021
Matteo Scandolo67654fa2017-06-09 09:33:17 -070022class XProtoGraphTests(unittest.TestCase):
Sapan Bhatia943dad52017-05-19 18:41:01 +020023 def test_cross_model(self):
Matteo Scandolo67654fa2017-06-09 09:33:17 -070024 target = XProtoTestHelpers.write_tmp_target(
Zack Williams045b63d2019-01-22 16:30:57 -070025 """
Sapan Bhatia943dad52017-05-19 18:41:01 +020026 {% for m in proto.messages %}
27 {{ m.name }} {
28 {%- for l in m.links %}
Sapan Bhatia3cfdf632017-06-08 05:14:03 +020029 {%- if proto.message_table[l.peer.fqn] -%}
30 {%- set model = proto.message_table[l.peer.fqn] %}
Sapan Bhatia943dad52017-05-19 18:41:01 +020031 {% for f in model.fields %}
32 {{ f.type }} {{ f.name }};
33 {% endfor %}
34 {%- endif -%}
35 {% endfor %}
36 }
37 {% endfor %}
Sapan Bhatia943dad52017-05-19 18:41:01 +020038"""
Zack Williams045b63d2019-01-22 16:30:57 -070039 )
40
41 proto = """
Sapan Bhatia943dad52017-05-19 18:41:01 +020042message Port (PlCoreBase,ParameterMixin){
43 required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False];
44 optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True];
45 optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
46 optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True];
47 optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True];
48 required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True];
49}
50
51message Instance (PlCoreBase){
52 optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False];
53 optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False];
54 required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False];
55 optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False];
56 optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
57 required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False];
58 optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True];
59 required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False];
60 required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False];
61 required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False];
62 required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False];
63 required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False];
64 optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True];
65 required string isolation = 14 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
66 optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True];
67 optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True];
68 required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True];
69}
70
71message Network (PlCoreBase,ParameterMixin) {
72 required string name = 1 [db_index = False, max_length = 32, null = False, blank = False];
73 required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False];
74 required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True];
75 required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True];
76 required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True];
77 optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True];
78 optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True];
79 required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False];
80 required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False];
81 required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True];
82 optional string topology_parameters = 11 [db_index = False, null = True, blank = True];
83 optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True];
84 optional string controller_parameters = 13 [db_index = False, null = True, blank = True];
85 optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True];
86 optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True];
87 optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True];
88 required bool autoconnect = 17 [help_text = "This network can be autoconnected to the slice that owns it", default = True, null = False, db_index = False, blank = True];
89 required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True];
90 required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True];
91 required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True];
92}
93
94message Slice (PlCoreBase){
95 required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False];
96 required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True];
97 required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True];
98 required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True];
99 required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True];
100 required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
101 required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False];
102 optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True];
103 optional string network = 9 [blank = True, max_length = 256, null = True, db_index = False, choices = "((None, 'Default'), ('host', 'Host'), ('bridged', 'Bridged'), ('noauto', 'No Automatic Networks'))"];
104 optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True];
105 optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True];
106 optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True];
107 optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True];
108 optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True];
109 optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True];
110 optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False];
111 required string default_isolation = 17 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
112 required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True];
113}
114"""
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700115
Scott Baker1f7791d2018-10-04 13:21:20 -0700116 args = XOSProcessorArgs()
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700117 args.inputs = proto
118 args.target = target
Sapan Bhatiabfb233a2018-02-09 14:53:09 -0800119 output = XOSProcessor.process(args)
Zack Williams045b63d2019-01-22 16:30:57 -0700120 num_semis = output.count(";")
121 self.assertGreater(
122 num_semis, 3
123 ) # 3 is the number of links, each of which contains at least one field
Sapan Bhatia943dad52017-05-19 18:41:01 +0200124
125 def test_base_class_fields(self):
Zack Williams045b63d2019-01-22 16:30:57 -0700126 target = """
Sapan Bhatia943dad52017-05-19 18:41:01 +0200127 {% for m in proto.messages %}
128 {{ m.name }} {
129 {%- for l in m.links %}
Sapan Bhatia3cfdf632017-06-08 05:14:03 +0200130 {%- if proto.message_table[l.peer.fqn] -%}
131 {%- set model = proto.message_table[l.peer.fqn] %}
Sapan Bhatia943dad52017-05-19 18:41:01 +0200132 {% for f in model.fields %}
133 {{ f.type }} {{ f.name }};
134 {% endfor %}
135 {%- endif -%}
136 {% endfor %}
137 }
138 {% endfor %}
139"""
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700140 xtarget = XProtoTestHelpers.write_tmp_target(target)
Sapan Bhatia943dad52017-05-19 18:41:01 +0200141
Zack Williams045b63d2019-01-22 16:30:57 -0700142 proto = """
Sapan Bhatia943dad52017-05-19 18:41:01 +0200143message Port (PlCoreBase,ParameterMixin){
144 required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False];
145 optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True];
146 optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
147 optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True];
148 optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True];
149 required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True];
150}
151
152message Instance (PlCoreBase){
153 optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False];
154 optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False];
155 required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False];
156 optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False];
157 optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
158 required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False];
159 optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True];
160 required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False];
161 required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False];
162 required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False];
163 required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False];
164 required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False];
165 optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True];
166 required string isolation = 14 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
167 optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True];
168 optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True];
169 required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True];
170}
171
172message Network (PlCoreBase,ParameterMixin) {
173 required string name = 1 [db_index = False, max_length = 32, null = False, blank = False];
174 required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False];
175 required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True];
176 required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True];
177 required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True];
178 optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True];
179 optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True];
180 required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False];
181 required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False];
182 required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True];
183 optional string topology_parameters = 11 [db_index = False, null = True, blank = True];
184 optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True];
185 optional string controller_parameters = 13 [db_index = False, null = True, blank = True];
186 optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True];
187 optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True];
188 optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True];
189 required bool autoconnect = 17 [help_text = "This network can be autoconnected to the slice that owns it", default = True, null = False, db_index = False, blank = True];
190 required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True];
191 required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True];
192 required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True];
193}
194
195message Slice (PlCoreBase){
196 required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False];
197 required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True];
198 required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True];
199 required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True];
200 required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True];
201 required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
202 required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False];
203 optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True];
204 optional string network = 9 [blank = True, max_length = 256, null = True, db_index = False, choices = "((None, 'Default'), ('host', 'Host'), ('bridged', 'Bridged'), ('noauto', 'No Automatic Networks'))"];
205 optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True];
206 optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True];
207 optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True];
208 optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True];
209 optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True];
210 optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True];
211 optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False];
212 required string default_isolation = 17 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
213 required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True];
214}
215"""
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700216
Scott Baker1f7791d2018-10-04 13:21:20 -0700217 args = XOSProcessorArgs()
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700218 args.inputs = proto
219 args.target = xtarget
Sapan Bhatiabfb233a2018-02-09 14:53:09 -0800220 output = XOSProcessor.process(args)
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700221
Zack Williams045b63d2019-01-22 16:30:57 -0700222 num_semis = output.count(";")
Sapan Bhatia3cfdf632017-06-08 05:14:03 +0200223 self.assertGreater(num_semis, 3)
Sapan Bhatia943dad52017-05-19 18:41:01 +0200224
225 def test_from_base(self):
Zack Williams045b63d2019-01-22 16:30:57 -0700226 target = """
Sapan Bhatia943dad52017-05-19 18:41:01 +0200227 {% for f in xproto_base_fields(proto.messages.3, proto.message_table) %}
228 {{ f.type }} {{ f.name }};
229 {% endfor %}
230"""
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700231 xtarget = XProtoTestHelpers.write_tmp_target(target)
Zack Williams045b63d2019-01-22 16:30:57 -0700232 proto = """
Sapan Bhatia943dad52017-05-19 18:41:01 +0200233message Port (PlCoreBase,ParameterMixin){
234 required string easter_egg = 1;
235 required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False];
236 optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True];
237 optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
238 optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True];
239 optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True];
240 required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True];
241}
242
243message Instance (Port){
244 optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False];
245 optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False];
246 required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False];
247 optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False];
248 optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
249 required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False];
250 optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True];
251 required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False];
252 required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False];
253 required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False];
254 required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False];
255 required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False];
256 optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True];
257 required string isolation = 14 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
258 optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True];
259 optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True];
260 required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True];
261}
262
263message Network (Instance) {
264 required string name = 1 [db_index = False, max_length = 32, null = False, blank = False];
265 required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False];
266 required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True];
267 required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True];
268 required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True];
269 optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True];
270 optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True];
271 required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False];
272 required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False];
273 required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True];
274 optional string topology_parameters = 11 [db_index = False, null = True, blank = True];
275 optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True];
276 optional string controller_parameters = 13 [db_index = False, null = True, blank = True];
277 optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True];
278 optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True];
279 optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True];
280 required bool autoconnect = 17 [help_text = "This network can be autoconnected to the slice that owns it", default = True, null = False, db_index = False, blank = True];
281 required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True];
282 required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True];
283 required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True];
284}
285
286message Slice (Network){
287 required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False];
288 required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True];
289 required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True];
290 required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True];
291 required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True];
292 required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
293 required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False];
294 optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True];
295 optional string network = 9 [blank = True, max_length = 256, null = True, db_index = False, choices = "((None, 'Default'), ('host', 'Host'), ('bridged', 'Bridged'), ('noauto', 'No Automatic Networks'))"];
296 optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True];
297 optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True];
298 optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True];
299 optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True];
300 optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True];
301 optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True];
302 optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False];
303 required string default_isolation = 17 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
304 required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True];
305}
306"""
Scott Baker1f7791d2018-10-04 13:21:20 -0700307 args = XOSProcessorArgs()
Matteo Scandolo67654fa2017-06-09 09:33:17 -0700308 args.inputs = proto
309 args.target = xtarget
Sapan Bhatiabfb233a2018-02-09 14:53:09 -0800310 output = XOSProcessor.process(args)
Zack Williams045b63d2019-01-22 16:30:57 -0700311 self.assertIn("easter_egg", output)
Sapan Bhatia943dad52017-05-19 18:41:01 +0200312
Zack Williams045b63d2019-01-22 16:30:57 -0700313
314if __name__ == "__main__":
Sapan Bhatia943dad52017-05-19 18:41:01 +0200315 unittest.main()