Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 17 | import unittest |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame^] | 18 | from xosgenx.generator import XOSProcessor, XOSProcessorArgs |
| 19 | from helpers import XProtoTestHelpers |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 20 | |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 21 | class XProtoGraphTests(unittest.TestCase): |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 22 | def test_cross_model(self): |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 23 | target = XProtoTestHelpers.write_tmp_target( |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 24 | """ |
| 25 | {% for m in proto.messages %} |
| 26 | {{ m.name }} { |
| 27 | {%- for l in m.links %} |
Sapan Bhatia | 3cfdf63 | 2017-06-08 05:14:03 +0200 | [diff] [blame] | 28 | {%- if proto.message_table[l.peer.fqn] -%} |
| 29 | {%- set model = proto.message_table[l.peer.fqn] %} |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 30 | {% for f in model.fields %} |
| 31 | {{ f.type }} {{ f.name }}; |
| 32 | {% endfor %} |
| 33 | {%- endif -%} |
| 34 | {% endfor %} |
| 35 | } |
| 36 | {% endfor %} |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 37 | """) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 38 | |
| 39 | proto = \ |
| 40 | """ |
| 41 | message Port (PlCoreBase,ParameterMixin){ |
| 42 | required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False]; |
| 43 | optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True]; |
| 44 | optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 45 | optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True]; |
| 46 | optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True]; |
| 47 | required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True]; |
| 48 | } |
| 49 | |
| 50 | message Instance (PlCoreBase){ |
| 51 | optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False]; |
| 52 | optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False]; |
| 53 | required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False]; |
| 54 | optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False]; |
| 55 | optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 56 | required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False]; |
| 57 | optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True]; |
| 58 | required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False]; |
| 59 | required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False]; |
| 60 | required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False]; |
| 61 | required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False]; |
| 62 | required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False]; |
| 63 | optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True]; |
| 64 | 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]; |
| 65 | optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True]; |
| 66 | optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True]; |
| 67 | required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True]; |
| 68 | } |
| 69 | |
| 70 | message Network (PlCoreBase,ParameterMixin) { |
| 71 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 72 | required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False]; |
| 73 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 74 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 75 | required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 76 | optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 77 | optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 78 | required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False]; |
| 79 | required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False]; |
| 80 | required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True]; |
| 81 | optional string topology_parameters = 11 [db_index = False, null = True, blank = True]; |
| 82 | optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 83 | optional string controller_parameters = 13 [db_index = False, null = True, blank = True]; |
| 84 | optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True]; |
| 85 | optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True]; |
| 86 | optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True]; |
| 87 | 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]; |
| 88 | required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True]; |
| 89 | required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True]; |
| 90 | required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True]; |
| 91 | } |
| 92 | |
| 93 | message Slice (PlCoreBase){ |
| 94 | required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False]; |
| 95 | required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True]; |
| 96 | required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True]; |
| 97 | 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]; |
| 98 | required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True]; |
| 99 | required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False]; |
| 100 | required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False]; |
| 101 | optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True]; |
| 102 | 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'))"]; |
| 103 | optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True]; |
| 104 | optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True]; |
| 105 | optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True]; |
| 106 | optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True]; |
| 107 | optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True]; |
| 108 | optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True]; |
| 109 | optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False]; |
| 110 | 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]; |
| 111 | required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True]; |
| 112 | } |
| 113 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 114 | |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame^] | 115 | args = XOSProcessorArgs() |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 116 | args.inputs = proto |
| 117 | args.target = target |
Sapan Bhatia | bfb233a | 2018-02-09 14:53:09 -0800 | [diff] [blame] | 118 | output = XOSProcessor.process(args) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 119 | num_semis = output.count(';') |
| 120 | self.assertGreater(num_semis, 3) # 3 is the number of links, each of which contains at least one field |
| 121 | |
| 122 | def test_base_class_fields(self): |
| 123 | target = \ |
| 124 | """ |
| 125 | {% for m in proto.messages %} |
| 126 | {{ m.name }} { |
| 127 | {%- for l in m.links %} |
Sapan Bhatia | 3cfdf63 | 2017-06-08 05:14:03 +0200 | [diff] [blame] | 128 | {%- if proto.message_table[l.peer.fqn] -%} |
| 129 | {%- set model = proto.message_table[l.peer.fqn] %} |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 130 | {% for f in model.fields %} |
| 131 | {{ f.type }} {{ f.name }}; |
| 132 | {% endfor %} |
| 133 | {%- endif -%} |
| 134 | {% endfor %} |
| 135 | } |
| 136 | {% endfor %} |
| 137 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 138 | xtarget = XProtoTestHelpers.write_tmp_target(target) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 139 | |
| 140 | proto = \ |
| 141 | """ |
| 142 | message Port (PlCoreBase,ParameterMixin){ |
| 143 | required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False]; |
| 144 | optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True]; |
| 145 | optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 146 | optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True]; |
| 147 | optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True]; |
| 148 | required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True]; |
| 149 | } |
| 150 | |
| 151 | message Instance (PlCoreBase){ |
| 152 | optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False]; |
| 153 | optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False]; |
| 154 | required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False]; |
| 155 | optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False]; |
| 156 | optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 157 | required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False]; |
| 158 | optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True]; |
| 159 | required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False]; |
| 160 | required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False]; |
| 161 | required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False]; |
| 162 | required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False]; |
| 163 | required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False]; |
| 164 | optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True]; |
| 165 | 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]; |
| 166 | optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True]; |
| 167 | optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True]; |
| 168 | required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True]; |
| 169 | } |
| 170 | |
| 171 | message Network (PlCoreBase,ParameterMixin) { |
| 172 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 173 | required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False]; |
| 174 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 175 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 176 | required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 177 | optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 178 | optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 179 | required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False]; |
| 180 | required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False]; |
| 181 | required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True]; |
| 182 | optional string topology_parameters = 11 [db_index = False, null = True, blank = True]; |
| 183 | optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 184 | optional string controller_parameters = 13 [db_index = False, null = True, blank = True]; |
| 185 | optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True]; |
| 186 | optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True]; |
| 187 | optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True]; |
| 188 | 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]; |
| 189 | required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True]; |
| 190 | required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True]; |
| 191 | required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True]; |
| 192 | } |
| 193 | |
| 194 | message Slice (PlCoreBase){ |
| 195 | required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False]; |
| 196 | required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True]; |
| 197 | required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True]; |
| 198 | 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]; |
| 199 | required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True]; |
| 200 | required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False]; |
| 201 | required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False]; |
| 202 | optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True]; |
| 203 | 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'))"]; |
| 204 | optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True]; |
| 205 | optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True]; |
| 206 | optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True]; |
| 207 | optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True]; |
| 208 | optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True]; |
| 209 | optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True]; |
| 210 | optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False]; |
| 211 | 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]; |
| 212 | required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True]; |
| 213 | } |
| 214 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 215 | |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame^] | 216 | args = XOSProcessorArgs() |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 217 | args.inputs = proto |
| 218 | args.target = xtarget |
Sapan Bhatia | bfb233a | 2018-02-09 14:53:09 -0800 | [diff] [blame] | 219 | output = XOSProcessor.process(args) |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 220 | |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 221 | num_semis = output.count(';') |
Sapan Bhatia | 3cfdf63 | 2017-06-08 05:14:03 +0200 | [diff] [blame] | 222 | self.assertGreater(num_semis, 3) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 223 | |
| 224 | def test_from_base(self): |
| 225 | target = \ |
| 226 | """ |
| 227 | {% for f in xproto_base_fields(proto.messages.3, proto.message_table) %} |
| 228 | {{ f.type }} {{ f.name }}; |
| 229 | {% endfor %} |
| 230 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 231 | xtarget = XProtoTestHelpers.write_tmp_target(target) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 232 | proto = \ |
| 233 | """ |
| 234 | message Port (PlCoreBase,ParameterMixin){ |
| 235 | required string easter_egg = 1; |
| 236 | required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False]; |
| 237 | optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True]; |
| 238 | optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 239 | optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True]; |
| 240 | optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True]; |
| 241 | required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True]; |
| 242 | } |
| 243 | |
| 244 | message Instance (Port){ |
| 245 | optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False]; |
| 246 | optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False]; |
| 247 | required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False]; |
| 248 | optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False]; |
| 249 | optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 250 | required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False]; |
| 251 | optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True]; |
| 252 | required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False]; |
| 253 | required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False]; |
| 254 | required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False]; |
| 255 | required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False]; |
| 256 | required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False]; |
| 257 | optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True]; |
| 258 | 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]; |
| 259 | optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True]; |
| 260 | optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True]; |
| 261 | required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True]; |
| 262 | } |
| 263 | |
| 264 | message Network (Instance) { |
| 265 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 266 | required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False]; |
| 267 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 268 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 269 | required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 270 | optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 271 | optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 272 | required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False]; |
| 273 | required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False]; |
| 274 | required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True]; |
| 275 | optional string topology_parameters = 11 [db_index = False, null = True, blank = True]; |
| 276 | optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 277 | optional string controller_parameters = 13 [db_index = False, null = True, blank = True]; |
| 278 | optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True]; |
| 279 | optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True]; |
| 280 | optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True]; |
| 281 | 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]; |
| 282 | required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True]; |
| 283 | required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True]; |
| 284 | required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True]; |
| 285 | } |
| 286 | |
| 287 | message Slice (Network){ |
| 288 | required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False]; |
| 289 | required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True]; |
| 290 | required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True]; |
| 291 | 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]; |
| 292 | required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True]; |
| 293 | required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False]; |
| 294 | required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False]; |
| 295 | optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True]; |
| 296 | 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'))"]; |
| 297 | optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True]; |
| 298 | optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True]; |
| 299 | optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True]; |
| 300 | optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True]; |
| 301 | optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True]; |
| 302 | optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True]; |
| 303 | optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False]; |
| 304 | 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]; |
| 305 | required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True]; |
| 306 | } |
| 307 | """ |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame^] | 308 | args = XOSProcessorArgs() |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 309 | args.inputs = proto |
| 310 | args.target = xtarget |
Sapan Bhatia | bfb233a | 2018-02-09 14:53:09 -0800 | [diff] [blame] | 311 | output = XOSProcessor.process(args) |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 312 | self.assertIn('easter_egg', output) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 313 | |
| 314 | if __name__ == '__main__': |
| 315 | unittest.main() |
| 316 | |
| 317 | |