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