Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 1 | # 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 | |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 16 | import unittest |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame] | 17 | from xosgenx.generator import XOSProcessor, XOSProcessorArgs |
| 18 | from helpers import XProtoTestHelpers |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 19 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [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( |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 24 | """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 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 %} |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 37 | """ |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 38 | ) |
| 39 | |
| 40 | proto = """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 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) |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 119 | num_semis = output.count(";") |
| 120 | self.assertGreater( |
| 121 | num_semis, 3 |
| 122 | ) # 3 is the number of links, each of which contains at least one field |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 123 | |
| 124 | def test_base_class_fields(self): |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 125 | target = """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 126 | {% for m in proto.messages %} |
| 127 | {{ m.name }} { |
| 128 | {%- for l in m.links %} |
Sapan Bhatia | 3cfdf63 | 2017-06-08 05:14:03 +0200 | [diff] [blame] | 129 | {%- if proto.message_table[l.peer.fqn] -%} |
| 130 | {%- set model = proto.message_table[l.peer.fqn] %} |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 131 | {% for f in model.fields %} |
| 132 | {{ f.type }} {{ f.name }}; |
| 133 | {% endfor %} |
| 134 | {%- endif -%} |
| 135 | {% endfor %} |
| 136 | } |
| 137 | {% endfor %} |
| 138 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 139 | xtarget = XProtoTestHelpers.write_tmp_target(target) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 140 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 141 | proto = """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 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 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [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): |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 225 | target = """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 226 | {% for f in xproto_base_fields(proto.messages.3, proto.message_table) %} |
| 227 | {{ f.type }} {{ f.name }}; |
| 228 | {% endfor %} |
| 229 | """ |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 230 | xtarget = XProtoTestHelpers.write_tmp_target(target) |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 231 | proto = """ |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 232 | message Port (PlCoreBase,ParameterMixin){ |
| 233 | required string easter_egg = 1; |
| 234 | required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False]; |
| 235 | optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True]; |
| 236 | optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 237 | optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True]; |
| 238 | optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True]; |
| 239 | required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True]; |
| 240 | } |
| 241 | |
| 242 | message Instance (Port){ |
| 243 | optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False]; |
| 244 | optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False]; |
| 245 | required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False]; |
| 246 | optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False]; |
| 247 | optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 248 | required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False]; |
| 249 | optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True]; |
| 250 | required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False]; |
| 251 | required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False]; |
| 252 | required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False]; |
| 253 | required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False]; |
| 254 | required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", default = "get_default_flavor()", null = False, db_index = True, blank = False]; |
| 255 | optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True]; |
| 256 | 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]; |
| 257 | optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True]; |
| 258 | optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True]; |
| 259 | required manytomany tags->Tag = 17 [db_index = False, null = False, blank = True]; |
| 260 | } |
| 261 | |
| 262 | message Network (Instance) { |
| 263 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 264 | required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False]; |
| 265 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 266 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 267 | required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 268 | optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 269 | optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 270 | required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False]; |
| 271 | required int32 guaranteed_bandwidth = 9 [default = 0, null = False, db_index = False, blank = False]; |
| 272 | required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True]; |
| 273 | optional string topology_parameters = 11 [db_index = False, null = True, blank = True]; |
| 274 | optional string controller_url = 12 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 275 | optional string controller_parameters = 13 [db_index = False, null = True, blank = True]; |
| 276 | optional string network_id = 14 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True]; |
| 277 | optional string router_id = 15 [help_text = "Quantum router id", max_length = 256, null = True, db_index = False, blank = True]; |
| 278 | optional string subnet_id = 16 [help_text = "Quantum subnet id", max_length = 256, null = True, db_index = False, blank = True]; |
| 279 | 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]; |
| 280 | required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True]; |
| 281 | required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True]; |
| 282 | required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True]; |
| 283 | } |
| 284 | |
| 285 | message Slice (Network){ |
| 286 | required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False]; |
| 287 | required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True]; |
| 288 | required bool omf_friendly = 3 [default = False, null = False, db_index = False, blank = True]; |
| 289 | 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]; |
| 290 | required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True]; |
| 291 | required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False]; |
| 292 | required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False]; |
| 293 | optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True]; |
| 294 | 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'))"]; |
| 295 | optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True]; |
| 296 | optional manytoone serviceClass->ServiceClass:slices = 11 [db_index = True, null = True, blank = True]; |
| 297 | optional manytoone creator->User:slices = 12 [db_index = True, null = True, blank = True]; |
| 298 | optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True]; |
| 299 | optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True]; |
| 300 | optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True]; |
| 301 | optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False]; |
| 302 | 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]; |
| 303 | required manytomany tags->Tag = 18 [db_index = False, null = False, blank = True]; |
| 304 | } |
| 305 | """ |
Scott Baker | 1f7791d | 2018-10-04 13:21:20 -0700 | [diff] [blame] | 306 | args = XOSProcessorArgs() |
Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 307 | args.inputs = proto |
| 308 | args.target = xtarget |
Sapan Bhatia | bfb233a | 2018-02-09 14:53:09 -0800 | [diff] [blame] | 309 | output = XOSProcessor.process(args) |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 310 | self.assertIn("easter_egg", output) |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 311 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 312 | |
| 313 | if __name__ == "__main__": |
Sapan Bhatia | 943dad5 | 2017-05-19 18:41:01 +0200 | [diff] [blame] | 314 | unittest.main() |