How to use update_server method in tempest

Best Python code snippet using tempest_python

resource_test.py

Source:resource_test.py Github

copy

Full Screen

1'''2This module defines the fixture classes for all config elements3'''4# AUTO-GENERATED file from IFMapApiGenerator. Do Not Edit!5import cfixture6from vnc_api import vnc_api7from cfgm_common.exceptions import *8from generatedssuper import GeneratedsSuper9class DomainTestFixtureGen(cfixture.ContrailFixture):10 """11 Fixture for :class:`.Domain`12 """13 def __init__(self, conn_drv, domain_name=None, parent_fixt=None, auto_prop_val=False, domain_limits=None, api_access_list=None, id_perms=None, display_name=None):14 '''15 Create DomainTestFixtureGen object16 17 constructor18 Args:19 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)20 Kwargs:21 domain_name (str): Name of domain22 parent_fixt (:class:`.ConfigRootTestFixtureGen`): Parent fixture23 domain_limits (instance): instance of :class:`DomainLimitsType`24 api_access_list (instance): instance of :class:`ApiAccessListType`25 id_perms (instance): instance of :class:`IdPermsType`26 display_name (instance): instance of :class:`xsd:string`27 '''28 super(DomainTestFixtureGen, self).__init__()29 self._conn_drv = conn_drv30 if not domain_name:31 self._name = 'default-domain'32 else:33 self._name = domain_name34 self._obj = None35 self._parent_fixt = parent_fixt36 self._auto_prop_val = auto_prop_val37 self.domain_limits = domain_limits38 self.api_access_list = api_access_list39 self.id_perms = id_perms40 self.display_name = display_name41 #end __init__42 def _update_links (self, update_server):43 return None44 #end _update_links45 def populate (self):46 self._obj.set_domain_limits(self.domain_limits or vnc_api.gen.resource_xsd.DomainLimitsType.populate())47 self._obj.set_api_access_list(self.api_access_list or vnc_api.gen.resource_xsd.ApiAccessListType.populate())48 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())49 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))50 #end populate51 def setUp(self):52 super(DomainTestFixtureGen, self).setUp()53 # child of config-root54 self._obj = vnc_api.Domain(self._name)55 try:56 self._obj = self._conn_drv.domain_read (fq_name=self._obj.get_fq_name())57 self._update_links (update_server=True)58 except NoIdError:59 self._update_links (update_server=False)60 if self._auto_prop_val:61 self.populate ()62 else:63 self._obj.domain_limits = self.domain_limits64 self._obj.api_access_list = self.api_access_list65 self._obj.id_perms = self.id_perms66 self._obj.display_name = self.display_name67 self._conn_drv.domain_create(self._obj)68 # read back for server allocated values69 self._obj = self._conn_drv.domain_read(id = self._obj.uuid)70 #end setUp71 def cleanUp(self):72 if self._obj.get_projects() or self._obj.get_namespaces() or self._obj.get_service_templates() or self._obj.get_virtual_DNSs():73 return74 parent_fixt = getattr(self, '_parent_fixt', None)75 if parent_fixt:76 # non config-root child77 parent_obj = self._parent_fixt.getObj()78 # remove child from parent obj79 for child_obj in parent_obj.get_domains():80 if type(child_obj) == dict:81 child_uuid = child_obj['uuid']82 else:83 child_uuid = child_obj.uuid84 if child_uuid == self._obj.uuid:85 parent_obj.domains.remove(child_obj)86 break87 self._conn_drv.domain_delete(id = self._obj.uuid)88 #end cleanUp89 def getObj(self):90 return self._obj91 #end getObj92#end class DomainTestFixtureGen93class GlobalVrouterConfigTestFixtureGen(cfixture.ContrailFixture):94 """95 Fixture for :class:`.GlobalVrouterConfig`96 """97 def __init__(self, conn_drv, global_vrouter_config_name=None, parent_fixt=None, auto_prop_val=False, linklocal_services=None, encapsulation_priorities=None, vxlan_network_identifier_mode=None, forwarding_mode=None, id_perms=None, display_name=None):98 '''99 Create GlobalVrouterConfigTestFixtureGen object100 101 constructor102 Args:103 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)104 Kwargs:105 global_vrouter_config_name (str): Name of global_vrouter_config106 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture107 linklocal_services (instance): instance of :class:`LinklocalServicesTypes`108 encapsulation_priorities (instance): instance of :class:`EncapsulationPrioritiesType`109 vxlan_network_identifier_mode (instance): instance of :class:`xsd:string`110 forwarding_mode (instance): instance of :class:`xsd:string`111 id_perms (instance): instance of :class:`IdPermsType`112 display_name (instance): instance of :class:`xsd:string`113 '''114 super(GlobalVrouterConfigTestFixtureGen, self).__init__()115 self._conn_drv = conn_drv116 if not global_vrouter_config_name:117 self._name = 'default-global-vrouter-config'118 else:119 self._name = global_vrouter_config_name120 self._obj = None121 self._parent_fixt = parent_fixt122 self._auto_prop_val = auto_prop_val123 self.linklocal_services = linklocal_services124 self.encapsulation_priorities = encapsulation_priorities125 self.vxlan_network_identifier_mode = vxlan_network_identifier_mode126 self.forwarding_mode = forwarding_mode127 self.id_perms = id_perms128 self.display_name = display_name129 #end __init__130 def _update_links (self, update_server):131 return None132 #end _update_links133 def populate (self):134 self._obj.set_linklocal_services(self.linklocal_services or vnc_api.gen.resource_xsd.LinklocalServicesTypes.populate())135 self._obj.set_encapsulation_priorities(self.encapsulation_priorities or vnc_api.gen.resource_xsd.EncapsulationPrioritiesType.populate())136 self._obj.set_vxlan_network_identifier_mode(self.vxlan_network_identifier_mode or GeneratedsSuper.populate_string("vxlan_network_identifier_mode"))137 self._obj.set_forwarding_mode(self.forwarding_mode or GeneratedsSuper.populate_string("forwarding_mode"))138 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())139 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))140 #end populate141 def setUp(self):142 super(GlobalVrouterConfigTestFixtureGen, self).setUp()143 if not self._parent_fixt:144 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))145 self._obj = vnc_api.GlobalVrouterConfig(self._name, self._parent_fixt.getObj ())146 try:147 self._obj = self._conn_drv.global_vrouter_config_read (fq_name=self._obj.get_fq_name())148 self._update_links (update_server=True)149 except NoIdError:150 self._update_links (update_server=False)151 if self._auto_prop_val:152 self.populate ()153 else:154 self._obj.linklocal_services = self.linklocal_services155 self._obj.encapsulation_priorities = self.encapsulation_priorities156 self._obj.vxlan_network_identifier_mode = self.vxlan_network_identifier_mode157 self._obj.forwarding_mode = self.forwarding_mode158 self._obj.id_perms = self.id_perms159 self._obj.display_name = self.display_name160 self._conn_drv.global_vrouter_config_create(self._obj)161 # read back for server allocated values162 self._obj = self._conn_drv.global_vrouter_config_read(id = self._obj.uuid)163 #end setUp164 def cleanUp(self):165 parent_fixt = getattr(self, '_parent_fixt', None)166 if parent_fixt:167 # non config-root child168 parent_obj = self._parent_fixt.getObj()169 # remove child from parent obj170 for child_obj in parent_obj.get_global_vrouter_configs():171 if type(child_obj) == dict:172 child_uuid = child_obj['uuid']173 else:174 child_uuid = child_obj.uuid175 if child_uuid == self._obj.uuid:176 parent_obj.global_vrouter_configs.remove(child_obj)177 break178 self._conn_drv.global_vrouter_config_delete(id = self._obj.uuid)179 #end cleanUp180 def getObj(self):181 return self._obj182 #end getObj183#end class GlobalVrouterConfigTestFixtureGen184class InstanceIpTestFixtureGen(cfixture.ContrailFixture):185 """186 Fixture for :class:`.InstanceIp`187 """188 def __init__(self, conn_drv, instance_ip_name=None, auto_prop_val=False, virtual_network_refs = None, virtual_machine_interface_refs = None, instance_ip_address=None, instance_ip_family=None, instance_ip_mode=None, subnet_uuid=None, instance_ip_secondary=None, id_perms=None, display_name=None):189 '''190 Create InstanceIpTestFixtureGen object191 192 constructor193 Args:194 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)195 Kwargs:196 %s_name (str): Name of %s197 virtual_network (list): list of :class:`VirtualNetwork` type198 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type199 instance_ip_address (instance): instance of :class:`xsd:string`200 instance_ip_family (instance): instance of :class:`xsd:string`201 instance_ip_mode (instance): instance of :class:`xsd:string`202 subnet_uuid (instance): instance of :class:`xsd:string`203 instance_ip_secondary (instance): instance of :class:`xsd:boolean`204 id_perms (instance): instance of :class:`IdPermsType`205 display_name (instance): instance of :class:`xsd:string`206 '''207 super(InstanceIpTestFixtureGen, self).__init__()208 self._conn_drv = conn_drv209 if not instance_ip_name:210 self._name = 'default-instance-ip'211 else:212 self._name = instance_ip_name213 self._obj = None214 self._auto_prop_val = auto_prop_val215 if virtual_network_refs:216 for ln in virtual_network_refs:217 self.add_virtual_network (ln)218 if virtual_machine_interface_refs:219 for ln in virtual_machine_interface_refs:220 self.add_virtual_machine_interface (ln)221 self.instance_ip_address = instance_ip_address222 self.instance_ip_family = instance_ip_family223 self.instance_ip_mode = instance_ip_mode224 self.subnet_uuid = subnet_uuid225 self.instance_ip_secondary = instance_ip_secondary226 self.id_perms = id_perms227 self.display_name = display_name228 #end __init__229 def _update_links (self, update_server):230 for ln in self.get_virtual_networks ():231 self.add_virtual_network (ln.fixture (), update_server = update_server, add_link = False)232 for ln in self.get_virtual_machine_interfaces ():233 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)234 return None235 #end _update_links236 def add_virtual_network (self, lo, update_server = True, add_link = True):237 '''238 add :class:`VirtualNetwork` link to :class:`InstanceIp`239 Args:240 lo (:class:`VirtualNetwork`): obj to link241 '''242 if self._obj:243 self._obj.add_virtual_network (lo)244 if update_server:245 self._conn_drv.instance_ip_update (self._obj)246 if add_link:247 self.add_link('virtual_network', cfixture.ConrtailLink('virtual_network', 'instance_ip', 'virtual_network', ['ref'], lo))248 #end add_virtual_network_link249 def get_virtual_networks (self):250 return self.get_links ('virtual_network')251 #end get_virtual_networks252 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):253 '''254 add :class:`VirtualMachineInterface` link to :class:`InstanceIp`255 Args:256 lo (:class:`VirtualMachineInterface`): obj to link257 '''258 if self._obj:259 self._obj.add_virtual_machine_interface (lo)260 if update_server:261 self._conn_drv.instance_ip_update (self._obj)262 if add_link:263 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'instance_ip', 'virtual_machine_interface', ['ref'], lo))264 #end add_virtual_machine_interface_link265 def get_virtual_machine_interfaces (self):266 return self.get_links ('virtual_machine_interface')267 #end get_virtual_machine_interfaces268 def populate (self):269 self._obj.set_instance_ip_address(self.instance_ip_address or GeneratedsSuper.populate_string("instance_ip_address"))270 self._obj.set_instance_ip_family(self.instance_ip_family or GeneratedsSuper.populate_string("instance_ip_family"))271 self._obj.set_instance_ip_mode(self.instance_ip_mode or GeneratedsSuper.populate_string("instance_ip_mode"))272 self._obj.set_subnet_uuid(self.subnet_uuid or GeneratedsSuper.populate_string("subnet_uuid"))273 self._obj.set_instance_ip_secondary(self.instance_ip_secondary or GeneratedsSuper.populate_boolean("instance_ip_secondary"))274 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())275 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))276 #end populate277 def setUp(self):278 super(InstanceIpTestFixtureGen, self).setUp()279 self._obj = vnc_api.InstanceIp(self._name)280 try:281 self._obj = self._conn_drv.instance_ip_read (fq_name=self._obj.get_fq_name())282 self._update_links (update_server=True)283 except NoIdError:284 self._update_links (update_server=False)285 if self._auto_prop_val:286 self.populate ()287 else:288 self._obj.instance_ip_address = self.instance_ip_address289 self._obj.instance_ip_family = self.instance_ip_family290 self._obj.instance_ip_mode = self.instance_ip_mode291 self._obj.subnet_uuid = self.subnet_uuid292 self._obj.instance_ip_secondary = self.instance_ip_secondary293 self._obj.id_perms = self.id_perms294 self._obj.display_name = self.display_name295 self._conn_drv.instance_ip_create(self._obj)296 # read back for server allocated values297 self._obj = self._conn_drv.instance_ip_read(id = self._obj.uuid)298 #end setUp299 def cleanUp(self):300 self._conn_drv.instance_ip_delete(id = self._obj.uuid)301 #end cleanUp302 def getObj(self):303 return self._obj304 #end getObj305#end class InstanceIpTestFixtureGen306class NetworkPolicyTestFixtureGen(cfixture.ContrailFixture):307 """308 Fixture for :class:`.NetworkPolicy`309 """310 def __init__(self, conn_drv, network_policy_name=None, parent_fixt=None, auto_prop_val=False, network_policy_entries=None, id_perms=None, display_name=None):311 '''312 Create NetworkPolicyTestFixtureGen object313 314 constructor315 Args:316 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)317 Kwargs:318 network_policy_name (str): Name of network_policy319 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture320 network_policy_entries (instance): instance of :class:`PolicyEntriesType`321 id_perms (instance): instance of :class:`IdPermsType`322 display_name (instance): instance of :class:`xsd:string`323 '''324 super(NetworkPolicyTestFixtureGen, self).__init__()325 self._conn_drv = conn_drv326 if not network_policy_name:327 self._name = 'default-network-policy'328 else:329 self._name = network_policy_name330 self._obj = None331 self._parent_fixt = parent_fixt332 self._auto_prop_val = auto_prop_val333 self.network_policy_entries = network_policy_entries334 self.id_perms = id_perms335 self.display_name = display_name336 #end __init__337 def _update_links (self, update_server):338 return None339 #end _update_links340 def populate (self):341 self._obj.set_network_policy_entries(self.network_policy_entries or vnc_api.gen.resource_xsd.PolicyEntriesType.populate())342 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())343 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))344 #end populate345 def setUp(self):346 super(NetworkPolicyTestFixtureGen, self).setUp()347 if not self._parent_fixt:348 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))349 self._obj = vnc_api.NetworkPolicy(self._name, self._parent_fixt.getObj ())350 try:351 self._obj = self._conn_drv.network_policy_read (fq_name=self._obj.get_fq_name())352 self._update_links (update_server=True)353 except NoIdError:354 self._update_links (update_server=False)355 if self._auto_prop_val:356 self.populate ()357 else:358 self._obj.network_policy_entries = self.network_policy_entries359 self._obj.id_perms = self.id_perms360 self._obj.display_name = self.display_name361 self._conn_drv.network_policy_create(self._obj)362 # read back for server allocated values363 self._obj = self._conn_drv.network_policy_read(id = self._obj.uuid)364 #end setUp365 def cleanUp(self):366 if self._obj.get_virtual_network_back_refs():367 return368 parent_fixt = getattr(self, '_parent_fixt', None)369 if parent_fixt:370 # non config-root child371 parent_obj = self._parent_fixt.getObj()372 # remove child from parent obj373 for child_obj in parent_obj.get_network_policys():374 if type(child_obj) == dict:375 child_uuid = child_obj['uuid']376 else:377 child_uuid = child_obj.uuid378 if child_uuid == self._obj.uuid:379 parent_obj.network_policys.remove(child_obj)380 break381 self._conn_drv.network_policy_delete(id = self._obj.uuid)382 #end cleanUp383 def getObj(self):384 return self._obj385 #end getObj386#end class NetworkPolicyTestFixtureGen387class LoadbalancerPoolTestFixtureGen(cfixture.ContrailFixture):388 """389 Fixture for :class:`.LoadbalancerPool`390 """391 def __init__(self, conn_drv, loadbalancer_pool_name=None, parent_fixt=None, auto_prop_val=False, service_instance_refs = None, virtual_machine_interface_refs = None, service_appliance_set_refs = None, loadbalancer_healthmonitor_refs = None, loadbalancer_pool_properties=None, loadbalancer_pool_provider=None, loadbalancer_pool_custom_attributes=None, id_perms=None, display_name=None):392 '''393 Create LoadbalancerPoolTestFixtureGen object394 395 constructor396 Args:397 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)398 Kwargs:399 loadbalancer_pool_name (str): Name of loadbalancer_pool400 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture401 service_instance (list): list of :class:`ServiceInstance` type402 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type403 service_appliance_set (list): list of :class:`ServiceApplianceSet` type404 loadbalancer_healthmonitor (list): list of :class:`LoadbalancerHealthmonitor` type405 loadbalancer_pool_properties (instance): instance of :class:`LoadbalancerPoolType`406 loadbalancer_pool_provider (instance): instance of :class:`xsd:string`407 loadbalancer_pool_custom_attributes (instance): instance of :class:`KeyValuePairs`408 id_perms (instance): instance of :class:`IdPermsType`409 display_name (instance): instance of :class:`xsd:string`410 '''411 super(LoadbalancerPoolTestFixtureGen, self).__init__()412 self._conn_drv = conn_drv413 if not loadbalancer_pool_name:414 self._name = 'default-loadbalancer-pool'415 else:416 self._name = loadbalancer_pool_name417 self._obj = None418 self._parent_fixt = parent_fixt419 self._auto_prop_val = auto_prop_val420 if service_instance_refs:421 for ln in service_instance_refs:422 self.add_service_instance (ln)423 if virtual_machine_interface_refs:424 for ln in virtual_machine_interface_refs:425 self.add_virtual_machine_interface (ln)426 if service_appliance_set_refs:427 for ln in service_appliance_set_refs:428 self.add_service_appliance_set (ln)429 if loadbalancer_healthmonitor_refs:430 for ln in loadbalancer_healthmonitor_refs:431 self.add_loadbalancer_healthmonitor (ln)432 self.loadbalancer_pool_properties = loadbalancer_pool_properties433 self.loadbalancer_pool_provider = loadbalancer_pool_provider434 self.loadbalancer_pool_custom_attributes = loadbalancer_pool_custom_attributes435 self.id_perms = id_perms436 self.display_name = display_name437 #end __init__438 def _update_links (self, update_server):439 for ln in self.get_service_instances ():440 self.add_service_instance (ln.fixture (), update_server = update_server, add_link = False)441 for ln in self.get_virtual_machine_interfaces ():442 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)443 for ln in self.get_service_appliance_sets ():444 self.add_service_appliance_set (ln.fixture (), update_server = update_server, add_link = False)445 for ln in self.get_loadbalancer_healthmonitors ():446 self.add_loadbalancer_healthmonitor (ln.fixture (), update_server = update_server, add_link = False)447 return None448 #end _update_links449 def add_service_instance (self, lo, update_server = True, add_link = True):450 '''451 add :class:`ServiceInstance` link to :class:`LoadbalancerPool`452 Args:453 lo (:class:`ServiceInstance`): obj to link454 '''455 if self._obj:456 self._obj.add_service_instance (lo)457 if update_server:458 self._conn_drv.loadbalancer_pool_update (self._obj)459 if add_link:460 self.add_link('service_instance', cfixture.ConrtailLink('service_instance', 'loadbalancer_pool', 'service_instance', ['ref'], lo))461 #end add_service_instance_link462 def get_service_instances (self):463 return self.get_links ('service_instance')464 #end get_service_instances465 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):466 '''467 add :class:`VirtualMachineInterface` link to :class:`LoadbalancerPool`468 Args:469 lo (:class:`VirtualMachineInterface`): obj to link470 '''471 if self._obj:472 self._obj.add_virtual_machine_interface (lo)473 if update_server:474 self._conn_drv.loadbalancer_pool_update (self._obj)475 if add_link:476 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'loadbalancer_pool', 'virtual_machine_interface', ['ref'], lo))477 #end add_virtual_machine_interface_link478 def get_virtual_machine_interfaces (self):479 return self.get_links ('virtual_machine_interface')480 #end get_virtual_machine_interfaces481 def add_service_appliance_set (self, lo, update_server = True, add_link = True):482 '''483 add :class:`ServiceApplianceSet` link to :class:`LoadbalancerPool`484 Args:485 lo (:class:`ServiceApplianceSet`): obj to link486 '''487 if self._obj:488 self._obj.add_service_appliance_set (lo)489 if update_server:490 self._conn_drv.loadbalancer_pool_update (self._obj)491 if add_link:492 self.add_link('service_appliance_set', cfixture.ConrtailLink('service_appliance_set', 'loadbalancer_pool', 'service_appliance_set', ['ref'], lo))493 #end add_service_appliance_set_link494 def get_service_appliance_sets (self):495 return self.get_links ('service_appliance_set')496 #end get_service_appliance_sets497 def add_loadbalancer_healthmonitor (self, lo, update_server = True, add_link = True):498 '''499 add :class:`LoadbalancerHealthmonitor` link to :class:`LoadbalancerPool`500 Args:501 lo (:class:`LoadbalancerHealthmonitor`): obj to link502 '''503 if self._obj:504 self._obj.add_loadbalancer_healthmonitor (lo)505 if update_server:506 self._conn_drv.loadbalancer_pool_update (self._obj)507 if add_link:508 self.add_link('loadbalancer_healthmonitor', cfixture.ConrtailLink('loadbalancer_healthmonitor', 'loadbalancer_pool', 'loadbalancer_healthmonitor', ['ref'], lo))509 #end add_loadbalancer_healthmonitor_link510 def get_loadbalancer_healthmonitors (self):511 return self.get_links ('loadbalancer_healthmonitor')512 #end get_loadbalancer_healthmonitors513 def populate (self):514 self._obj.set_loadbalancer_pool_properties(self.loadbalancer_pool_properties or vnc_api.gen.resource_xsd.LoadbalancerPoolType.populate())515 self._obj.set_loadbalancer_pool_provider(self.loadbalancer_pool_provider or GeneratedsSuper.populate_string("loadbalancer_pool_provider"))516 self._obj.set_loadbalancer_pool_custom_attributes(self.loadbalancer_pool_custom_attributes or vnc_api.gen.resource_xsd.KeyValuePairs.populate())517 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())518 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))519 #end populate520 def setUp(self):521 super(LoadbalancerPoolTestFixtureGen, self).setUp()522 if not self._parent_fixt:523 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))524 self._obj = vnc_api.LoadbalancerPool(self._name, self._parent_fixt.getObj ())525 try:526 self._obj = self._conn_drv.loadbalancer_pool_read (fq_name=self._obj.get_fq_name())527 self._update_links (update_server=True)528 except NoIdError:529 self._update_links (update_server=False)530 if self._auto_prop_val:531 self.populate ()532 else:533 self._obj.loadbalancer_pool_properties = self.loadbalancer_pool_properties534 self._obj.loadbalancer_pool_provider = self.loadbalancer_pool_provider535 self._obj.loadbalancer_pool_custom_attributes = self.loadbalancer_pool_custom_attributes536 self._obj.id_perms = self.id_perms537 self._obj.display_name = self.display_name538 self._conn_drv.loadbalancer_pool_create(self._obj)539 # read back for server allocated values540 self._obj = self._conn_drv.loadbalancer_pool_read(id = self._obj.uuid)541 #end setUp542 def cleanUp(self):543 if self._obj.get_virtual_ip_back_refs():544 return545 if self._obj.get_loadbalancer_members():546 return547 parent_fixt = getattr(self, '_parent_fixt', None)548 if parent_fixt:549 # non config-root child550 parent_obj = self._parent_fixt.getObj()551 # remove child from parent obj552 for child_obj in parent_obj.get_loadbalancer_pools():553 if type(child_obj) == dict:554 child_uuid = child_obj['uuid']555 else:556 child_uuid = child_obj.uuid557 if child_uuid == self._obj.uuid:558 parent_obj.loadbalancer_pools.remove(child_obj)559 break560 self._conn_drv.loadbalancer_pool_delete(id = self._obj.uuid)561 #end cleanUp562 def getObj(self):563 return self._obj564 #end getObj565#end class LoadbalancerPoolTestFixtureGen566class VirtualDnsRecordTestFixtureGen(cfixture.ContrailFixture):567 """568 Fixture for :class:`.VirtualDnsRecord`569 """570 def __init__(self, conn_drv, virtual_DNS_record_name=None, parent_fixt=None, auto_prop_val=False, virtual_DNS_record_data=None, id_perms=None, display_name=None):571 '''572 Create VirtualDnsRecordTestFixtureGen object573 574 constructor575 Args:576 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)577 Kwargs:578 virtual_DNS_record_name (str): Name of virtual_DNS_record579 parent_fixt (:class:`.VirtualDnsTestFixtureGen`): Parent fixture580 virtual_DNS_record_data (instance): instance of :class:`VirtualDnsRecordType`581 id_perms (instance): instance of :class:`IdPermsType`582 display_name (instance): instance of :class:`xsd:string`583 '''584 super(VirtualDnsRecordTestFixtureGen, self).__init__()585 self._conn_drv = conn_drv586 if not virtual_DNS_record_name:587 self._name = 'default-virtual-DNS-record'588 else:589 self._name = virtual_DNS_record_name590 self._obj = None591 self._parent_fixt = parent_fixt592 self._auto_prop_val = auto_prop_val593 self.virtual_DNS_record_data = virtual_DNS_record_data594 self.id_perms = id_perms595 self.display_name = display_name596 #end __init__597 def _update_links (self, update_server):598 return None599 #end _update_links600 def populate (self):601 self._obj.set_virtual_DNS_record_data(self.virtual_DNS_record_data or vnc_api.gen.resource_xsd.VirtualDnsRecordType.populate())602 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())603 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))604 #end populate605 def setUp(self):606 super(VirtualDnsRecordTestFixtureGen, self).setUp()607 if not self._parent_fixt:608 self._parent_fixt = self.useFixture(VirtualDnsTestFixtureGen(self._conn_drv, 'default-virtual-DNS'))609 self._obj = vnc_api.VirtualDnsRecord(self._name, self._parent_fixt.getObj ())610 try:611 self._obj = self._conn_drv.virtual_DNS_record_read (fq_name=self._obj.get_fq_name())612 self._update_links (update_server=True)613 except NoIdError:614 self._update_links (update_server=False)615 if self._auto_prop_val:616 self.populate ()617 else:618 self._obj.virtual_DNS_record_data = self.virtual_DNS_record_data619 self._obj.id_perms = self.id_perms620 self._obj.display_name = self.display_name621 self._conn_drv.virtual_DNS_record_create(self._obj)622 # read back for server allocated values623 self._obj = self._conn_drv.virtual_DNS_record_read(id = self._obj.uuid)624 #end setUp625 def cleanUp(self):626 parent_fixt = getattr(self, '_parent_fixt', None)627 if parent_fixt:628 # non config-root child629 parent_obj = self._parent_fixt.getObj()630 # remove child from parent obj631 for child_obj in parent_obj.get_virtual_DNS_records():632 if type(child_obj) == dict:633 child_uuid = child_obj['uuid']634 else:635 child_uuid = child_obj.uuid636 if child_uuid == self._obj.uuid:637 parent_obj.virtual_DNS_records.remove(child_obj)638 break639 self._conn_drv.virtual_DNS_record_delete(id = self._obj.uuid)640 #end cleanUp641 def getObj(self):642 return self._obj643 #end getObj644#end class VirtualDnsRecordTestFixtureGen645class RouteTargetTestFixtureGen(cfixture.ContrailFixture):646 """647 Fixture for :class:`.RouteTarget`648 """649 def __init__(self, conn_drv, route_target_name=None, auto_prop_val=False, id_perms=None, display_name=None):650 '''651 Create RouteTargetTestFixtureGen object652 653 constructor654 Args:655 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)656 Kwargs:657 %s_name (str): Name of %s658 id_perms (instance): instance of :class:`IdPermsType`659 display_name (instance): instance of :class:`xsd:string`660 '''661 super(RouteTargetTestFixtureGen, self).__init__()662 self._conn_drv = conn_drv663 if not route_target_name:664 self._name = 'default-route-target'665 else:666 self._name = route_target_name667 self._obj = None668 self._auto_prop_val = auto_prop_val669 self.id_perms = id_perms670 self.display_name = display_name671 #end __init__672 def _update_links (self, update_server):673 return None674 #end _update_links675 def populate (self):676 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())677 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))678 #end populate679 def setUp(self):680 super(RouteTargetTestFixtureGen, self).setUp()681 self._obj = vnc_api.RouteTarget(self._name)682 try:683 self._obj = self._conn_drv.route_target_read (fq_name=self._obj.get_fq_name())684 self._update_links (update_server=True)685 except NoIdError:686 self._update_links (update_server=False)687 if self._auto_prop_val:688 self.populate ()689 else:690 self._obj.id_perms = self.id_perms691 self._obj.display_name = self.display_name692 self._conn_drv.route_target_create(self._obj)693 # read back for server allocated values694 self._obj = self._conn_drv.route_target_read(id = self._obj.uuid)695 #end setUp696 def cleanUp(self):697 if self._obj.get_logical_router_back_refs() or self._obj.get_routing_instance_back_refs():698 return699 self._conn_drv.route_target_delete(id = self._obj.uuid)700 #end cleanUp701 def getObj(self):702 return self._obj703 #end getObj704#end class RouteTargetTestFixtureGen705class FloatingIpTestFixtureGen(cfixture.ContrailFixture):706 """707 Fixture for :class:`.FloatingIp`708 """709 def __init__(self, conn_drv, floating_ip_name=None, parent_fixt=None, auto_prop_val=False, project_refs = None, virtual_machine_interface_refs = None, floating_ip_address=None, floating_ip_is_virtual_ip=None, floating_ip_fixed_ip_address=None, floating_ip_address_family=None, id_perms=None, display_name=None):710 '''711 Create FloatingIpTestFixtureGen object712 713 constructor714 Args:715 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)716 Kwargs:717 floating_ip_name (str): Name of floating_ip718 parent_fixt (:class:`.FloatingIpPoolTestFixtureGen`): Parent fixture719 project (list): list of :class:`Project` type720 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type721 floating_ip_address (instance): instance of :class:`xsd:string`722 floating_ip_is_virtual_ip (instance): instance of :class:`xsd:boolean`723 floating_ip_fixed_ip_address (instance): instance of :class:`xsd:string`724 floating_ip_address_family (instance): instance of :class:`xsd:string`725 id_perms (instance): instance of :class:`IdPermsType`726 display_name (instance): instance of :class:`xsd:string`727 '''728 super(FloatingIpTestFixtureGen, self).__init__()729 self._conn_drv = conn_drv730 if not floating_ip_name:731 self._name = 'default-floating-ip'732 else:733 self._name = floating_ip_name734 self._obj = None735 self._parent_fixt = parent_fixt736 self._auto_prop_val = auto_prop_val737 if project_refs:738 for ln in project_refs:739 self.add_project (ln)740 if virtual_machine_interface_refs:741 for ln in virtual_machine_interface_refs:742 self.add_virtual_machine_interface (ln)743 self.floating_ip_address = floating_ip_address744 self.floating_ip_is_virtual_ip = floating_ip_is_virtual_ip745 self.floating_ip_fixed_ip_address = floating_ip_fixed_ip_address746 self.floating_ip_address_family = floating_ip_address_family747 self.id_perms = id_perms748 self.display_name = display_name749 #end __init__750 def _update_links (self, update_server):751 for ln in self.get_projects ():752 self.add_project (ln.fixture (), update_server = update_server, add_link = False)753 for ln in self.get_virtual_machine_interfaces ():754 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)755 return None756 #end _update_links757 def add_project (self, lo, update_server = True, add_link = True):758 '''759 add :class:`Project` link to :class:`FloatingIp`760 Args:761 lo (:class:`Project`): obj to link762 '''763 if self._obj:764 self._obj.add_project (lo)765 if update_server:766 self._conn_drv.floating_ip_update (self._obj)767 if add_link:768 self.add_link('project', cfixture.ConrtailLink('project', 'floating_ip', 'project', ['ref'], lo))769 #end add_project_link770 def get_projects (self):771 return self.get_links ('project')772 #end get_projects773 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):774 '''775 add :class:`VirtualMachineInterface` link to :class:`FloatingIp`776 Args:777 lo (:class:`VirtualMachineInterface`): obj to link778 '''779 if self._obj:780 self._obj.add_virtual_machine_interface (lo)781 if update_server:782 self._conn_drv.floating_ip_update (self._obj)783 if add_link:784 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'floating_ip', 'virtual_machine_interface', ['ref'], lo))785 #end add_virtual_machine_interface_link786 def get_virtual_machine_interfaces (self):787 return self.get_links ('virtual_machine_interface')788 #end get_virtual_machine_interfaces789 def populate (self):790 self._obj.set_floating_ip_address(self.floating_ip_address or GeneratedsSuper.populate_string("floating_ip_address"))791 self._obj.set_floating_ip_is_virtual_ip(self.floating_ip_is_virtual_ip or GeneratedsSuper.populate_boolean("floating_ip_is_virtual_ip"))792 self._obj.set_floating_ip_fixed_ip_address(self.floating_ip_fixed_ip_address or GeneratedsSuper.populate_string("floating_ip_fixed_ip_address"))793 self._obj.set_floating_ip_address_family(self.floating_ip_address_family or GeneratedsSuper.populate_string("floating_ip_address_family"))794 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())795 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))796 #end populate797 def setUp(self):798 super(FloatingIpTestFixtureGen, self).setUp()799 if not self._parent_fixt:800 self._parent_fixt = self.useFixture(FloatingIpPoolTestFixtureGen(self._conn_drv, 'default-floating-ip-pool'))801 self._obj = vnc_api.FloatingIp(self._name, self._parent_fixt.getObj ())802 try:803 self._obj = self._conn_drv.floating_ip_read (fq_name=self._obj.get_fq_name())804 self._update_links (update_server=True)805 except NoIdError:806 self._update_links (update_server=False)807 if self._auto_prop_val:808 self.populate ()809 else:810 self._obj.floating_ip_address = self.floating_ip_address811 self._obj.floating_ip_is_virtual_ip = self.floating_ip_is_virtual_ip812 self._obj.floating_ip_fixed_ip_address = self.floating_ip_fixed_ip_address813 self._obj.floating_ip_address_family = self.floating_ip_address_family814 self._obj.id_perms = self.id_perms815 self._obj.display_name = self.display_name816 self._conn_drv.floating_ip_create(self._obj)817 # read back for server allocated values818 self._obj = self._conn_drv.floating_ip_read(id = self._obj.uuid)819 #end setUp820 def cleanUp(self):821 if self._obj.get_customer_attachment_back_refs():822 return823 parent_fixt = getattr(self, '_parent_fixt', None)824 if parent_fixt:825 # non config-root child826 parent_obj = self._parent_fixt.getObj()827 # remove child from parent obj828 for child_obj in parent_obj.get_floating_ips():829 if type(child_obj) == dict:830 child_uuid = child_obj['uuid']831 else:832 child_uuid = child_obj.uuid833 if child_uuid == self._obj.uuid:834 parent_obj.floating_ips.remove(child_obj)835 break836 self._conn_drv.floating_ip_delete(id = self._obj.uuid)837 #end cleanUp838 def getObj(self):839 return self._obj840 #end getObj841#end class FloatingIpTestFixtureGen842class FloatingIpPoolTestFixtureGen(cfixture.ContrailFixture):843 """844 Fixture for :class:`.FloatingIpPool`845 """846 def __init__(self, conn_drv, floating_ip_pool_name=None, parent_fixt=None, auto_prop_val=False, floating_ip_pool_prefixes=None, id_perms=None, display_name=None):847 '''848 Create FloatingIpPoolTestFixtureGen object849 850 constructor851 Args:852 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)853 Kwargs:854 floating_ip_pool_name (str): Name of floating_ip_pool855 parent_fixt (:class:`.VirtualNetworkTestFixtureGen`): Parent fixture856 floating_ip_pool_prefixes (instance): instance of :class:`FloatingIpPoolType`857 id_perms (instance): instance of :class:`IdPermsType`858 display_name (instance): instance of :class:`xsd:string`859 '''860 super(FloatingIpPoolTestFixtureGen, self).__init__()861 self._conn_drv = conn_drv862 if not floating_ip_pool_name:863 self._name = 'default-floating-ip-pool'864 else:865 self._name = floating_ip_pool_name866 self._obj = None867 self._parent_fixt = parent_fixt868 self._auto_prop_val = auto_prop_val869 self.floating_ip_pool_prefixes = floating_ip_pool_prefixes870 self.id_perms = id_perms871 self.display_name = display_name872 #end __init__873 def _update_links (self, update_server):874 return None875 #end _update_links876 def populate (self):877 self._obj.set_floating_ip_pool_prefixes(self.floating_ip_pool_prefixes or vnc_api.gen.resource_xsd.FloatingIpPoolType.populate())878 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())879 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))880 #end populate881 def setUp(self):882 super(FloatingIpPoolTestFixtureGen, self).setUp()883 if not self._parent_fixt:884 self._parent_fixt = self.useFixture(VirtualNetworkTestFixtureGen(self._conn_drv, 'default-virtual-network'))885 self._obj = vnc_api.FloatingIpPool(self._name, self._parent_fixt.getObj ())886 try:887 self._obj = self._conn_drv.floating_ip_pool_read (fq_name=self._obj.get_fq_name())888 self._update_links (update_server=True)889 except NoIdError:890 self._update_links (update_server=False)891 if self._auto_prop_val:892 self.populate ()893 else:894 self._obj.floating_ip_pool_prefixes = self.floating_ip_pool_prefixes895 self._obj.id_perms = self.id_perms896 self._obj.display_name = self.display_name897 self._conn_drv.floating_ip_pool_create(self._obj)898 # read back for server allocated values899 self._obj = self._conn_drv.floating_ip_pool_read(id = self._obj.uuid)900 #end setUp901 def cleanUp(self):902 if self._obj.get_project_back_refs():903 return904 if self._obj.get_floating_ips():905 return906 parent_fixt = getattr(self, '_parent_fixt', None)907 if parent_fixt:908 # non config-root child909 parent_obj = self._parent_fixt.getObj()910 # remove child from parent obj911 for child_obj in parent_obj.get_floating_ip_pools():912 if type(child_obj) == dict:913 child_uuid = child_obj['uuid']914 else:915 child_uuid = child_obj.uuid916 if child_uuid == self._obj.uuid:917 parent_obj.floating_ip_pools.remove(child_obj)918 break919 self._conn_drv.floating_ip_pool_delete(id = self._obj.uuid)920 #end cleanUp921 def getObj(self):922 return self._obj923 #end getObj924#end class FloatingIpPoolTestFixtureGen925class PhysicalRouterTestFixtureGen(cfixture.ContrailFixture):926 """927 Fixture for :class:`.PhysicalRouter`928 """929 def __init__(self, conn_drv, physical_router_name=None, parent_fixt=None, auto_prop_val=False, virtual_router_refs = None, bgp_router_refs = None, virtual_network_refs = None, physical_router_management_ip=None, physical_router_dataplane_ip=None, physical_router_vendor_name=None, physical_router_product_name=None, physical_router_vnc_managed=None, physical_router_user_credentials=None, physical_router_snmp_credentials=None, physical_router_junos_service_ports=None, id_perms=None, display_name=None):930 '''931 Create PhysicalRouterTestFixtureGen object932 933 constructor934 Args:935 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)936 Kwargs:937 physical_router_name (str): Name of physical_router938 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture939 virtual_router (list): list of :class:`VirtualRouter` type940 bgp_router (list): list of :class:`BgpRouter` type941 virtual_network (list): list of :class:`VirtualNetwork` type942 physical_router_management_ip (instance): instance of :class:`xsd:string`943 physical_router_dataplane_ip (instance): instance of :class:`xsd:string`944 physical_router_vendor_name (instance): instance of :class:`xsd:string`945 physical_router_product_name (instance): instance of :class:`xsd:string`946 physical_router_vnc_managed (instance): instance of :class:`xsd:boolean`947 physical_router_user_credentials (instance): instance of :class:`UserCredentials`948 physical_router_snmp_credentials (instance): instance of :class:`SNMPCredentials`949 physical_router_junos_service_ports (instance): instance of :class:`JunosServicePorts`950 id_perms (instance): instance of :class:`IdPermsType`951 display_name (instance): instance of :class:`xsd:string`952 '''953 super(PhysicalRouterTestFixtureGen, self).__init__()954 self._conn_drv = conn_drv955 if not physical_router_name:956 self._name = 'default-physical-router'957 else:958 self._name = physical_router_name959 self._obj = None960 self._parent_fixt = parent_fixt961 self._auto_prop_val = auto_prop_val962 if virtual_router_refs:963 for ln in virtual_router_refs:964 self.add_virtual_router (ln)965 if bgp_router_refs:966 for ln in bgp_router_refs:967 self.add_bgp_router (ln)968 if virtual_network_refs:969 for ln in virtual_network_refs:970 self.add_virtual_network (ln)971 self.physical_router_management_ip = physical_router_management_ip972 self.physical_router_dataplane_ip = physical_router_dataplane_ip973 self.physical_router_vendor_name = physical_router_vendor_name974 self.physical_router_product_name = physical_router_product_name975 self.physical_router_vnc_managed = physical_router_vnc_managed976 self.physical_router_user_credentials = physical_router_user_credentials977 self.physical_router_snmp_credentials = physical_router_snmp_credentials978 self.physical_router_junos_service_ports = physical_router_junos_service_ports979 self.id_perms = id_perms980 self.display_name = display_name981 #end __init__982 def _update_links (self, update_server):983 for ln in self.get_virtual_routers ():984 self.add_virtual_router (ln.fixture (), update_server = update_server, add_link = False)985 for ln in self.get_bgp_routers ():986 self.add_bgp_router (ln.fixture (), update_server = update_server, add_link = False)987 for ln in self.get_virtual_networks ():988 self.add_virtual_network (ln.fixture (), update_server = update_server, add_link = False)989 return None990 #end _update_links991 def add_virtual_router (self, lo, update_server = True, add_link = True):992 '''993 add :class:`VirtualRouter` link to :class:`PhysicalRouter`994 Args:995 lo (:class:`VirtualRouter`): obj to link996 '''997 if self._obj:998 self._obj.add_virtual_router (lo)999 if update_server:1000 self._conn_drv.physical_router_update (self._obj)1001 if add_link:1002 self.add_link('virtual_router', cfixture.ConrtailLink('virtual_router', 'physical_router', 'virtual_router', ['ref'], lo))1003 #end add_virtual_router_link1004 def get_virtual_routers (self):1005 return self.get_links ('virtual_router')1006 #end get_virtual_routers1007 def add_bgp_router (self, lo, update_server = True, add_link = True):1008 '''1009 add :class:`BgpRouter` link to :class:`PhysicalRouter`1010 Args:1011 lo (:class:`BgpRouter`): obj to link1012 '''1013 if self._obj:1014 self._obj.add_bgp_router (lo)1015 if update_server:1016 self._conn_drv.physical_router_update (self._obj)1017 if add_link:1018 self.add_link('bgp_router', cfixture.ConrtailLink('bgp_router', 'physical_router', 'bgp_router', ['ref'], lo))1019 #end add_bgp_router_link1020 def get_bgp_routers (self):1021 return self.get_links ('bgp_router')1022 #end get_bgp_routers1023 def add_virtual_network (self, lo, update_server = True, add_link = True):1024 '''1025 add :class:`VirtualNetwork` link to :class:`PhysicalRouter`1026 Args:1027 lo (:class:`VirtualNetwork`): obj to link1028 '''1029 if self._obj:1030 self._obj.add_virtual_network (lo)1031 if update_server:1032 self._conn_drv.physical_router_update (self._obj)1033 if add_link:1034 self.add_link('virtual_network', cfixture.ConrtailLink('virtual_network', 'physical_router', 'virtual_network', ['ref'], lo))1035 #end add_virtual_network_link1036 def get_virtual_networks (self):1037 return self.get_links ('virtual_network')1038 #end get_virtual_networks1039 def populate (self):1040 self._obj.set_physical_router_management_ip(self.physical_router_management_ip or GeneratedsSuper.populate_string("physical_router_management_ip"))1041 self._obj.set_physical_router_dataplane_ip(self.physical_router_dataplane_ip or GeneratedsSuper.populate_string("physical_router_dataplane_ip"))1042 self._obj.set_physical_router_vendor_name(self.physical_router_vendor_name or GeneratedsSuper.populate_string("physical_router_vendor_name"))1043 self._obj.set_physical_router_product_name(self.physical_router_product_name or GeneratedsSuper.populate_string("physical_router_product_name"))1044 self._obj.set_physical_router_vnc_managed(self.physical_router_vnc_managed or GeneratedsSuper.populate_boolean("physical_router_vnc_managed"))1045 self._obj.set_physical_router_user_credentials(self.physical_router_user_credentials or [vnc_api.gen.resource_xsd.UserCredentials.populate()])1046 self._obj.set_physical_router_snmp_credentials(self.physical_router_snmp_credentials or vnc_api.gen.resource_xsd.SNMPCredentials.populate())1047 self._obj.set_physical_router_junos_service_ports(self.physical_router_junos_service_ports or vnc_api.gen.resource_xsd.JunosServicePorts.populate())1048 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1049 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1050 #end populate1051 def setUp(self):1052 super(PhysicalRouterTestFixtureGen, self).setUp()1053 if not self._parent_fixt:1054 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))1055 self._obj = vnc_api.PhysicalRouter(self._name, self._parent_fixt.getObj ())1056 try:1057 self._obj = self._conn_drv.physical_router_read (fq_name=self._obj.get_fq_name())1058 self._update_links (update_server=True)1059 except NoIdError:1060 self._update_links (update_server=False)1061 if self._auto_prop_val:1062 self.populate ()1063 else:1064 self._obj.physical_router_management_ip = self.physical_router_management_ip1065 self._obj.physical_router_dataplane_ip = self.physical_router_dataplane_ip1066 self._obj.physical_router_vendor_name = self.physical_router_vendor_name1067 self._obj.physical_router_product_name = self.physical_router_product_name1068 self._obj.physical_router_vnc_managed = self.physical_router_vnc_managed1069 self._obj.physical_router_user_credentials = self.physical_router_user_credentials1070 self._obj.physical_router_snmp_credentials = self.physical_router_snmp_credentials1071 self._obj.physical_router_junos_service_ports = self.physical_router_junos_service_ports1072 self._obj.id_perms = self.id_perms1073 self._obj.display_name = self.display_name1074 self._conn_drv.physical_router_create(self._obj)1075 # read back for server allocated values1076 self._obj = self._conn_drv.physical_router_read(id = self._obj.uuid)1077 #end setUp1078 def cleanUp(self):1079 if self._obj.get_physical_interfaces() or self._obj.get_logical_interfaces():1080 return1081 parent_fixt = getattr(self, '_parent_fixt', None)1082 if parent_fixt:1083 # non config-root child1084 parent_obj = self._parent_fixt.getObj()1085 # remove child from parent obj1086 for child_obj in parent_obj.get_physical_routers():1087 if type(child_obj) == dict:1088 child_uuid = child_obj['uuid']1089 else:1090 child_uuid = child_obj.uuid1091 if child_uuid == self._obj.uuid:1092 parent_obj.physical_routers.remove(child_obj)1093 break1094 self._conn_drv.physical_router_delete(id = self._obj.uuid)1095 #end cleanUp1096 def getObj(self):1097 return self._obj1098 #end getObj1099#end class PhysicalRouterTestFixtureGen1100class BgpRouterTestFixtureGen(cfixture.ContrailFixture):1101 """1102 Fixture for :class:`.BgpRouter`1103 """1104 def __init__(self, conn_drv, bgp_router_name=None, parent_fixt=None, auto_prop_val=False, bgp_router_ref_infos = None, bgp_router_parameters=None, id_perms=None, display_name=None):1105 '''1106 Create BgpRouterTestFixtureGen object1107 1108 constructor1109 Args:1110 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1111 Kwargs:1112 bgp_router_name (str): Name of bgp_router1113 parent_fixt (:class:`.RoutingInstanceTestFixtureGen`): Parent fixture1114 bgp_router (list): list of tuple (:class:`BgpRouter`, :class: `BgpPeeringAttributes`) type1115 bgp_router_parameters (instance): instance of :class:`BgpRouterParams`1116 id_perms (instance): instance of :class:`IdPermsType`1117 display_name (instance): instance of :class:`xsd:string`1118 '''1119 super(BgpRouterTestFixtureGen, self).__init__()1120 self._conn_drv = conn_drv1121 if not bgp_router_name:1122 self._name = 'default-bgp-router'1123 else:1124 self._name = bgp_router_name1125 self._obj = None1126 self._parent_fixt = parent_fixt1127 self._auto_prop_val = auto_prop_val1128 if bgp_router_ref_infos:1129 for ln, ref in bgp_router_ref_infos:1130 self.add_bgp_router (ln, ref)1131 self.bgp_router_parameters = bgp_router_parameters1132 self.id_perms = id_perms1133 self.display_name = display_name1134 #end __init__1135 def _update_links (self, update_server):1136 for ln in self.get_bgp_routers ():1137 self.add_bgp_router (*ln.fixture (), update_server = update_server, add_link = False)1138 return None1139 #end _update_links1140 def add_bgp_router (self, lo, ref, update_server = True, add_link = True):1141 '''1142 add :class:`BgpRouter` link to :class:`BgpRouter`1143 Args:1144 lo (:class:`BgpRouter`): obj to link1145 ref (:class:`BgpPeeringAttributes`): property of the link object1146 '''1147 if self._obj:1148 self._obj.add_bgp_router (lo, ref)1149 if update_server:1150 self._conn_drv.bgp_router_update (self._obj)1151 if add_link:1152 self.add_link('bgp_router', cfixture.ConrtailLink('bgp_router', 'bgp_router', 'bgp_router', ['ref'], (lo, ref)))1153 #end add_bgp_router_link1154 def get_bgp_routers (self):1155 return self.get_links ('bgp_router')1156 #end get_bgp_routers1157 def populate (self):1158 self._obj.set_bgp_router_parameters(self.bgp_router_parameters or vnc_api.gen.resource_xsd.BgpRouterParams.populate())1159 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1160 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1161 #end populate1162 def setUp(self):1163 super(BgpRouterTestFixtureGen, self).setUp()1164 if not self._parent_fixt:1165 self._parent_fixt = self.useFixture(RoutingInstanceTestFixtureGen(self._conn_drv, 'default-routing-instance'))1166 self._obj = vnc_api.BgpRouter(self._name, self._parent_fixt.getObj ())1167 try:1168 self._obj = self._conn_drv.bgp_router_read (fq_name=self._obj.get_fq_name())1169 self._update_links (update_server=True)1170 except NoIdError:1171 self._update_links (update_server=False)1172 if self._auto_prop_val:1173 self.populate ()1174 else:1175 self._obj.bgp_router_parameters = self.bgp_router_parameters1176 self._obj.id_perms = self.id_perms1177 self._obj.display_name = self.display_name1178 self._conn_drv.bgp_router_create(self._obj)1179 # read back for server allocated values1180 self._obj = self._conn_drv.bgp_router_read(id = self._obj.uuid)1181 #end setUp1182 def cleanUp(self):1183 if self._obj.get_global_system_config_back_refs() or self._obj.get_physical_router_back_refs() or self._obj.get_virtual_router_back_refs() or self._obj.get_bgp_router_back_refs():1184 return1185 parent_fixt = getattr(self, '_parent_fixt', None)1186 if parent_fixt:1187 # non config-root child1188 parent_obj = self._parent_fixt.getObj()1189 # remove child from parent obj1190 for child_obj in parent_obj.get_bgp_routers():1191 if type(child_obj) == dict:1192 child_uuid = child_obj['uuid']1193 else:1194 child_uuid = child_obj.uuid1195 if child_uuid == self._obj.uuid:1196 parent_obj.bgp_routers.remove(child_obj)1197 break1198 self._conn_drv.bgp_router_delete(id = self._obj.uuid)1199 #end cleanUp1200 def getObj(self):1201 return self._obj1202 #end getObj1203#end class BgpRouterTestFixtureGen1204class VirtualRouterTestFixtureGen(cfixture.ContrailFixture):1205 """1206 Fixture for :class:`.VirtualRouter`1207 """1208 def __init__(self, conn_drv, virtual_router_name=None, parent_fixt=None, auto_prop_val=False, bgp_router_refs = None, virtual_machine_refs = None, virtual_router_type=None, virtual_router_ip_address=None, id_perms=None, display_name=None):1209 '''1210 Create VirtualRouterTestFixtureGen object1211 1212 constructor1213 Args:1214 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1215 Kwargs:1216 virtual_router_name (str): Name of virtual_router1217 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture1218 bgp_router (list): list of :class:`BgpRouter` type1219 virtual_machine (list): list of :class:`VirtualMachine` type1220 virtual_router_type (instance): instance of :class:`xsd:string`1221 virtual_router_ip_address (instance): instance of :class:`xsd:string`1222 id_perms (instance): instance of :class:`IdPermsType`1223 display_name (instance): instance of :class:`xsd:string`1224 '''1225 super(VirtualRouterTestFixtureGen, self).__init__()1226 self._conn_drv = conn_drv1227 if not virtual_router_name:1228 self._name = 'default-virtual-router'1229 else:1230 self._name = virtual_router_name1231 self._obj = None1232 self._parent_fixt = parent_fixt1233 self._auto_prop_val = auto_prop_val1234 if bgp_router_refs:1235 for ln in bgp_router_refs:1236 self.add_bgp_router (ln)1237 if virtual_machine_refs:1238 for ln in virtual_machine_refs:1239 self.add_virtual_machine (ln)1240 self.virtual_router_type = virtual_router_type1241 self.virtual_router_ip_address = virtual_router_ip_address1242 self.id_perms = id_perms1243 self.display_name = display_name1244 #end __init__1245 def _update_links (self, update_server):1246 for ln in self.get_bgp_routers ():1247 self.add_bgp_router (ln.fixture (), update_server = update_server, add_link = False)1248 for ln in self.get_virtual_machines ():1249 self.add_virtual_machine (ln.fixture (), update_server = update_server, add_link = False)1250 return None1251 #end _update_links1252 def add_bgp_router (self, lo, update_server = True, add_link = True):1253 '''1254 add :class:`BgpRouter` link to :class:`VirtualRouter`1255 Args:1256 lo (:class:`BgpRouter`): obj to link1257 '''1258 if self._obj:1259 self._obj.add_bgp_router (lo)1260 if update_server:1261 self._conn_drv.virtual_router_update (self._obj)1262 if add_link:1263 self.add_link('bgp_router', cfixture.ConrtailLink('bgp_router', 'virtual_router', 'bgp_router', ['ref'], lo))1264 #end add_bgp_router_link1265 def get_bgp_routers (self):1266 return self.get_links ('bgp_router')1267 #end get_bgp_routers1268 def add_virtual_machine (self, lo, update_server = True, add_link = True):1269 '''1270 add :class:`VirtualMachine` link to :class:`VirtualRouter`1271 Args:1272 lo (:class:`VirtualMachine`): obj to link1273 '''1274 if self._obj:1275 self._obj.add_virtual_machine (lo)1276 if update_server:1277 self._conn_drv.virtual_router_update (self._obj)1278 if add_link:1279 self.add_link('virtual_machine', cfixture.ConrtailLink('virtual_machine', 'virtual_router', 'virtual_machine', ['ref'], lo))1280 #end add_virtual_machine_link1281 def get_virtual_machines (self):1282 return self.get_links ('virtual_machine')1283 #end get_virtual_machines1284 def populate (self):1285 self._obj.set_virtual_router_type(self.virtual_router_type or GeneratedsSuper.populate_string("virtual_router_type"))1286 self._obj.set_virtual_router_ip_address(self.virtual_router_ip_address or GeneratedsSuper.populate_string("virtual_router_ip_address"))1287 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1288 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1289 #end populate1290 def setUp(self):1291 super(VirtualRouterTestFixtureGen, self).setUp()1292 if not self._parent_fixt:1293 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))1294 self._obj = vnc_api.VirtualRouter(self._name, self._parent_fixt.getObj ())1295 try:1296 self._obj = self._conn_drv.virtual_router_read (fq_name=self._obj.get_fq_name())1297 self._update_links (update_server=True)1298 except NoIdError:1299 self._update_links (update_server=False)1300 if self._auto_prop_val:1301 self.populate ()1302 else:1303 self._obj.virtual_router_type = self.virtual_router_type1304 self._obj.virtual_router_ip_address = self.virtual_router_ip_address1305 self._obj.id_perms = self.id_perms1306 self._obj.display_name = self.display_name1307 self._conn_drv.virtual_router_create(self._obj)1308 # read back for server allocated values1309 self._obj = self._conn_drv.virtual_router_read(id = self._obj.uuid)1310 #end setUp1311 def cleanUp(self):1312 if self._obj.get_physical_router_back_refs() or self._obj.get_provider_attachment_back_refs():1313 return1314 parent_fixt = getattr(self, '_parent_fixt', None)1315 if parent_fixt:1316 # non config-root child1317 parent_obj = self._parent_fixt.getObj()1318 # remove child from parent obj1319 for child_obj in parent_obj.get_virtual_routers():1320 if type(child_obj) == dict:1321 child_uuid = child_obj['uuid']1322 else:1323 child_uuid = child_obj.uuid1324 if child_uuid == self._obj.uuid:1325 parent_obj.virtual_routers.remove(child_obj)1326 break1327 self._conn_drv.virtual_router_delete(id = self._obj.uuid)1328 #end cleanUp1329 def getObj(self):1330 return self._obj1331 #end getObj1332#end class VirtualRouterTestFixtureGen1333class SubnetTestFixtureGen(cfixture.ContrailFixture):1334 """1335 Fixture for :class:`.Subnet`1336 """1337 def __init__(self, conn_drv, subnet_name=None, auto_prop_val=False, virtual_machine_interface_refs = None, subnet_ip_prefix=None, id_perms=None, display_name=None):1338 '''1339 Create SubnetTestFixtureGen object1340 1341 constructor1342 Args:1343 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1344 Kwargs:1345 %s_name (str): Name of %s1346 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type1347 subnet_ip_prefix (instance): instance of :class:`SubnetType`1348 id_perms (instance): instance of :class:`IdPermsType`1349 display_name (instance): instance of :class:`xsd:string`1350 '''1351 super(SubnetTestFixtureGen, self).__init__()1352 self._conn_drv = conn_drv1353 if not subnet_name:1354 self._name = 'default-subnet'1355 else:1356 self._name = subnet_name1357 self._obj = None1358 self._auto_prop_val = auto_prop_val1359 if virtual_machine_interface_refs:1360 for ln in virtual_machine_interface_refs:1361 self.add_virtual_machine_interface (ln)1362 self.subnet_ip_prefix = subnet_ip_prefix1363 self.id_perms = id_perms1364 self.display_name = display_name1365 #end __init__1366 def _update_links (self, update_server):1367 for ln in self.get_virtual_machine_interfaces ():1368 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)1369 return None1370 #end _update_links1371 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):1372 '''1373 add :class:`VirtualMachineInterface` link to :class:`Subnet`1374 Args:1375 lo (:class:`VirtualMachineInterface`): obj to link1376 '''1377 if self._obj:1378 self._obj.add_virtual_machine_interface (lo)1379 if update_server:1380 self._conn_drv.subnet_update (self._obj)1381 if add_link:1382 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'subnet', 'virtual_machine_interface', ['ref'], lo))1383 #end add_virtual_machine_interface_link1384 def get_virtual_machine_interfaces (self):1385 return self.get_links ('virtual_machine_interface')1386 #end get_virtual_machine_interfaces1387 def populate (self):1388 self._obj.set_subnet_ip_prefix(self.subnet_ip_prefix or vnc_api.gen.resource_xsd.SubnetType.populate())1389 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1390 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1391 #end populate1392 def setUp(self):1393 super(SubnetTestFixtureGen, self).setUp()1394 self._obj = vnc_api.Subnet(self._name)1395 try:1396 self._obj = self._conn_drv.subnet_read (fq_name=self._obj.get_fq_name())1397 self._update_links (update_server=True)1398 except NoIdError:1399 self._update_links (update_server=False)1400 if self._auto_prop_val:1401 self.populate ()1402 else:1403 self._obj.subnet_ip_prefix = self.subnet_ip_prefix1404 self._obj.id_perms = self.id_perms1405 self._obj.display_name = self.display_name1406 self._conn_drv.subnet_create(self._obj)1407 # read back for server allocated values1408 self._obj = self._conn_drv.subnet_read(id = self._obj.uuid)1409 #end setUp1410 def cleanUp(self):1411 self._conn_drv.subnet_delete(id = self._obj.uuid)1412 #end cleanUp1413 def getObj(self):1414 return self._obj1415 #end getObj1416#end class SubnetTestFixtureGen1417class GlobalSystemConfigTestFixtureGen(cfixture.ContrailFixture):1418 """1419 Fixture for :class:`.GlobalSystemConfig`1420 """1421 def __init__(self, conn_drv, global_system_config_name=None, parent_fixt=None, auto_prop_val=False, bgp_router_refs = None, autonomous_system=None, config_version=None, plugin_tuning=None, ibgp_auto_mesh=None, ip_fabric_subnets=None, id_perms=None, display_name=None):1422 '''1423 Create GlobalSystemConfigTestFixtureGen object1424 1425 constructor1426 Args:1427 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1428 Kwargs:1429 global_system_config_name (str): Name of global_system_config1430 parent_fixt (:class:`.ConfigRootTestFixtureGen`): Parent fixture1431 bgp_router (list): list of :class:`BgpRouter` type1432 autonomous_system (instance): instance of :class:`xsd:integer`1433 config_version (instance): instance of :class:`xsd:string`1434 plugin_tuning (instance): instance of :class:`PluginProperties`1435 ibgp_auto_mesh (instance): instance of :class:`xsd:boolean`1436 ip_fabric_subnets (instance): instance of :class:`SubnetListType`1437 id_perms (instance): instance of :class:`IdPermsType`1438 display_name (instance): instance of :class:`xsd:string`1439 '''1440 super(GlobalSystemConfigTestFixtureGen, self).__init__()1441 self._conn_drv = conn_drv1442 if not global_system_config_name:1443 self._name = 'default-global-system-config'1444 else:1445 self._name = global_system_config_name1446 self._obj = None1447 self._parent_fixt = parent_fixt1448 self._auto_prop_val = auto_prop_val1449 if bgp_router_refs:1450 for ln in bgp_router_refs:1451 self.add_bgp_router (ln)1452 self.autonomous_system = autonomous_system1453 self.config_version = config_version1454 self.plugin_tuning = plugin_tuning1455 self.ibgp_auto_mesh = ibgp_auto_mesh1456 self.ip_fabric_subnets = ip_fabric_subnets1457 self.id_perms = id_perms1458 self.display_name = display_name1459 #end __init__1460 def _update_links (self, update_server):1461 for ln in self.get_bgp_routers ():1462 self.add_bgp_router (ln.fixture (), update_server = update_server, add_link = False)1463 return None1464 #end _update_links1465 def add_bgp_router (self, lo, update_server = True, add_link = True):1466 '''1467 add :class:`BgpRouter` link to :class:`GlobalSystemConfig`1468 Args:1469 lo (:class:`BgpRouter`): obj to link1470 '''1471 if self._obj:1472 self._obj.add_bgp_router (lo)1473 if update_server:1474 self._conn_drv.global_system_config_update (self._obj)1475 if add_link:1476 self.add_link('bgp_router', cfixture.ConrtailLink('bgp_router', 'global_system_config', 'bgp_router', ['ref'], lo))1477 #end add_bgp_router_link1478 def get_bgp_routers (self):1479 return self.get_links ('bgp_router')1480 #end get_bgp_routers1481 def populate (self):1482 self._obj.set_autonomous_system(self.autonomous_system or GeneratedsSuper.populate_integer("autonomous_system"))1483 self._obj.set_config_version(self.config_version or GeneratedsSuper.populate_string("config_version"))1484 self._obj.set_plugin_tuning(self.plugin_tuning or vnc_api.gen.resource_xsd.PluginProperties.populate())1485 self._obj.set_ibgp_auto_mesh(self.ibgp_auto_mesh or GeneratedsSuper.populate_boolean("ibgp_auto_mesh"))1486 self._obj.set_ip_fabric_subnets(self.ip_fabric_subnets or vnc_api.gen.resource_xsd.SubnetListType.populate())1487 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1488 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1489 #end populate1490 def setUp(self):1491 super(GlobalSystemConfigTestFixtureGen, self).setUp()1492 # child of config-root1493 self._obj = vnc_api.GlobalSystemConfig(self._name)1494 try:1495 self._obj = self._conn_drv.global_system_config_read (fq_name=self._obj.get_fq_name())1496 self._update_links (update_server=True)1497 except NoIdError:1498 self._update_links (update_server=False)1499 if self._auto_prop_val:1500 self.populate ()1501 else:1502 self._obj.autonomous_system = self.autonomous_system1503 self._obj.config_version = self.config_version1504 self._obj.plugin_tuning = self.plugin_tuning1505 self._obj.ibgp_auto_mesh = self.ibgp_auto_mesh1506 self._obj.ip_fabric_subnets = self.ip_fabric_subnets1507 self._obj.id_perms = self.id_perms1508 self._obj.display_name = self.display_name1509 self._conn_drv.global_system_config_create(self._obj)1510 # read back for server allocated values1511 self._obj = self._conn_drv.global_system_config_read(id = self._obj.uuid)1512 #end setUp1513 def cleanUp(self):1514 if self._obj.get_global_vrouter_configs() or self._obj.get_physical_routers() or self._obj.get_virtual_routers() or self._obj.get_config_nodes() or self._obj.get_analytics_nodes() or self._obj.get_database_nodes() or self._obj.get_service_appliance_sets():1515 return1516 parent_fixt = getattr(self, '_parent_fixt', None)1517 if parent_fixt:1518 # non config-root child1519 parent_obj = self._parent_fixt.getObj()1520 # remove child from parent obj1521 for child_obj in parent_obj.get_global_system_configs():1522 if type(child_obj) == dict:1523 child_uuid = child_obj['uuid']1524 else:1525 child_uuid = child_obj.uuid1526 if child_uuid == self._obj.uuid:1527 parent_obj.global_system_configs.remove(child_obj)1528 break1529 self._conn_drv.global_system_config_delete(id = self._obj.uuid)1530 #end cleanUp1531 def getObj(self):1532 return self._obj1533 #end getObj1534#end class GlobalSystemConfigTestFixtureGen1535class ServiceApplianceTestFixtureGen(cfixture.ContrailFixture):1536 """1537 Fixture for :class:`.ServiceAppliance`1538 """1539 def __init__(self, conn_drv, service_appliance_name=None, parent_fixt=None, auto_prop_val=False, service_appliance_user_credentials=None, service_appliance_ip_address=None, service_appliance_properties=None, id_perms=None, display_name=None):1540 '''1541 Create ServiceApplianceTestFixtureGen object1542 1543 constructor1544 Args:1545 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1546 Kwargs:1547 service_appliance_name (str): Name of service_appliance1548 parent_fixt (:class:`.ServiceApplianceSetTestFixtureGen`): Parent fixture1549 service_appliance_user_credentials (instance): instance of :class:`UserCredentials`1550 service_appliance_ip_address (instance): instance of :class:`xsd:string`1551 service_appliance_properties (instance): instance of :class:`KeyValuePairs`1552 id_perms (instance): instance of :class:`IdPermsType`1553 display_name (instance): instance of :class:`xsd:string`1554 '''1555 super(ServiceApplianceTestFixtureGen, self).__init__()1556 self._conn_drv = conn_drv1557 if not service_appliance_name:1558 self._name = 'default-service-appliance'1559 else:1560 self._name = service_appliance_name1561 self._obj = None1562 self._parent_fixt = parent_fixt1563 self._auto_prop_val = auto_prop_val1564 self.service_appliance_user_credentials = service_appliance_user_credentials1565 self.service_appliance_ip_address = service_appliance_ip_address1566 self.service_appliance_properties = service_appliance_properties1567 self.id_perms = id_perms1568 self.display_name = display_name1569 #end __init__1570 def _update_links (self, update_server):1571 return None1572 #end _update_links1573 def populate (self):1574 self._obj.set_service_appliance_user_credentials(self.service_appliance_user_credentials or [vnc_api.gen.resource_xsd.UserCredentials.populate()])1575 self._obj.set_service_appliance_ip_address(self.service_appliance_ip_address or GeneratedsSuper.populate_string("service_appliance_ip_address"))1576 self._obj.set_service_appliance_properties(self.service_appliance_properties or vnc_api.gen.resource_xsd.KeyValuePairs.populate())1577 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1578 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1579 #end populate1580 def setUp(self):1581 super(ServiceApplianceTestFixtureGen, self).setUp()1582 if not self._parent_fixt:1583 self._parent_fixt = self.useFixture(ServiceApplianceSetTestFixtureGen(self._conn_drv, 'default-service-appliance-set'))1584 self._obj = vnc_api.ServiceAppliance(self._name, self._parent_fixt.getObj ())1585 try:1586 self._obj = self._conn_drv.service_appliance_read (fq_name=self._obj.get_fq_name())1587 self._update_links (update_server=True)1588 except NoIdError:1589 self._update_links (update_server=False)1590 if self._auto_prop_val:1591 self.populate ()1592 else:1593 self._obj.service_appliance_user_credentials = self.service_appliance_user_credentials1594 self._obj.service_appliance_ip_address = self.service_appliance_ip_address1595 self._obj.service_appliance_properties = self.service_appliance_properties1596 self._obj.id_perms = self.id_perms1597 self._obj.display_name = self.display_name1598 self._conn_drv.service_appliance_create(self._obj)1599 # read back for server allocated values1600 self._obj = self._conn_drv.service_appliance_read(id = self._obj.uuid)1601 #end setUp1602 def cleanUp(self):1603 parent_fixt = getattr(self, '_parent_fixt', None)1604 if parent_fixt:1605 # non config-root child1606 parent_obj = self._parent_fixt.getObj()1607 # remove child from parent obj1608 for child_obj in parent_obj.get_service_appliances():1609 if type(child_obj) == dict:1610 child_uuid = child_obj['uuid']1611 else:1612 child_uuid = child_obj.uuid1613 if child_uuid == self._obj.uuid:1614 parent_obj.service_appliances.remove(child_obj)1615 break1616 self._conn_drv.service_appliance_delete(id = self._obj.uuid)1617 #end cleanUp1618 def getObj(self):1619 return self._obj1620 #end getObj1621#end class ServiceApplianceTestFixtureGen1622class ServiceInstanceTestFixtureGen(cfixture.ContrailFixture):1623 """1624 Fixture for :class:`.ServiceInstance`1625 """1626 def __init__(self, conn_drv, service_instance_name=None, parent_fixt=None, auto_prop_val=False, service_template_refs = None, service_instance_properties=None, id_perms=None, display_name=None):1627 '''1628 Create ServiceInstanceTestFixtureGen object1629 1630 constructor1631 Args:1632 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1633 Kwargs:1634 service_instance_name (str): Name of service_instance1635 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture1636 service_template (list): list of :class:`ServiceTemplate` type1637 service_instance_properties (instance): instance of :class:`ServiceInstanceType`1638 id_perms (instance): instance of :class:`IdPermsType`1639 display_name (instance): instance of :class:`xsd:string`1640 '''1641 super(ServiceInstanceTestFixtureGen, self).__init__()1642 self._conn_drv = conn_drv1643 if not service_instance_name:1644 self._name = 'default-service-instance'1645 else:1646 self._name = service_instance_name1647 self._obj = None1648 self._parent_fixt = parent_fixt1649 self._auto_prop_val = auto_prop_val1650 if service_template_refs:1651 for ln in service_template_refs:1652 self.add_service_template (ln)1653 self.service_instance_properties = service_instance_properties1654 self.id_perms = id_perms1655 self.display_name = display_name1656 #end __init__1657 def _update_links (self, update_server):1658 for ln in self.get_service_templates ():1659 self.add_service_template (ln.fixture (), update_server = update_server, add_link = False)1660 return None1661 #end _update_links1662 def add_service_template (self, lo, update_server = True, add_link = True):1663 '''1664 add :class:`ServiceTemplate` link to :class:`ServiceInstance`1665 Args:1666 lo (:class:`ServiceTemplate`): obj to link1667 '''1668 if self._obj:1669 self._obj.add_service_template (lo)1670 if update_server:1671 self._conn_drv.service_instance_update (self._obj)1672 if add_link:1673 self.add_link('service_template', cfixture.ConrtailLink('service_template', 'service_instance', 'service_template', ['ref'], lo))1674 #end add_service_template_link1675 def get_service_templates (self):1676 return self.get_links ('service_template')1677 #end get_service_templates1678 def populate (self):1679 self._obj.set_service_instance_properties(self.service_instance_properties or vnc_api.gen.resource_xsd.ServiceInstanceType.populate())1680 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1681 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1682 #end populate1683 def setUp(self):1684 super(ServiceInstanceTestFixtureGen, self).setUp()1685 if not self._parent_fixt:1686 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))1687 self._obj = vnc_api.ServiceInstance(self._name, self._parent_fixt.getObj ())1688 try:1689 self._obj = self._conn_drv.service_instance_read (fq_name=self._obj.get_fq_name())1690 self._update_links (update_server=True)1691 except NoIdError:1692 self._update_links (update_server=False)1693 if self._auto_prop_val:1694 self.populate ()1695 else:1696 self._obj.service_instance_properties = self.service_instance_properties1697 self._obj.id_perms = self.id_perms1698 self._obj.display_name = self.display_name1699 self._conn_drv.service_instance_create(self._obj)1700 # read back for server allocated values1701 self._obj = self._conn_drv.service_instance_read(id = self._obj.uuid)1702 #end setUp1703 def cleanUp(self):1704 if self._obj.get_logical_router_back_refs() or self._obj.get_loadbalancer_pool_back_refs():1705 return1706 parent_fixt = getattr(self, '_parent_fixt', None)1707 if parent_fixt:1708 # non config-root child1709 parent_obj = self._parent_fixt.getObj()1710 # remove child from parent obj1711 for child_obj in parent_obj.get_service_instances():1712 if type(child_obj) == dict:1713 child_uuid = child_obj['uuid']1714 else:1715 child_uuid = child_obj.uuid1716 if child_uuid == self._obj.uuid:1717 parent_obj.service_instances.remove(child_obj)1718 break1719 self._conn_drv.service_instance_delete(id = self._obj.uuid)1720 #end cleanUp1721 def getObj(self):1722 return self._obj1723 #end getObj1724#end class ServiceInstanceTestFixtureGen1725class NamespaceTestFixtureGen(cfixture.ContrailFixture):1726 """1727 Fixture for :class:`.Namespace`1728 """1729 def __init__(self, conn_drv, namespace_name=None, parent_fixt=None, auto_prop_val=False, namespace_cidr=None, id_perms=None, display_name=None):1730 '''1731 Create NamespaceTestFixtureGen object1732 1733 constructor1734 Args:1735 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1736 Kwargs:1737 namespace_name (str): Name of namespace1738 parent_fixt (:class:`.DomainTestFixtureGen`): Parent fixture1739 namespace_cidr (instance): instance of :class:`SubnetType`1740 id_perms (instance): instance of :class:`IdPermsType`1741 display_name (instance): instance of :class:`xsd:string`1742 '''1743 super(NamespaceTestFixtureGen, self).__init__()1744 self._conn_drv = conn_drv1745 if not namespace_name:1746 self._name = 'default-namespace'1747 else:1748 self._name = namespace_name1749 self._obj = None1750 self._parent_fixt = parent_fixt1751 self._auto_prop_val = auto_prop_val1752 self.namespace_cidr = namespace_cidr1753 self.id_perms = id_perms1754 self.display_name = display_name1755 #end __init__1756 def _update_links (self, update_server):1757 return None1758 #end _update_links1759 def populate (self):1760 self._obj.set_namespace_cidr(self.namespace_cidr or vnc_api.gen.resource_xsd.SubnetType.populate())1761 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1762 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1763 #end populate1764 def setUp(self):1765 super(NamespaceTestFixtureGen, self).setUp()1766 if not self._parent_fixt:1767 self._parent_fixt = self.useFixture(DomainTestFixtureGen(self._conn_drv, 'default-domain'))1768 self._obj = vnc_api.Namespace(self._name, self._parent_fixt.getObj ())1769 try:1770 self._obj = self._conn_drv.namespace_read (fq_name=self._obj.get_fq_name())1771 self._update_links (update_server=True)1772 except NoIdError:1773 self._update_links (update_server=False)1774 if self._auto_prop_val:1775 self.populate ()1776 else:1777 self._obj.namespace_cidr = self.namespace_cidr1778 self._obj.id_perms = self.id_perms1779 self._obj.display_name = self.display_name1780 self._conn_drv.namespace_create(self._obj)1781 # read back for server allocated values1782 self._obj = self._conn_drv.namespace_read(id = self._obj.uuid)1783 #end setUp1784 def cleanUp(self):1785 if self._obj.get_project_back_refs():1786 return1787 parent_fixt = getattr(self, '_parent_fixt', None)1788 if parent_fixt:1789 # non config-root child1790 parent_obj = self._parent_fixt.getObj()1791 # remove child from parent obj1792 for child_obj in parent_obj.get_namespaces():1793 if type(child_obj) == dict:1794 child_uuid = child_obj['uuid']1795 else:1796 child_uuid = child_obj.uuid1797 if child_uuid == self._obj.uuid:1798 parent_obj.namespaces.remove(child_obj)1799 break1800 self._conn_drv.namespace_delete(id = self._obj.uuid)1801 #end cleanUp1802 def getObj(self):1803 return self._obj1804 #end getObj1805#end class NamespaceTestFixtureGen1806class LogicalInterfaceTestFixtureGen(cfixture.ContrailFixture):1807 """1808 Fixture for :class:`.LogicalInterface`1809 """1810 def __init__(self, conn_drv, logical_interface_name=None, parent_fixt=None, auto_prop_val=False, virtual_machine_interface_refs = None, logical_interface_vlan_tag=None, logical_interface_type=None, id_perms=None, display_name=None):1811 '''1812 Create LogicalInterfaceTestFixtureGen object1813 1814 constructor1815 Args:1816 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1817 Kwargs:1818 logical_interface_name (str): Name of logical_interface1819 parent_fixt (:class:`.PhysicalRouterTestFixtureGen`): Parent fixture1820 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type1821 logical_interface_vlan_tag (instance): instance of :class:`xsd:integer`1822 logical_interface_type (instance): instance of :class:`xsd:string`1823 id_perms (instance): instance of :class:`IdPermsType`1824 display_name (instance): instance of :class:`xsd:string`1825 '''1826 super(LogicalInterfaceTestFixtureGen, self).__init__()1827 self._conn_drv = conn_drv1828 if not logical_interface_name:1829 self._name = 'default-logical-interface'1830 else:1831 self._name = logical_interface_name1832 self._obj = None1833 self._parent_fixt = parent_fixt1834 self._auto_prop_val = auto_prop_val1835 if virtual_machine_interface_refs:1836 for ln in virtual_machine_interface_refs:1837 self.add_virtual_machine_interface (ln)1838 self.logical_interface_vlan_tag = logical_interface_vlan_tag1839 self.logical_interface_type = logical_interface_type1840 self.id_perms = id_perms1841 self.display_name = display_name1842 #end __init__1843 def _update_links (self, update_server):1844 for ln in self.get_virtual_machine_interfaces ():1845 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)1846 return None1847 #end _update_links1848 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):1849 '''1850 add :class:`VirtualMachineInterface` link to :class:`LogicalInterface`1851 Args:1852 lo (:class:`VirtualMachineInterface`): obj to link1853 '''1854 if self._obj:1855 self._obj.add_virtual_machine_interface (lo)1856 if update_server:1857 self._conn_drv.logical_interface_update (self._obj)1858 if add_link:1859 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'logical_interface', 'virtual_machine_interface', ['ref'], lo))1860 #end add_virtual_machine_interface_link1861 def get_virtual_machine_interfaces (self):1862 return self.get_links ('virtual_machine_interface')1863 #end get_virtual_machine_interfaces1864 def populate (self):1865 self._obj.set_logical_interface_vlan_tag(self.logical_interface_vlan_tag or GeneratedsSuper.populate_integer("logical_interface_vlan_tag"))1866 self._obj.set_logical_interface_type(self.logical_interface_type or GeneratedsSuper.populate_string("logical_interface_type"))1867 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1868 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1869 #end populate1870 def setUp(self):1871 super(LogicalInterfaceTestFixtureGen, self).setUp()1872 if not self._parent_fixt:1873 raise AmbiguousParentError("[[u'default-global-system-config', u'default-physical-router'], [u'default-global-system-config', u'default-physical-router', u'default-physical-interface']]")1874 self._obj = vnc_api.LogicalInterface(self._name, self._parent_fixt.getObj ())1875 try:1876 self._obj = self._conn_drv.logical_interface_read (fq_name=self._obj.get_fq_name())1877 self._update_links (update_server=True)1878 except NoIdError:1879 self._update_links (update_server=False)1880 if self._auto_prop_val:1881 self.populate ()1882 else:1883 self._obj.logical_interface_vlan_tag = self.logical_interface_vlan_tag1884 self._obj.logical_interface_type = self.logical_interface_type1885 self._obj.id_perms = self.id_perms1886 self._obj.display_name = self.display_name1887 self._conn_drv.logical_interface_create(self._obj)1888 # read back for server allocated values1889 self._obj = self._conn_drv.logical_interface_read(id = self._obj.uuid)1890 #end setUp1891 def cleanUp(self):1892 parent_fixt = getattr(self, '_parent_fixt', None)1893 if parent_fixt:1894 # non config-root child1895 parent_obj = self._parent_fixt.getObj()1896 # remove child from parent obj1897 for child_obj in parent_obj.get_logical_interfaces():1898 if type(child_obj) == dict:1899 child_uuid = child_obj['uuid']1900 else:1901 child_uuid = child_obj.uuid1902 if child_uuid == self._obj.uuid:1903 parent_obj.logical_interfaces.remove(child_obj)1904 break1905 self._conn_drv.logical_interface_delete(id = self._obj.uuid)1906 #end cleanUp1907 def getObj(self):1908 return self._obj1909 #end getObj1910#end class LogicalInterfaceTestFixtureGen1911class RouteTableTestFixtureGen(cfixture.ContrailFixture):1912 """1913 Fixture for :class:`.RouteTable`1914 """1915 def __init__(self, conn_drv, route_table_name=None, parent_fixt=None, auto_prop_val=False, routes=None, id_perms=None, display_name=None):1916 '''1917 Create RouteTableTestFixtureGen object1918 1919 constructor1920 Args:1921 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)1922 Kwargs:1923 route_table_name (str): Name of route_table1924 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture1925 routes (instance): instance of :class:`RouteTableType`1926 id_perms (instance): instance of :class:`IdPermsType`1927 display_name (instance): instance of :class:`xsd:string`1928 '''1929 super(RouteTableTestFixtureGen, self).__init__()1930 self._conn_drv = conn_drv1931 if not route_table_name:1932 self._name = 'default-route-table'1933 else:1934 self._name = route_table_name1935 self._obj = None1936 self._parent_fixt = parent_fixt1937 self._auto_prop_val = auto_prop_val1938 self.routes = routes1939 self.id_perms = id_perms1940 self.display_name = display_name1941 #end __init__1942 def _update_links (self, update_server):1943 return None1944 #end _update_links1945 def populate (self):1946 self._obj.set_routes(self.routes or vnc_api.gen.resource_xsd.RouteTableType.populate())1947 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())1948 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))1949 #end populate1950 def setUp(self):1951 super(RouteTableTestFixtureGen, self).setUp()1952 if not self._parent_fixt:1953 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))1954 self._obj = vnc_api.RouteTable(self._name, self._parent_fixt.getObj ())1955 try:1956 self._obj = self._conn_drv.route_table_read (fq_name=self._obj.get_fq_name())1957 self._update_links (update_server=True)1958 except NoIdError:1959 self._update_links (update_server=False)1960 if self._auto_prop_val:1961 self.populate ()1962 else:1963 self._obj.routes = self.routes1964 self._obj.id_perms = self.id_perms1965 self._obj.display_name = self.display_name1966 self._conn_drv.route_table_create(self._obj)1967 # read back for server allocated values1968 self._obj = self._conn_drv.route_table_read(id = self._obj.uuid)1969 #end setUp1970 def cleanUp(self):1971 if self._obj.get_virtual_network_back_refs():1972 return1973 parent_fixt = getattr(self, '_parent_fixt', None)1974 if parent_fixt:1975 # non config-root child1976 parent_obj = self._parent_fixt.getObj()1977 # remove child from parent obj1978 for child_obj in parent_obj.get_route_tables():1979 if type(child_obj) == dict:1980 child_uuid = child_obj['uuid']1981 else:1982 child_uuid = child_obj.uuid1983 if child_uuid == self._obj.uuid:1984 parent_obj.route_tables.remove(child_obj)1985 break1986 self._conn_drv.route_table_delete(id = self._obj.uuid)1987 #end cleanUp1988 def getObj(self):1989 return self._obj1990 #end getObj1991#end class RouteTableTestFixtureGen1992class PhysicalInterfaceTestFixtureGen(cfixture.ContrailFixture):1993 """1994 Fixture for :class:`.PhysicalInterface`1995 """1996 def __init__(self, conn_drv, physical_interface_name=None, parent_fixt=None, auto_prop_val=False, id_perms=None, display_name=None):1997 '''1998 Create PhysicalInterfaceTestFixtureGen object1999 2000 constructor2001 Args:2002 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2003 Kwargs:2004 physical_interface_name (str): Name of physical_interface2005 parent_fixt (:class:`.PhysicalRouterTestFixtureGen`): Parent fixture2006 id_perms (instance): instance of :class:`IdPermsType`2007 display_name (instance): instance of :class:`xsd:string`2008 '''2009 super(PhysicalInterfaceTestFixtureGen, self).__init__()2010 self._conn_drv = conn_drv2011 if not physical_interface_name:2012 self._name = 'default-physical-interface'2013 else:2014 self._name = physical_interface_name2015 self._obj = None2016 self._parent_fixt = parent_fixt2017 self._auto_prop_val = auto_prop_val2018 self.id_perms = id_perms2019 self.display_name = display_name2020 #end __init__2021 def _update_links (self, update_server):2022 return None2023 #end _update_links2024 def populate (self):2025 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2026 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2027 #end populate2028 def setUp(self):2029 super(PhysicalInterfaceTestFixtureGen, self).setUp()2030 if not self._parent_fixt:2031 self._parent_fixt = self.useFixture(PhysicalRouterTestFixtureGen(self._conn_drv, 'default-physical-router'))2032 self._obj = vnc_api.PhysicalInterface(self._name, self._parent_fixt.getObj ())2033 try:2034 self._obj = self._conn_drv.physical_interface_read (fq_name=self._obj.get_fq_name())2035 self._update_links (update_server=True)2036 except NoIdError:2037 self._update_links (update_server=False)2038 if self._auto_prop_val:2039 self.populate ()2040 else:2041 self._obj.id_perms = self.id_perms2042 self._obj.display_name = self.display_name2043 self._conn_drv.physical_interface_create(self._obj)2044 # read back for server allocated values2045 self._obj = self._conn_drv.physical_interface_read(id = self._obj.uuid)2046 #end setUp2047 def cleanUp(self):2048 if self._obj.get_logical_interfaces():2049 return2050 parent_fixt = getattr(self, '_parent_fixt', None)2051 if parent_fixt:2052 # non config-root child2053 parent_obj = self._parent_fixt.getObj()2054 # remove child from parent obj2055 for child_obj in parent_obj.get_physical_interfaces():2056 if type(child_obj) == dict:2057 child_uuid = child_obj['uuid']2058 else:2059 child_uuid = child_obj.uuid2060 if child_uuid == self._obj.uuid:2061 parent_obj.physical_interfaces.remove(child_obj)2062 break2063 self._conn_drv.physical_interface_delete(id = self._obj.uuid)2064 #end cleanUp2065 def getObj(self):2066 return self._obj2067 #end getObj2068#end class PhysicalInterfaceTestFixtureGen2069class AccessControlListTestFixtureGen(cfixture.ContrailFixture):2070 """2071 Fixture for :class:`.AccessControlList`2072 """2073 def __init__(self, conn_drv, access_control_list_name=None, parent_fixt=None, auto_prop_val=False, access_control_list_entries=None, id_perms=None, display_name=None):2074 '''2075 Create AccessControlListTestFixtureGen object2076 2077 constructor2078 Args:2079 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2080 Kwargs:2081 access_control_list_name (str): Name of access_control_list2082 parent_fixt (:class:`.VirtualNetworkTestFixtureGen`): Parent fixture2083 access_control_list_entries (instance): instance of :class:`AclEntriesType`2084 id_perms (instance): instance of :class:`IdPermsType`2085 display_name (instance): instance of :class:`xsd:string`2086 '''2087 super(AccessControlListTestFixtureGen, self).__init__()2088 self._conn_drv = conn_drv2089 if not access_control_list_name:2090 self._name = 'default-access-control-list'2091 else:2092 self._name = access_control_list_name2093 self._obj = None2094 self._parent_fixt = parent_fixt2095 self._auto_prop_val = auto_prop_val2096 self.access_control_list_entries = access_control_list_entries2097 self.id_perms = id_perms2098 self.display_name = display_name2099 #end __init__2100 def _update_links (self, update_server):2101 return None2102 #end _update_links2103 def populate (self):2104 self._obj.set_access_control_list_entries(self.access_control_list_entries or vnc_api.gen.resource_xsd.AclEntriesType.populate())2105 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2106 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2107 #end populate2108 def setUp(self):2109 super(AccessControlListTestFixtureGen, self).setUp()2110 if not self._parent_fixt:2111 raise AmbiguousParentError("[[u'default-domain', u'default-project', u'default-virtual-network'], [u'default-domain', u'default-project', u'default-security-group']]")2112 self._obj = vnc_api.AccessControlList(self._name, self._parent_fixt.getObj ())2113 try:2114 self._obj = self._conn_drv.access_control_list_read (fq_name=self._obj.get_fq_name())2115 self._update_links (update_server=True)2116 except NoIdError:2117 self._update_links (update_server=False)2118 if self._auto_prop_val:2119 self.populate ()2120 else:2121 self._obj.access_control_list_entries = self.access_control_list_entries2122 self._obj.id_perms = self.id_perms2123 self._obj.display_name = self.display_name2124 self._conn_drv.access_control_list_create(self._obj)2125 # read back for server allocated values2126 self._obj = self._conn_drv.access_control_list_read(id = self._obj.uuid)2127 #end setUp2128 def cleanUp(self):2129 parent_fixt = getattr(self, '_parent_fixt', None)2130 if parent_fixt:2131 # non config-root child2132 parent_obj = self._parent_fixt.getObj()2133 # remove child from parent obj2134 for child_obj in parent_obj.get_access_control_lists():2135 if type(child_obj) == dict:2136 child_uuid = child_obj['uuid']2137 else:2138 child_uuid = child_obj.uuid2139 if child_uuid == self._obj.uuid:2140 parent_obj.access_control_lists.remove(child_obj)2141 break2142 self._conn_drv.access_control_list_delete(id = self._obj.uuid)2143 #end cleanUp2144 def getObj(self):2145 return self._obj2146 #end getObj2147#end class AccessControlListTestFixtureGen2148class AnalyticsNodeTestFixtureGen(cfixture.ContrailFixture):2149 """2150 Fixture for :class:`.AnalyticsNode`2151 """2152 def __init__(self, conn_drv, analytics_node_name=None, parent_fixt=None, auto_prop_val=False, analytics_node_ip_address=None, id_perms=None, display_name=None):2153 '''2154 Create AnalyticsNodeTestFixtureGen object2155 2156 constructor2157 Args:2158 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2159 Kwargs:2160 analytics_node_name (str): Name of analytics_node2161 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture2162 analytics_node_ip_address (instance): instance of :class:`xsd:string`2163 id_perms (instance): instance of :class:`IdPermsType`2164 display_name (instance): instance of :class:`xsd:string`2165 '''2166 super(AnalyticsNodeTestFixtureGen, self).__init__()2167 self._conn_drv = conn_drv2168 if not analytics_node_name:2169 self._name = 'default-analytics-node'2170 else:2171 self._name = analytics_node_name2172 self._obj = None2173 self._parent_fixt = parent_fixt2174 self._auto_prop_val = auto_prop_val2175 self.analytics_node_ip_address = analytics_node_ip_address2176 self.id_perms = id_perms2177 self.display_name = display_name2178 #end __init__2179 def _update_links (self, update_server):2180 return None2181 #end _update_links2182 def populate (self):2183 self._obj.set_analytics_node_ip_address(self.analytics_node_ip_address or GeneratedsSuper.populate_string("analytics_node_ip_address"))2184 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2185 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2186 #end populate2187 def setUp(self):2188 super(AnalyticsNodeTestFixtureGen, self).setUp()2189 if not self._parent_fixt:2190 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))2191 self._obj = vnc_api.AnalyticsNode(self._name, self._parent_fixt.getObj ())2192 try:2193 self._obj = self._conn_drv.analytics_node_read (fq_name=self._obj.get_fq_name())2194 self._update_links (update_server=True)2195 except NoIdError:2196 self._update_links (update_server=False)2197 if self._auto_prop_val:2198 self.populate ()2199 else:2200 self._obj.analytics_node_ip_address = self.analytics_node_ip_address2201 self._obj.id_perms = self.id_perms2202 self._obj.display_name = self.display_name2203 self._conn_drv.analytics_node_create(self._obj)2204 # read back for server allocated values2205 self._obj = self._conn_drv.analytics_node_read(id = self._obj.uuid)2206 #end setUp2207 def cleanUp(self):2208 parent_fixt = getattr(self, '_parent_fixt', None)2209 if parent_fixt:2210 # non config-root child2211 parent_obj = self._parent_fixt.getObj()2212 # remove child from parent obj2213 for child_obj in parent_obj.get_analytics_nodes():2214 if type(child_obj) == dict:2215 child_uuid = child_obj['uuid']2216 else:2217 child_uuid = child_obj.uuid2218 if child_uuid == self._obj.uuid:2219 parent_obj.analytics_nodes.remove(child_obj)2220 break2221 self._conn_drv.analytics_node_delete(id = self._obj.uuid)2222 #end cleanUp2223 def getObj(self):2224 return self._obj2225 #end getObj2226#end class AnalyticsNodeTestFixtureGen2227class VirtualDnsTestFixtureGen(cfixture.ContrailFixture):2228 """2229 Fixture for :class:`.VirtualDns`2230 """2231 def __init__(self, conn_drv, virtual_DNS_name=None, parent_fixt=None, auto_prop_val=False, virtual_DNS_data=None, id_perms=None, display_name=None):2232 '''2233 Create VirtualDnsTestFixtureGen object2234 2235 constructor2236 Args:2237 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2238 Kwargs:2239 virtual_DNS_name (str): Name of virtual_DNS2240 parent_fixt (:class:`.DomainTestFixtureGen`): Parent fixture2241 virtual_DNS_data (instance): instance of :class:`VirtualDnsType`2242 id_perms (instance): instance of :class:`IdPermsType`2243 display_name (instance): instance of :class:`xsd:string`2244 '''2245 super(VirtualDnsTestFixtureGen, self).__init__()2246 self._conn_drv = conn_drv2247 if not virtual_DNS_name:2248 self._name = 'default-virtual-DNS'2249 else:2250 self._name = virtual_DNS_name2251 self._obj = None2252 self._parent_fixt = parent_fixt2253 self._auto_prop_val = auto_prop_val2254 self.virtual_DNS_data = virtual_DNS_data2255 self.id_perms = id_perms2256 self.display_name = display_name2257 #end __init__2258 def _update_links (self, update_server):2259 return None2260 #end _update_links2261 def populate (self):2262 self._obj.set_virtual_DNS_data(self.virtual_DNS_data or vnc_api.gen.resource_xsd.VirtualDnsType.populate())2263 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2264 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2265 #end populate2266 def setUp(self):2267 super(VirtualDnsTestFixtureGen, self).setUp()2268 if not self._parent_fixt:2269 self._parent_fixt = self.useFixture(DomainTestFixtureGen(self._conn_drv, 'default-domain'))2270 self._obj = vnc_api.VirtualDns(self._name, self._parent_fixt.getObj ())2271 try:2272 self._obj = self._conn_drv.virtual_DNS_read (fq_name=self._obj.get_fq_name())2273 self._update_links (update_server=True)2274 except NoIdError:2275 self._update_links (update_server=False)2276 if self._auto_prop_val:2277 self.populate ()2278 else:2279 self._obj.virtual_DNS_data = self.virtual_DNS_data2280 self._obj.id_perms = self.id_perms2281 self._obj.display_name = self.display_name2282 self._conn_drv.virtual_DNS_create(self._obj)2283 # read back for server allocated values2284 self._obj = self._conn_drv.virtual_DNS_read(id = self._obj.uuid)2285 #end setUp2286 def cleanUp(self):2287 if self._obj.get_network_ipam_back_refs():2288 return2289 if self._obj.get_virtual_DNS_records():2290 return2291 parent_fixt = getattr(self, '_parent_fixt', None)2292 if parent_fixt:2293 # non config-root child2294 parent_obj = self._parent_fixt.getObj()2295 # remove child from parent obj2296 for child_obj in parent_obj.get_virtual_DNSs():2297 if type(child_obj) == dict:2298 child_uuid = child_obj['uuid']2299 else:2300 child_uuid = child_obj.uuid2301 if child_uuid == self._obj.uuid:2302 parent_obj.virtual_DNSs.remove(child_obj)2303 break2304 self._conn_drv.virtual_DNS_delete(id = self._obj.uuid)2305 #end cleanUp2306 def getObj(self):2307 return self._obj2308 #end getObj2309#end class VirtualDnsTestFixtureGen2310class CustomerAttachmentTestFixtureGen(cfixture.ContrailFixture):2311 """2312 Fixture for :class:`.CustomerAttachment`2313 """2314 def __init__(self, conn_drv, customer_attachment_name=None, auto_prop_val=False, virtual_machine_interface_refs = None, floating_ip_refs = None, attachment_address=None, id_perms=None, display_name=None):2315 '''2316 Create CustomerAttachmentTestFixtureGen object2317 2318 constructor2319 Args:2320 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2321 Kwargs:2322 %s_name (str): Name of %s2323 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type2324 floating_ip (list): list of :class:`FloatingIp` type2325 attachment_address (instance): instance of :class:`AttachmentAddressType`2326 id_perms (instance): instance of :class:`IdPermsType`2327 display_name (instance): instance of :class:`xsd:string`2328 '''2329 super(CustomerAttachmentTestFixtureGen, self).__init__()2330 self._conn_drv = conn_drv2331 if not customer_attachment_name:2332 self._name = 'default-customer-attachment'2333 else:2334 self._name = customer_attachment_name2335 self._obj = None2336 self._auto_prop_val = auto_prop_val2337 if virtual_machine_interface_refs:2338 for ln in virtual_machine_interface_refs:2339 self.add_virtual_machine_interface (ln)2340 if floating_ip_refs:2341 for ln in floating_ip_refs:2342 self.add_floating_ip (ln)2343 self.attachment_address = attachment_address2344 self.id_perms = id_perms2345 self.display_name = display_name2346 #end __init__2347 def _update_links (self, update_server):2348 for ln in self.get_virtual_machine_interfaces ():2349 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)2350 for ln in self.get_floating_ips ():2351 self.add_floating_ip (ln.fixture (), update_server = update_server, add_link = False)2352 return None2353 #end _update_links2354 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):2355 '''2356 add :class:`VirtualMachineInterface` link to :class:`CustomerAttachment`2357 Args:2358 lo (:class:`VirtualMachineInterface`): obj to link2359 '''2360 if self._obj:2361 self._obj.add_virtual_machine_interface (lo)2362 if update_server:2363 self._conn_drv.customer_attachment_update (self._obj)2364 if add_link:2365 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'customer_attachment', 'virtual_machine_interface', ['ref'], lo))2366 #end add_virtual_machine_interface_link2367 def get_virtual_machine_interfaces (self):2368 return self.get_links ('virtual_machine_interface')2369 #end get_virtual_machine_interfaces2370 def add_floating_ip (self, lo, update_server = True, add_link = True):2371 '''2372 add :class:`FloatingIp` link to :class:`CustomerAttachment`2373 Args:2374 lo (:class:`FloatingIp`): obj to link2375 '''2376 if self._obj:2377 self._obj.add_floating_ip (lo)2378 if update_server:2379 self._conn_drv.customer_attachment_update (self._obj)2380 if add_link:2381 self.add_link('floating_ip', cfixture.ConrtailLink('floating_ip', 'customer_attachment', 'floating_ip', ['ref'], lo))2382 #end add_floating_ip_link2383 def get_floating_ips (self):2384 return self.get_links ('floating_ip')2385 #end get_floating_ips2386 def populate (self):2387 self._obj.set_attachment_address(self.attachment_address or vnc_api.gen.resource_xsd.AttachmentAddressType.populate())2388 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2389 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2390 #end populate2391 def setUp(self):2392 super(CustomerAttachmentTestFixtureGen, self).setUp()2393 self._obj = vnc_api.CustomerAttachment(self._name)2394 try:2395 self._obj = self._conn_drv.customer_attachment_read (fq_name=self._obj.get_fq_name())2396 self._update_links (update_server=True)2397 except NoIdError:2398 self._update_links (update_server=False)2399 if self._auto_prop_val:2400 self.populate ()2401 else:2402 self._obj.attachment_address = self.attachment_address2403 self._obj.id_perms = self.id_perms2404 self._obj.display_name = self.display_name2405 self._conn_drv.customer_attachment_create(self._obj)2406 # read back for server allocated values2407 self._obj = self._conn_drv.customer_attachment_read(id = self._obj.uuid)2408 #end setUp2409 def cleanUp(self):2410 self._conn_drv.customer_attachment_delete(id = self._obj.uuid)2411 #end cleanUp2412 def getObj(self):2413 return self._obj2414 #end getObj2415#end class CustomerAttachmentTestFixtureGen2416class ServiceApplianceSetTestFixtureGen(cfixture.ContrailFixture):2417 """2418 Fixture for :class:`.ServiceApplianceSet`2419 """2420 def __init__(self, conn_drv, service_appliance_set_name=None, parent_fixt=None, auto_prop_val=False, service_appliance_set_properties=None, service_appliance_driver=None, service_appliance_ha_mode=None, id_perms=None, display_name=None):2421 '''2422 Create ServiceApplianceSetTestFixtureGen object2423 2424 constructor2425 Args:2426 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2427 Kwargs:2428 service_appliance_set_name (str): Name of service_appliance_set2429 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture2430 service_appliance_set_properties (instance): instance of :class:`KeyValuePairs`2431 service_appliance_driver (instance): instance of :class:`xsd:string`2432 service_appliance_ha_mode (instance): instance of :class:`xsd:string`2433 id_perms (instance): instance of :class:`IdPermsType`2434 display_name (instance): instance of :class:`xsd:string`2435 '''2436 super(ServiceApplianceSetTestFixtureGen, self).__init__()2437 self._conn_drv = conn_drv2438 if not service_appliance_set_name:2439 self._name = 'default-service-appliance-set'2440 else:2441 self._name = service_appliance_set_name2442 self._obj = None2443 self._parent_fixt = parent_fixt2444 self._auto_prop_val = auto_prop_val2445 self.service_appliance_set_properties = service_appliance_set_properties2446 self.service_appliance_driver = service_appliance_driver2447 self.service_appliance_ha_mode = service_appliance_ha_mode2448 self.id_perms = id_perms2449 self.display_name = display_name2450 #end __init__2451 def _update_links (self, update_server):2452 return None2453 #end _update_links2454 def populate (self):2455 self._obj.set_service_appliance_set_properties(self.service_appliance_set_properties or vnc_api.gen.resource_xsd.KeyValuePairs.populate())2456 self._obj.set_service_appliance_driver(self.service_appliance_driver or GeneratedsSuper.populate_string("service_appliance_driver"))2457 self._obj.set_service_appliance_ha_mode(self.service_appliance_ha_mode or GeneratedsSuper.populate_string("service_appliance_ha_mode"))2458 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2459 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2460 #end populate2461 def setUp(self):2462 super(ServiceApplianceSetTestFixtureGen, self).setUp()2463 if not self._parent_fixt:2464 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))2465 self._obj = vnc_api.ServiceApplianceSet(self._name, self._parent_fixt.getObj ())2466 try:2467 self._obj = self._conn_drv.service_appliance_set_read (fq_name=self._obj.get_fq_name())2468 self._update_links (update_server=True)2469 except NoIdError:2470 self._update_links (update_server=False)2471 if self._auto_prop_val:2472 self.populate ()2473 else:2474 self._obj.service_appliance_set_properties = self.service_appliance_set_properties2475 self._obj.service_appliance_driver = self.service_appliance_driver2476 self._obj.service_appliance_ha_mode = self.service_appliance_ha_mode2477 self._obj.id_perms = self.id_perms2478 self._obj.display_name = self.display_name2479 self._conn_drv.service_appliance_set_create(self._obj)2480 # read back for server allocated values2481 self._obj = self._conn_drv.service_appliance_set_read(id = self._obj.uuid)2482 #end setUp2483 def cleanUp(self):2484 if self._obj.get_loadbalancer_pool_back_refs():2485 return2486 if self._obj.get_service_appliances():2487 return2488 parent_fixt = getattr(self, '_parent_fixt', None)2489 if parent_fixt:2490 # non config-root child2491 parent_obj = self._parent_fixt.getObj()2492 # remove child from parent obj2493 for child_obj in parent_obj.get_service_appliance_sets():2494 if type(child_obj) == dict:2495 child_uuid = child_obj['uuid']2496 else:2497 child_uuid = child_obj.uuid2498 if child_uuid == self._obj.uuid:2499 parent_obj.service_appliance_sets.remove(child_obj)2500 break2501 self._conn_drv.service_appliance_set_delete(id = self._obj.uuid)2502 #end cleanUp2503 def getObj(self):2504 return self._obj2505 #end getObj2506#end class ServiceApplianceSetTestFixtureGen2507class ConfigNodeTestFixtureGen(cfixture.ContrailFixture):2508 """2509 Fixture for :class:`.ConfigNode`2510 """2511 def __init__(self, conn_drv, config_node_name=None, parent_fixt=None, auto_prop_val=False, config_node_ip_address=None, id_perms=None, display_name=None):2512 '''2513 Create ConfigNodeTestFixtureGen object2514 2515 constructor2516 Args:2517 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2518 Kwargs:2519 config_node_name (str): Name of config_node2520 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture2521 config_node_ip_address (instance): instance of :class:`xsd:string`2522 id_perms (instance): instance of :class:`IdPermsType`2523 display_name (instance): instance of :class:`xsd:string`2524 '''2525 super(ConfigNodeTestFixtureGen, self).__init__()2526 self._conn_drv = conn_drv2527 if not config_node_name:2528 self._name = 'default-config-node'2529 else:2530 self._name = config_node_name2531 self._obj = None2532 self._parent_fixt = parent_fixt2533 self._auto_prop_val = auto_prop_val2534 self.config_node_ip_address = config_node_ip_address2535 self.id_perms = id_perms2536 self.display_name = display_name2537 #end __init__2538 def _update_links (self, update_server):2539 return None2540 #end _update_links2541 def populate (self):2542 self._obj.set_config_node_ip_address(self.config_node_ip_address or GeneratedsSuper.populate_string("config_node_ip_address"))2543 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2544 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2545 #end populate2546 def setUp(self):2547 super(ConfigNodeTestFixtureGen, self).setUp()2548 if not self._parent_fixt:2549 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))2550 self._obj = vnc_api.ConfigNode(self._name, self._parent_fixt.getObj ())2551 try:2552 self._obj = self._conn_drv.config_node_read (fq_name=self._obj.get_fq_name())2553 self._update_links (update_server=True)2554 except NoIdError:2555 self._update_links (update_server=False)2556 if self._auto_prop_val:2557 self.populate ()2558 else:2559 self._obj.config_node_ip_address = self.config_node_ip_address2560 self._obj.id_perms = self.id_perms2561 self._obj.display_name = self.display_name2562 self._conn_drv.config_node_create(self._obj)2563 # read back for server allocated values2564 self._obj = self._conn_drv.config_node_read(id = self._obj.uuid)2565 #end setUp2566 def cleanUp(self):2567 parent_fixt = getattr(self, '_parent_fixt', None)2568 if parent_fixt:2569 # non config-root child2570 parent_obj = self._parent_fixt.getObj()2571 # remove child from parent obj2572 for child_obj in parent_obj.get_config_nodes():2573 if type(child_obj) == dict:2574 child_uuid = child_obj['uuid']2575 else:2576 child_uuid = child_obj.uuid2577 if child_uuid == self._obj.uuid:2578 parent_obj.config_nodes.remove(child_obj)2579 break2580 self._conn_drv.config_node_delete(id = self._obj.uuid)2581 #end cleanUp2582 def getObj(self):2583 return self._obj2584 #end getObj2585#end class ConfigNodeTestFixtureGen2586class QosQueueTestFixtureGen(cfixture.ContrailFixture):2587 """2588 Fixture for :class:`.QosQueue`2589 """2590 def __init__(self, conn_drv, qos_queue_name=None, parent_fixt=None, auto_prop_val=False, min_bandwidth=None, max_bandwidth=None, id_perms=None, display_name=None):2591 '''2592 Create QosQueueTestFixtureGen object2593 2594 constructor2595 Args:2596 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2597 Kwargs:2598 qos_queue_name (str): Name of qos_queue2599 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture2600 min_bandwidth (instance): instance of :class:`xsd:integer`2601 max_bandwidth (instance): instance of :class:`xsd:integer`2602 id_perms (instance): instance of :class:`IdPermsType`2603 display_name (instance): instance of :class:`xsd:string`2604 '''2605 super(QosQueueTestFixtureGen, self).__init__()2606 self._conn_drv = conn_drv2607 if not qos_queue_name:2608 self._name = 'default-qos-queue'2609 else:2610 self._name = qos_queue_name2611 self._obj = None2612 self._parent_fixt = parent_fixt2613 self._auto_prop_val = auto_prop_val2614 self.min_bandwidth = min_bandwidth2615 self.max_bandwidth = max_bandwidth2616 self.id_perms = id_perms2617 self.display_name = display_name2618 #end __init__2619 def _update_links (self, update_server):2620 return None2621 #end _update_links2622 def populate (self):2623 self._obj.set_min_bandwidth(self.min_bandwidth or GeneratedsSuper.populate_integer("min_bandwidth"))2624 self._obj.set_max_bandwidth(self.max_bandwidth or GeneratedsSuper.populate_integer("max_bandwidth"))2625 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2626 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2627 #end populate2628 def setUp(self):2629 super(QosQueueTestFixtureGen, self).setUp()2630 if not self._parent_fixt:2631 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))2632 self._obj = vnc_api.QosQueue(self._name, self._parent_fixt.getObj ())2633 try:2634 self._obj = self._conn_drv.qos_queue_read (fq_name=self._obj.get_fq_name())2635 self._update_links (update_server=True)2636 except NoIdError:2637 self._update_links (update_server=False)2638 if self._auto_prop_val:2639 self.populate ()2640 else:2641 self._obj.min_bandwidth = self.min_bandwidth2642 self._obj.max_bandwidth = self.max_bandwidth2643 self._obj.id_perms = self.id_perms2644 self._obj.display_name = self.display_name2645 self._conn_drv.qos_queue_create(self._obj)2646 # read back for server allocated values2647 self._obj = self._conn_drv.qos_queue_read(id = self._obj.uuid)2648 #end setUp2649 def cleanUp(self):2650 if self._obj.get_qos_forwarding_class_back_refs():2651 return2652 parent_fixt = getattr(self, '_parent_fixt', None)2653 if parent_fixt:2654 # non config-root child2655 parent_obj = self._parent_fixt.getObj()2656 # remove child from parent obj2657 for child_obj in parent_obj.get_qos_queues():2658 if type(child_obj) == dict:2659 child_uuid = child_obj['uuid']2660 else:2661 child_uuid = child_obj.uuid2662 if child_uuid == self._obj.uuid:2663 parent_obj.qos_queues.remove(child_obj)2664 break2665 self._conn_drv.qos_queue_delete(id = self._obj.uuid)2666 #end cleanUp2667 def getObj(self):2668 return self._obj2669 #end getObj2670#end class QosQueueTestFixtureGen2671class VirtualMachineTestFixtureGen(cfixture.ContrailFixture):2672 """2673 Fixture for :class:`.VirtualMachine`2674 """2675 def __init__(self, conn_drv, virtual_machine_name=None, auto_prop_val=False, service_instance_refs = None, id_perms=None, display_name=None):2676 '''2677 Create VirtualMachineTestFixtureGen object2678 2679 constructor2680 Args:2681 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2682 Kwargs:2683 %s_name (str): Name of %s2684 service_instance (list): list of :class:`ServiceInstance` type2685 id_perms (instance): instance of :class:`IdPermsType`2686 display_name (instance): instance of :class:`xsd:string`2687 '''2688 super(VirtualMachineTestFixtureGen, self).__init__()2689 self._conn_drv = conn_drv2690 if not virtual_machine_name:2691 self._name = 'default-virtual-machine'2692 else:2693 self._name = virtual_machine_name2694 self._obj = None2695 self._auto_prop_val = auto_prop_val2696 if service_instance_refs:2697 for ln in service_instance_refs:2698 self.add_service_instance (ln)2699 self.id_perms = id_perms2700 self.display_name = display_name2701 #end __init__2702 def _update_links (self, update_server):2703 for ln in self.get_service_instances ():2704 self.add_service_instance (ln.fixture (), update_server = update_server, add_link = False)2705 return None2706 #end _update_links2707 def add_service_instance (self, lo, update_server = True, add_link = True):2708 '''2709 add :class:`ServiceInstance` link to :class:`VirtualMachine`2710 Args:2711 lo (:class:`ServiceInstance`): obj to link2712 '''2713 if self._obj:2714 self._obj.add_service_instance (lo)2715 if update_server:2716 self._conn_drv.virtual_machine_update (self._obj)2717 if add_link:2718 self.add_link('service_instance', cfixture.ConrtailLink('service_instance', 'virtual_machine', 'service_instance', ['ref', 'derived'], lo))2719 #end add_service_instance_link2720 def get_service_instances (self):2721 return self.get_links ('service_instance')2722 #end get_service_instances2723 def populate (self):2724 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2725 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2726 #end populate2727 def setUp(self):2728 super(VirtualMachineTestFixtureGen, self).setUp()2729 self._obj = vnc_api.VirtualMachine(self._name)2730 try:2731 self._obj = self._conn_drv.virtual_machine_read (fq_name=self._obj.get_fq_name())2732 self._update_links (update_server=True)2733 except NoIdError:2734 self._update_links (update_server=False)2735 if self._auto_prop_val:2736 self.populate ()2737 else:2738 self._obj.id_perms = self.id_perms2739 self._obj.display_name = self.display_name2740 self._conn_drv.virtual_machine_create(self._obj)2741 # read back for server allocated values2742 self._obj = self._conn_drv.virtual_machine_read(id = self._obj.uuid)2743 #end setUp2744 def cleanUp(self):2745 if self._obj.get_virtual_machine_interface_back_refs() or self._obj.get_virtual_router_back_refs():2746 return2747 if self._obj.get_virtual_machine_interfaces():2748 return2749 self._conn_drv.virtual_machine_delete(id = self._obj.uuid)2750 #end cleanUp2751 def getObj(self):2752 return self._obj2753 #end getObj2754#end class VirtualMachineTestFixtureGen2755class InterfaceRouteTableTestFixtureGen(cfixture.ContrailFixture):2756 """2757 Fixture for :class:`.InterfaceRouteTable`2758 """2759 def __init__(self, conn_drv, interface_route_table_name=None, parent_fixt=None, auto_prop_val=False, interface_route_table_routes=None, id_perms=None, display_name=None):2760 '''2761 Create InterfaceRouteTableTestFixtureGen object2762 2763 constructor2764 Args:2765 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2766 Kwargs:2767 interface_route_table_name (str): Name of interface_route_table2768 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture2769 interface_route_table_routes (instance): instance of :class:`RouteTableType`2770 id_perms (instance): instance of :class:`IdPermsType`2771 display_name (instance): instance of :class:`xsd:string`2772 '''2773 super(InterfaceRouteTableTestFixtureGen, self).__init__()2774 self._conn_drv = conn_drv2775 if not interface_route_table_name:2776 self._name = 'default-interface-route-table'2777 else:2778 self._name = interface_route_table_name2779 self._obj = None2780 self._parent_fixt = parent_fixt2781 self._auto_prop_val = auto_prop_val2782 self.interface_route_table_routes = interface_route_table_routes2783 self.id_perms = id_perms2784 self.display_name = display_name2785 #end __init__2786 def _update_links (self, update_server):2787 return None2788 #end _update_links2789 def populate (self):2790 self._obj.set_interface_route_table_routes(self.interface_route_table_routes or vnc_api.gen.resource_xsd.RouteTableType.populate())2791 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2792 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2793 #end populate2794 def setUp(self):2795 super(InterfaceRouteTableTestFixtureGen, self).setUp()2796 if not self._parent_fixt:2797 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))2798 self._obj = vnc_api.InterfaceRouteTable(self._name, self._parent_fixt.getObj ())2799 try:2800 self._obj = self._conn_drv.interface_route_table_read (fq_name=self._obj.get_fq_name())2801 self._update_links (update_server=True)2802 except NoIdError:2803 self._update_links (update_server=False)2804 if self._auto_prop_val:2805 self.populate ()2806 else:2807 self._obj.interface_route_table_routes = self.interface_route_table_routes2808 self._obj.id_perms = self.id_perms2809 self._obj.display_name = self.display_name2810 self._conn_drv.interface_route_table_create(self._obj)2811 # read back for server allocated values2812 self._obj = self._conn_drv.interface_route_table_read(id = self._obj.uuid)2813 #end setUp2814 def cleanUp(self):2815 if self._obj.get_virtual_machine_interface_back_refs():2816 return2817 parent_fixt = getattr(self, '_parent_fixt', None)2818 if parent_fixt:2819 # non config-root child2820 parent_obj = self._parent_fixt.getObj()2821 # remove child from parent obj2822 for child_obj in parent_obj.get_interface_route_tables():2823 if type(child_obj) == dict:2824 child_uuid = child_obj['uuid']2825 else:2826 child_uuid = child_obj.uuid2827 if child_uuid == self._obj.uuid:2828 parent_obj.interface_route_tables.remove(child_obj)2829 break2830 self._conn_drv.interface_route_table_delete(id = self._obj.uuid)2831 #end cleanUp2832 def getObj(self):2833 return self._obj2834 #end getObj2835#end class InterfaceRouteTableTestFixtureGen2836class ServiceTemplateTestFixtureGen(cfixture.ContrailFixture):2837 """2838 Fixture for :class:`.ServiceTemplate`2839 """2840 def __init__(self, conn_drv, service_template_name=None, parent_fixt=None, auto_prop_val=False, service_template_properties=None, id_perms=None, display_name=None):2841 '''2842 Create ServiceTemplateTestFixtureGen object2843 2844 constructor2845 Args:2846 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2847 Kwargs:2848 service_template_name (str): Name of service_template2849 parent_fixt (:class:`.DomainTestFixtureGen`): Parent fixture2850 service_template_properties (instance): instance of :class:`ServiceTemplateType`2851 id_perms (instance): instance of :class:`IdPermsType`2852 display_name (instance): instance of :class:`xsd:string`2853 '''2854 super(ServiceTemplateTestFixtureGen, self).__init__()2855 self._conn_drv = conn_drv2856 if not service_template_name:2857 self._name = 'default-service-template'2858 else:2859 self._name = service_template_name2860 self._obj = None2861 self._parent_fixt = parent_fixt2862 self._auto_prop_val = auto_prop_val2863 self.service_template_properties = service_template_properties2864 self.id_perms = id_perms2865 self.display_name = display_name2866 #end __init__2867 def _update_links (self, update_server):2868 return None2869 #end _update_links2870 def populate (self):2871 self._obj.set_service_template_properties(self.service_template_properties or vnc_api.gen.resource_xsd.ServiceTemplateType.populate())2872 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2873 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2874 #end populate2875 def setUp(self):2876 super(ServiceTemplateTestFixtureGen, self).setUp()2877 if not self._parent_fixt:2878 self._parent_fixt = self.useFixture(DomainTestFixtureGen(self._conn_drv, 'default-domain'))2879 self._obj = vnc_api.ServiceTemplate(self._name, self._parent_fixt.getObj ())2880 try:2881 self._obj = self._conn_drv.service_template_read (fq_name=self._obj.get_fq_name())2882 self._update_links (update_server=True)2883 except NoIdError:2884 self._update_links (update_server=False)2885 if self._auto_prop_val:2886 self.populate ()2887 else:2888 self._obj.service_template_properties = self.service_template_properties2889 self._obj.id_perms = self.id_perms2890 self._obj.display_name = self.display_name2891 self._conn_drv.service_template_create(self._obj)2892 # read back for server allocated values2893 self._obj = self._conn_drv.service_template_read(id = self._obj.uuid)2894 #end setUp2895 def cleanUp(self):2896 if self._obj.get_service_instance_back_refs():2897 return2898 parent_fixt = getattr(self, '_parent_fixt', None)2899 if parent_fixt:2900 # non config-root child2901 parent_obj = self._parent_fixt.getObj()2902 # remove child from parent obj2903 for child_obj in parent_obj.get_service_templates():2904 if type(child_obj) == dict:2905 child_uuid = child_obj['uuid']2906 else:2907 child_uuid = child_obj.uuid2908 if child_uuid == self._obj.uuid:2909 parent_obj.service_templates.remove(child_obj)2910 break2911 self._conn_drv.service_template_delete(id = self._obj.uuid)2912 #end cleanUp2913 def getObj(self):2914 return self._obj2915 #end getObj2916#end class ServiceTemplateTestFixtureGen2917class VirtualIpTestFixtureGen(cfixture.ContrailFixture):2918 """2919 Fixture for :class:`.VirtualIp`2920 """2921 def __init__(self, conn_drv, virtual_ip_name=None, parent_fixt=None, auto_prop_val=False, loadbalancer_pool_refs = None, virtual_machine_interface_refs = None, virtual_ip_properties=None, id_perms=None, display_name=None):2922 '''2923 Create VirtualIpTestFixtureGen object2924 2925 constructor2926 Args:2927 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)2928 Kwargs:2929 virtual_ip_name (str): Name of virtual_ip2930 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture2931 loadbalancer_pool (list): list of :class:`LoadbalancerPool` type2932 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type2933 virtual_ip_properties (instance): instance of :class:`VirtualIpType`2934 id_perms (instance): instance of :class:`IdPermsType`2935 display_name (instance): instance of :class:`xsd:string`2936 '''2937 super(VirtualIpTestFixtureGen, self).__init__()2938 self._conn_drv = conn_drv2939 if not virtual_ip_name:2940 self._name = 'default-virtual-ip'2941 else:2942 self._name = virtual_ip_name2943 self._obj = None2944 self._parent_fixt = parent_fixt2945 self._auto_prop_val = auto_prop_val2946 if loadbalancer_pool_refs:2947 for ln in loadbalancer_pool_refs:2948 self.add_loadbalancer_pool (ln)2949 if virtual_machine_interface_refs:2950 for ln in virtual_machine_interface_refs:2951 self.add_virtual_machine_interface (ln)2952 self.virtual_ip_properties = virtual_ip_properties2953 self.id_perms = id_perms2954 self.display_name = display_name2955 #end __init__2956 def _update_links (self, update_server):2957 for ln in self.get_loadbalancer_pools ():2958 self.add_loadbalancer_pool (ln.fixture (), update_server = update_server, add_link = False)2959 for ln in self.get_virtual_machine_interfaces ():2960 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)2961 return None2962 #end _update_links2963 def add_loadbalancer_pool (self, lo, update_server = True, add_link = True):2964 '''2965 add :class:`LoadbalancerPool` link to :class:`VirtualIp`2966 Args:2967 lo (:class:`LoadbalancerPool`): obj to link2968 '''2969 if self._obj:2970 self._obj.add_loadbalancer_pool (lo)2971 if update_server:2972 self._conn_drv.virtual_ip_update (self._obj)2973 if add_link:2974 self.add_link('loadbalancer_pool', cfixture.ConrtailLink('loadbalancer_pool', 'virtual_ip', 'loadbalancer_pool', ['ref'], lo))2975 #end add_loadbalancer_pool_link2976 def get_loadbalancer_pools (self):2977 return self.get_links ('loadbalancer_pool')2978 #end get_loadbalancer_pools2979 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):2980 '''2981 add :class:`VirtualMachineInterface` link to :class:`VirtualIp`2982 Args:2983 lo (:class:`VirtualMachineInterface`): obj to link2984 '''2985 if self._obj:2986 self._obj.add_virtual_machine_interface (lo)2987 if update_server:2988 self._conn_drv.virtual_ip_update (self._obj)2989 if add_link:2990 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'virtual_ip', 'virtual_machine_interface', ['ref'], lo))2991 #end add_virtual_machine_interface_link2992 def get_virtual_machine_interfaces (self):2993 return self.get_links ('virtual_machine_interface')2994 #end get_virtual_machine_interfaces2995 def populate (self):2996 self._obj.set_virtual_ip_properties(self.virtual_ip_properties or vnc_api.gen.resource_xsd.VirtualIpType.populate())2997 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())2998 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))2999 #end populate3000 def setUp(self):3001 super(VirtualIpTestFixtureGen, self).setUp()3002 if not self._parent_fixt:3003 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))3004 self._obj = vnc_api.VirtualIp(self._name, self._parent_fixt.getObj ())3005 try:3006 self._obj = self._conn_drv.virtual_ip_read (fq_name=self._obj.get_fq_name())3007 self._update_links (update_server=True)3008 except NoIdError:3009 self._update_links (update_server=False)3010 if self._auto_prop_val:3011 self.populate ()3012 else:3013 self._obj.virtual_ip_properties = self.virtual_ip_properties3014 self._obj.id_perms = self.id_perms3015 self._obj.display_name = self.display_name3016 self._conn_drv.virtual_ip_create(self._obj)3017 # read back for server allocated values3018 self._obj = self._conn_drv.virtual_ip_read(id = self._obj.uuid)3019 #end setUp3020 def cleanUp(self):3021 parent_fixt = getattr(self, '_parent_fixt', None)3022 if parent_fixt:3023 # non config-root child3024 parent_obj = self._parent_fixt.getObj()3025 # remove child from parent obj3026 for child_obj in parent_obj.get_virtual_ips():3027 if type(child_obj) == dict:3028 child_uuid = child_obj['uuid']3029 else:3030 child_uuid = child_obj.uuid3031 if child_uuid == self._obj.uuid:3032 parent_obj.virtual_ips.remove(child_obj)3033 break3034 self._conn_drv.virtual_ip_delete(id = self._obj.uuid)3035 #end cleanUp3036 def getObj(self):3037 return self._obj3038 #end getObj3039#end class VirtualIpTestFixtureGen3040class LoadbalancerMemberTestFixtureGen(cfixture.ContrailFixture):3041 """3042 Fixture for :class:`.LoadbalancerMember`3043 """3044 def __init__(self, conn_drv, loadbalancer_member_name=None, parent_fixt=None, auto_prop_val=False, loadbalancer_member_properties=None, id_perms=None, display_name=None):3045 '''3046 Create LoadbalancerMemberTestFixtureGen object3047 3048 constructor3049 Args:3050 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3051 Kwargs:3052 loadbalancer_member_name (str): Name of loadbalancer_member3053 parent_fixt (:class:`.LoadbalancerPoolTestFixtureGen`): Parent fixture3054 loadbalancer_member_properties (instance): instance of :class:`LoadbalancerMemberType`3055 id_perms (instance): instance of :class:`IdPermsType`3056 display_name (instance): instance of :class:`xsd:string`3057 '''3058 super(LoadbalancerMemberTestFixtureGen, self).__init__()3059 self._conn_drv = conn_drv3060 if not loadbalancer_member_name:3061 self._name = 'default-loadbalancer-member'3062 else:3063 self._name = loadbalancer_member_name3064 self._obj = None3065 self._parent_fixt = parent_fixt3066 self._auto_prop_val = auto_prop_val3067 self.loadbalancer_member_properties = loadbalancer_member_properties3068 self.id_perms = id_perms3069 self.display_name = display_name3070 #end __init__3071 def _update_links (self, update_server):3072 return None3073 #end _update_links3074 def populate (self):3075 self._obj.set_loadbalancer_member_properties(self.loadbalancer_member_properties or vnc_api.gen.resource_xsd.LoadbalancerMemberType.populate())3076 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3077 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3078 #end populate3079 def setUp(self):3080 super(LoadbalancerMemberTestFixtureGen, self).setUp()3081 if not self._parent_fixt:3082 self._parent_fixt = self.useFixture(LoadbalancerPoolTestFixtureGen(self._conn_drv, 'default-loadbalancer-pool'))3083 self._obj = vnc_api.LoadbalancerMember(self._name, self._parent_fixt.getObj ())3084 try:3085 self._obj = self._conn_drv.loadbalancer_member_read (fq_name=self._obj.get_fq_name())3086 self._update_links (update_server=True)3087 except NoIdError:3088 self._update_links (update_server=False)3089 if self._auto_prop_val:3090 self.populate ()3091 else:3092 self._obj.loadbalancer_member_properties = self.loadbalancer_member_properties3093 self._obj.id_perms = self.id_perms3094 self._obj.display_name = self.display_name3095 self._conn_drv.loadbalancer_member_create(self._obj)3096 # read back for server allocated values3097 self._obj = self._conn_drv.loadbalancer_member_read(id = self._obj.uuid)3098 #end setUp3099 def cleanUp(self):3100 parent_fixt = getattr(self, '_parent_fixt', None)3101 if parent_fixt:3102 # non config-root child3103 parent_obj = self._parent_fixt.getObj()3104 # remove child from parent obj3105 for child_obj in parent_obj.get_loadbalancer_members():3106 if type(child_obj) == dict:3107 child_uuid = child_obj['uuid']3108 else:3109 child_uuid = child_obj.uuid3110 if child_uuid == self._obj.uuid:3111 parent_obj.loadbalancer_members.remove(child_obj)3112 break3113 self._conn_drv.loadbalancer_member_delete(id = self._obj.uuid)3114 #end cleanUp3115 def getObj(self):3116 return self._obj3117 #end getObj3118#end class LoadbalancerMemberTestFixtureGen3119class SecurityGroupTestFixtureGen(cfixture.ContrailFixture):3120 """3121 Fixture for :class:`.SecurityGroup`3122 """3123 def __init__(self, conn_drv, security_group_name=None, parent_fixt=None, auto_prop_val=False, security_group_id=None, configured_security_group_id=None, security_group_entries=None, id_perms=None, display_name=None):3124 '''3125 Create SecurityGroupTestFixtureGen object3126 3127 constructor3128 Args:3129 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3130 Kwargs:3131 security_group_name (str): Name of security_group3132 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture3133 security_group_id (instance): instance of :class:`xsd:string`3134 configured_security_group_id (instance): instance of :class:`xsd:integer`3135 security_group_entries (instance): instance of :class:`PolicyEntriesType`3136 id_perms (instance): instance of :class:`IdPermsType`3137 display_name (instance): instance of :class:`xsd:string`3138 '''3139 super(SecurityGroupTestFixtureGen, self).__init__()3140 self._conn_drv = conn_drv3141 if not security_group_name:3142 self._name = 'default-security-group'3143 else:3144 self._name = security_group_name3145 self._obj = None3146 self._parent_fixt = parent_fixt3147 self._auto_prop_val = auto_prop_val3148 self.security_group_id = security_group_id3149 self.configured_security_group_id = configured_security_group_id3150 self.security_group_entries = security_group_entries3151 self.id_perms = id_perms3152 self.display_name = display_name3153 #end __init__3154 def _update_links (self, update_server):3155 return None3156 #end _update_links3157 def populate (self):3158 self._obj.set_security_group_id(self.security_group_id or GeneratedsSuper.populate_string("security_group_id"))3159 self._obj.set_configured_security_group_id(self.configured_security_group_id or GeneratedsSuper.populate_integer("configured_security_group_id"))3160 self._obj.set_security_group_entries(self.security_group_entries or vnc_api.gen.resource_xsd.PolicyEntriesType.populate())3161 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3162 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3163 #end populate3164 def setUp(self):3165 super(SecurityGroupTestFixtureGen, self).setUp()3166 if not self._parent_fixt:3167 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))3168 self._obj = vnc_api.SecurityGroup(self._name, self._parent_fixt.getObj ())3169 try:3170 self._obj = self._conn_drv.security_group_read (fq_name=self._obj.get_fq_name())3171 self._update_links (update_server=True)3172 except NoIdError:3173 self._update_links (update_server=False)3174 if self._auto_prop_val:3175 self.populate ()3176 else:3177 self._obj.security_group_id = self.security_group_id3178 self._obj.configured_security_group_id = self.configured_security_group_id3179 self._obj.security_group_entries = self.security_group_entries3180 self._obj.id_perms = self.id_perms3181 self._obj.display_name = self.display_name3182 self._conn_drv.security_group_create(self._obj)3183 # read back for server allocated values3184 self._obj = self._conn_drv.security_group_read(id = self._obj.uuid)3185 #end setUp3186 def cleanUp(self):3187 if self._obj.get_virtual_machine_interface_back_refs():3188 return3189 parent_fixt = getattr(self, '_parent_fixt', None)3190 if parent_fixt:3191 # non config-root child3192 parent_obj = self._parent_fixt.getObj()3193 # remove child from parent obj3194 for child_obj in parent_obj.get_security_groups():3195 if type(child_obj) == dict:3196 child_uuid = child_obj['uuid']3197 else:3198 child_uuid = child_obj.uuid3199 if child_uuid == self._obj.uuid:3200 parent_obj.security_groups.remove(child_obj)3201 break3202 self._conn_drv.security_group_delete(id = self._obj.uuid)3203 #end cleanUp3204 def getObj(self):3205 return self._obj3206 #end getObj3207#end class SecurityGroupTestFixtureGen3208class ProviderAttachmentTestFixtureGen(cfixture.ContrailFixture):3209 """3210 Fixture for :class:`.ProviderAttachment`3211 """3212 def __init__(self, conn_drv, provider_attachment_name=None, auto_prop_val=False, virtual_router_refs = None, id_perms=None, display_name=None):3213 '''3214 Create ProviderAttachmentTestFixtureGen object3215 3216 constructor3217 Args:3218 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3219 Kwargs:3220 %s_name (str): Name of %s3221 virtual_router (list): list of :class:`VirtualRouter` type3222 id_perms (instance): instance of :class:`IdPermsType`3223 display_name (instance): instance of :class:`xsd:string`3224 '''3225 super(ProviderAttachmentTestFixtureGen, self).__init__()3226 self._conn_drv = conn_drv3227 if not provider_attachment_name:3228 self._name = 'default-provider-attachment'3229 else:3230 self._name = provider_attachment_name3231 self._obj = None3232 self._auto_prop_val = auto_prop_val3233 if virtual_router_refs:3234 for ln in virtual_router_refs:3235 self.add_virtual_router (ln)3236 self.id_perms = id_perms3237 self.display_name = display_name3238 #end __init__3239 def _update_links (self, update_server):3240 for ln in self.get_virtual_routers ():3241 self.add_virtual_router (ln.fixture (), update_server = update_server, add_link = False)3242 return None3243 #end _update_links3244 def add_virtual_router (self, lo, update_server = True, add_link = True):3245 '''3246 add :class:`VirtualRouter` link to :class:`ProviderAttachment`3247 Args:3248 lo (:class:`VirtualRouter`): obj to link3249 '''3250 if self._obj:3251 self._obj.add_virtual_router (lo)3252 if update_server:3253 self._conn_drv.provider_attachment_update (self._obj)3254 if add_link:3255 self.add_link('virtual_router', cfixture.ConrtailLink('virtual_router', 'provider_attachment', 'virtual_router', ['ref'], lo))3256 #end add_virtual_router_link3257 def get_virtual_routers (self):3258 return self.get_links ('virtual_router')3259 #end get_virtual_routers3260 def populate (self):3261 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3262 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3263 #end populate3264 def setUp(self):3265 super(ProviderAttachmentTestFixtureGen, self).setUp()3266 self._obj = vnc_api.ProviderAttachment(self._name)3267 try:3268 self._obj = self._conn_drv.provider_attachment_read (fq_name=self._obj.get_fq_name())3269 self._update_links (update_server=True)3270 except NoIdError:3271 self._update_links (update_server=False)3272 if self._auto_prop_val:3273 self.populate ()3274 else:3275 self._obj.id_perms = self.id_perms3276 self._obj.display_name = self.display_name3277 self._conn_drv.provider_attachment_create(self._obj)3278 # read back for server allocated values3279 self._obj = self._conn_drv.provider_attachment_read(id = self._obj.uuid)3280 #end setUp3281 def cleanUp(self):3282 self._conn_drv.provider_attachment_delete(id = self._obj.uuid)3283 #end cleanUp3284 def getObj(self):3285 return self._obj3286 #end getObj3287#end class ProviderAttachmentTestFixtureGen3288class VirtualMachineInterfaceTestFixtureGen(cfixture.ContrailFixture):3289 """3290 Fixture for :class:`.VirtualMachineInterface`3291 """3292 def __init__(self, conn_drv, virtual_machine_interface_name=None, parent_fixt=None, auto_prop_val=False, qos_forwarding_class_refs = None, security_group_refs = None, virtual_machine_interface_refs = None, virtual_machine_refs = None, virtual_network_refs = None, routing_instance_ref_infos = None, interface_route_table_refs = None, virtual_machine_interface_mac_addresses=None, virtual_machine_interface_dhcp_option_list=None, virtual_machine_interface_host_routes=None, virtual_machine_interface_allowed_address_pairs=None, vrf_assign_table=None, virtual_machine_interface_device_owner=None, virtual_machine_interface_properties=None, id_perms=None, display_name=None):3293 '''3294 Create VirtualMachineInterfaceTestFixtureGen object3295 3296 constructor3297 Args:3298 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3299 Kwargs:3300 virtual_machine_interface_name (str): Name of virtual_machine_interface3301 parent_fixt (:class:`.VirtualMachineTestFixtureGen`): Parent fixture3302 qos_forwarding_class (list): list of :class:`QosForwardingClass` type3303 security_group (list): list of :class:`SecurityGroup` type3304 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type3305 virtual_machine (list): list of :class:`VirtualMachine` type3306 virtual_network (list): list of :class:`VirtualNetwork` type3307 routing_instance (list): list of tuple (:class:`RoutingInstance`, :class: `PolicyBasedForwardingRuleType`) type3308 interface_route_table (list): list of :class:`InterfaceRouteTable` type3309 virtual_machine_interface_mac_addresses (instance): instance of :class:`MacAddressesType`3310 virtual_machine_interface_dhcp_option_list (instance): instance of :class:`DhcpOptionsListType`3311 virtual_machine_interface_host_routes (instance): instance of :class:`RouteTableType`3312 virtual_machine_interface_allowed_address_pairs (instance): instance of :class:`AllowedAddressPairs`3313 vrf_assign_table (instance): instance of :class:`VrfAssignTableType`3314 virtual_machine_interface_device_owner (instance): instance of :class:`xsd:string`3315 virtual_machine_interface_properties (instance): instance of :class:`VirtualMachineInterfacePropertiesType`3316 id_perms (instance): instance of :class:`IdPermsType`3317 display_name (instance): instance of :class:`xsd:string`3318 '''3319 super(VirtualMachineInterfaceTestFixtureGen, self).__init__()3320 self._conn_drv = conn_drv3321 if not virtual_machine_interface_name:3322 self._name = 'default-virtual-machine-interface'3323 else:3324 self._name = virtual_machine_interface_name3325 self._obj = None3326 self._parent_fixt = parent_fixt3327 self._auto_prop_val = auto_prop_val3328 if qos_forwarding_class_refs:3329 for ln in qos_forwarding_class_refs:3330 self.add_qos_forwarding_class (ln)3331 if security_group_refs:3332 for ln in security_group_refs:3333 self.add_security_group (ln)3334 if virtual_machine_interface_refs:3335 for ln in virtual_machine_interface_refs:3336 self.add_virtual_machine_interface (ln)3337 if virtual_machine_refs:3338 for ln in virtual_machine_refs:3339 self.add_virtual_machine (ln)3340 if virtual_network_refs:3341 for ln in virtual_network_refs:3342 self.add_virtual_network (ln)3343 if routing_instance_ref_infos:3344 for ln, ref in routing_instance_ref_infos:3345 self.add_routing_instance (ln, ref)3346 if interface_route_table_refs:3347 for ln in interface_route_table_refs:3348 self.add_interface_route_table (ln)3349 self.virtual_machine_interface_mac_addresses = virtual_machine_interface_mac_addresses3350 self.virtual_machine_interface_dhcp_option_list = virtual_machine_interface_dhcp_option_list3351 self.virtual_machine_interface_host_routes = virtual_machine_interface_host_routes3352 self.virtual_machine_interface_allowed_address_pairs = virtual_machine_interface_allowed_address_pairs3353 self.vrf_assign_table = vrf_assign_table3354 self.virtual_machine_interface_device_owner = virtual_machine_interface_device_owner3355 self.virtual_machine_interface_properties = virtual_machine_interface_properties3356 self.id_perms = id_perms3357 self.display_name = display_name3358 #end __init__3359 def _update_links (self, update_server):3360 for ln in self.get_qos_forwarding_classs ():3361 self.add_qos_forwarding_class (ln.fixture (), update_server = update_server, add_link = False)3362 for ln in self.get_security_groups ():3363 self.add_security_group (ln.fixture (), update_server = update_server, add_link = False)3364 for ln in self.get_virtual_machine_interfaces ():3365 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)3366 for ln in self.get_virtual_machines ():3367 self.add_virtual_machine (ln.fixture (), update_server = update_server, add_link = False)3368 for ln in self.get_virtual_networks ():3369 self.add_virtual_network (ln.fixture (), update_server = update_server, add_link = False)3370 for ln in self.get_routing_instances ():3371 self.add_routing_instance (*ln.fixture (), update_server = update_server, add_link = False)3372 for ln in self.get_interface_route_tables ():3373 self.add_interface_route_table (ln.fixture (), update_server = update_server, add_link = False)3374 return None3375 #end _update_links3376 def add_qos_forwarding_class (self, lo, update_server = True, add_link = True):3377 '''3378 add :class:`QosForwardingClass` link to :class:`VirtualMachineInterface`3379 Args:3380 lo (:class:`QosForwardingClass`): obj to link3381 '''3382 if self._obj:3383 self._obj.add_qos_forwarding_class (lo)3384 if update_server:3385 self._conn_drv.virtual_machine_interface_update (self._obj)3386 if add_link:3387 self.add_link('qos_forwarding_class', cfixture.ConrtailLink('qos_forwarding_class', 'virtual_machine_interface', 'qos_forwarding_class', ['ref'], lo))3388 #end add_qos_forwarding_class_link3389 def get_qos_forwarding_classs (self):3390 return self.get_links ('qos_forwarding_class')3391 #end get_qos_forwarding_classs3392 def add_security_group (self, lo, update_server = True, add_link = True):3393 '''3394 add :class:`SecurityGroup` link to :class:`VirtualMachineInterface`3395 Args:3396 lo (:class:`SecurityGroup`): obj to link3397 '''3398 if self._obj:3399 self._obj.add_security_group (lo)3400 if update_server:3401 self._conn_drv.virtual_machine_interface_update (self._obj)3402 if add_link:3403 self.add_link('security_group', cfixture.ConrtailLink('security_group', 'virtual_machine_interface', 'security_group', ['ref'], lo))3404 #end add_security_group_link3405 def get_security_groups (self):3406 return self.get_links ('security_group')3407 #end get_security_groups3408 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):3409 '''3410 add :class:`VirtualMachineInterface` link to :class:`VirtualMachineInterface`3411 Args:3412 lo (:class:`VirtualMachineInterface`): obj to link3413 '''3414 if self._obj:3415 self._obj.add_virtual_machine_interface (lo)3416 if update_server:3417 self._conn_drv.virtual_machine_interface_update (self._obj)3418 if add_link:3419 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'virtual_machine_interface', 'virtual_machine_interface', ['ref'], lo))3420 #end add_virtual_machine_interface_link3421 def get_virtual_machine_interfaces (self):3422 return self.get_links ('virtual_machine_interface')3423 #end get_virtual_machine_interfaces3424 def add_virtual_machine (self, lo, update_server = True, add_link = True):3425 '''3426 add :class:`VirtualMachine` link to :class:`VirtualMachineInterface`3427 Args:3428 lo (:class:`VirtualMachine`): obj to link3429 '''3430 if self._obj:3431 self._obj.add_virtual_machine (lo)3432 if update_server:3433 self._conn_drv.virtual_machine_interface_update (self._obj)3434 if add_link:3435 self.add_link('virtual_machine', cfixture.ConrtailLink('virtual_machine', 'virtual_machine_interface', 'virtual_machine', ['ref'], lo))3436 #end add_virtual_machine_link3437 def get_virtual_machines (self):3438 return self.get_links ('virtual_machine')3439 #end get_virtual_machines3440 def add_virtual_network (self, lo, update_server = True, add_link = True):3441 '''3442 add :class:`VirtualNetwork` link to :class:`VirtualMachineInterface`3443 Args:3444 lo (:class:`VirtualNetwork`): obj to link3445 '''3446 if self._obj:3447 self._obj.add_virtual_network (lo)3448 if update_server:3449 self._conn_drv.virtual_machine_interface_update (self._obj)3450 if add_link:3451 self.add_link('virtual_network', cfixture.ConrtailLink('virtual_network', 'virtual_machine_interface', 'virtual_network', ['ref'], lo))3452 #end add_virtual_network_link3453 def get_virtual_networks (self):3454 return self.get_links ('virtual_network')3455 #end get_virtual_networks3456 def add_routing_instance (self, lo, ref, update_server = True, add_link = True):3457 '''3458 add :class:`RoutingInstance` link to :class:`VirtualMachineInterface`3459 Args:3460 lo (:class:`RoutingInstance`): obj to link3461 ref (:class:`PolicyBasedForwardingRuleType`): property of the link object3462 '''3463 if self._obj:3464 self._obj.add_routing_instance (lo, ref)3465 if update_server:3466 self._conn_drv.virtual_machine_interface_update (self._obj)3467 if add_link:3468 self.add_link('routing_instance', cfixture.ConrtailLink('routing_instance', 'virtual_machine_interface', 'routing_instance', ['ref'], (lo, ref)))3469 #end add_routing_instance_link3470 def get_routing_instances (self):3471 return self.get_links ('routing_instance')3472 #end get_routing_instances3473 def add_interface_route_table (self, lo, update_server = True, add_link = True):3474 '''3475 add :class:`InterfaceRouteTable` link to :class:`VirtualMachineInterface`3476 Args:3477 lo (:class:`InterfaceRouteTable`): obj to link3478 '''3479 if self._obj:3480 self._obj.add_interface_route_table (lo)3481 if update_server:3482 self._conn_drv.virtual_machine_interface_update (self._obj)3483 if add_link:3484 self.add_link('interface_route_table', cfixture.ConrtailLink('interface_route_table', 'virtual_machine_interface', 'interface_route_table', ['ref'], lo))3485 #end add_interface_route_table_link3486 def get_interface_route_tables (self):3487 return self.get_links ('interface_route_table')3488 #end get_interface_route_tables3489 def populate (self):3490 self._obj.set_virtual_machine_interface_mac_addresses(self.virtual_machine_interface_mac_addresses or vnc_api.gen.resource_xsd.MacAddressesType.populate())3491 self._obj.set_virtual_machine_interface_dhcp_option_list(self.virtual_machine_interface_dhcp_option_list or vnc_api.gen.resource_xsd.DhcpOptionsListType.populate())3492 self._obj.set_virtual_machine_interface_host_routes(self.virtual_machine_interface_host_routes or vnc_api.gen.resource_xsd.RouteTableType.populate())3493 self._obj.set_virtual_machine_interface_allowed_address_pairs(self.virtual_machine_interface_allowed_address_pairs or vnc_api.gen.resource_xsd.AllowedAddressPairs.populate())3494 self._obj.set_vrf_assign_table(self.vrf_assign_table or vnc_api.gen.resource_xsd.VrfAssignTableType.populate())3495 self._obj.set_virtual_machine_interface_device_owner(self.virtual_machine_interface_device_owner or GeneratedsSuper.populate_string("virtual_machine_interface_device_owner"))3496 self._obj.set_virtual_machine_interface_properties(self.virtual_machine_interface_properties or vnc_api.gen.resource_xsd.VirtualMachineInterfacePropertiesType.populate())3497 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3498 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3499 #end populate3500 def setUp(self):3501 super(VirtualMachineInterfaceTestFixtureGen, self).setUp()3502 if not self._parent_fixt:3503 raise AmbiguousParentError("[[u'default-virtual-machine'], [u'default-domain', u'default-project']]")3504 self._obj = vnc_api.VirtualMachineInterface(self._name, self._parent_fixt.getObj ())3505 try:3506 self._obj = self._conn_drv.virtual_machine_interface_read (fq_name=self._obj.get_fq_name())3507 self._update_links (update_server=True)3508 except NoIdError:3509 self._update_links (update_server=False)3510 if self._auto_prop_val:3511 self.populate ()3512 else:3513 self._obj.virtual_machine_interface_mac_addresses = self.virtual_machine_interface_mac_addresses3514 self._obj.virtual_machine_interface_dhcp_option_list = self.virtual_machine_interface_dhcp_option_list3515 self._obj.virtual_machine_interface_host_routes = self.virtual_machine_interface_host_routes3516 self._obj.virtual_machine_interface_allowed_address_pairs = self.virtual_machine_interface_allowed_address_pairs3517 self._obj.vrf_assign_table = self.vrf_assign_table3518 self._obj.virtual_machine_interface_device_owner = self.virtual_machine_interface_device_owner3519 self._obj.virtual_machine_interface_properties = self.virtual_machine_interface_properties3520 self._obj.id_perms = self.id_perms3521 self._obj.display_name = self.display_name3522 self._conn_drv.virtual_machine_interface_create(self._obj)3523 # read back for server allocated values3524 self._obj = self._conn_drv.virtual_machine_interface_read(id = self._obj.uuid)3525 #end setUp3526 def cleanUp(self):3527 if self._obj.get_virtual_machine_interface_back_refs() or self._obj.get_instance_ip_back_refs() or self._obj.get_subnet_back_refs() or self._obj.get_floating_ip_back_refs() or self._obj.get_logical_interface_back_refs() or self._obj.get_customer_attachment_back_refs() or self._obj.get_logical_router_back_refs() or self._obj.get_loadbalancer_pool_back_refs() or self._obj.get_virtual_ip_back_refs():3528 return3529 parent_fixt = getattr(self, '_parent_fixt', None)3530 if parent_fixt:3531 # non config-root child3532 parent_obj = self._parent_fixt.getObj()3533 # remove child from parent obj3534 for child_obj in parent_obj.get_virtual_machine_interfaces():3535 if type(child_obj) == dict:3536 child_uuid = child_obj['uuid']3537 else:3538 child_uuid = child_obj.uuid3539 if child_uuid == self._obj.uuid:3540 parent_obj.virtual_machine_interfaces.remove(child_obj)3541 break3542 self._conn_drv.virtual_machine_interface_delete(id = self._obj.uuid)3543 #end cleanUp3544 def getObj(self):3545 return self._obj3546 #end getObj3547#end class VirtualMachineInterfaceTestFixtureGen3548class LoadbalancerHealthmonitorTestFixtureGen(cfixture.ContrailFixture):3549 """3550 Fixture for :class:`.LoadbalancerHealthmonitor`3551 """3552 def __init__(self, conn_drv, loadbalancer_healthmonitor_name=None, parent_fixt=None, auto_prop_val=False, loadbalancer_healthmonitor_properties=None, id_perms=None, display_name=None):3553 '''3554 Create LoadbalancerHealthmonitorTestFixtureGen object3555 3556 constructor3557 Args:3558 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3559 Kwargs:3560 loadbalancer_healthmonitor_name (str): Name of loadbalancer_healthmonitor3561 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture3562 loadbalancer_healthmonitor_properties (instance): instance of :class:`LoadbalancerHealthmonitorType`3563 id_perms (instance): instance of :class:`IdPermsType`3564 display_name (instance): instance of :class:`xsd:string`3565 '''3566 super(LoadbalancerHealthmonitorTestFixtureGen, self).__init__()3567 self._conn_drv = conn_drv3568 if not loadbalancer_healthmonitor_name:3569 self._name = 'default-loadbalancer-healthmonitor'3570 else:3571 self._name = loadbalancer_healthmonitor_name3572 self._obj = None3573 self._parent_fixt = parent_fixt3574 self._auto_prop_val = auto_prop_val3575 self.loadbalancer_healthmonitor_properties = loadbalancer_healthmonitor_properties3576 self.id_perms = id_perms3577 self.display_name = display_name3578 #end __init__3579 def _update_links (self, update_server):3580 return None3581 #end _update_links3582 def populate (self):3583 self._obj.set_loadbalancer_healthmonitor_properties(self.loadbalancer_healthmonitor_properties or vnc_api.gen.resource_xsd.LoadbalancerHealthmonitorType.populate())3584 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3585 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3586 #end populate3587 def setUp(self):3588 super(LoadbalancerHealthmonitorTestFixtureGen, self).setUp()3589 if not self._parent_fixt:3590 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))3591 self._obj = vnc_api.LoadbalancerHealthmonitor(self._name, self._parent_fixt.getObj ())3592 try:3593 self._obj = self._conn_drv.loadbalancer_healthmonitor_read (fq_name=self._obj.get_fq_name())3594 self._update_links (update_server=True)3595 except NoIdError:3596 self._update_links (update_server=False)3597 if self._auto_prop_val:3598 self.populate ()3599 else:3600 self._obj.loadbalancer_healthmonitor_properties = self.loadbalancer_healthmonitor_properties3601 self._obj.id_perms = self.id_perms3602 self._obj.display_name = self.display_name3603 self._conn_drv.loadbalancer_healthmonitor_create(self._obj)3604 # read back for server allocated values3605 self._obj = self._conn_drv.loadbalancer_healthmonitor_read(id = self._obj.uuid)3606 #end setUp3607 def cleanUp(self):3608 if self._obj.get_loadbalancer_pool_back_refs():3609 return3610 parent_fixt = getattr(self, '_parent_fixt', None)3611 if parent_fixt:3612 # non config-root child3613 parent_obj = self._parent_fixt.getObj()3614 # remove child from parent obj3615 for child_obj in parent_obj.get_loadbalancer_healthmonitors():3616 if type(child_obj) == dict:3617 child_uuid = child_obj['uuid']3618 else:3619 child_uuid = child_obj.uuid3620 if child_uuid == self._obj.uuid:3621 parent_obj.loadbalancer_healthmonitors.remove(child_obj)3622 break3623 self._conn_drv.loadbalancer_healthmonitor_delete(id = self._obj.uuid)3624 #end cleanUp3625 def getObj(self):3626 return self._obj3627 #end getObj3628#end class LoadbalancerHealthmonitorTestFixtureGen3629class VirtualNetworkTestFixtureGen(cfixture.ContrailFixture):3630 """3631 Fixture for :class:`.VirtualNetwork`3632 """3633 def __init__(self, conn_drv, virtual_network_name=None, parent_fixt=None, auto_prop_val=False, qos_forwarding_class_refs = None, network_ipam_ref_infos = None, network_policy_ref_infos = None, route_table_refs = None, virtual_network_properties=None, virtual_network_network_id=None, route_target_list=None, router_external=None, is_shared=None, external_ipam=None, flood_unknown_unicast=None, id_perms=None, display_name=None):3634 '''3635 Create VirtualNetworkTestFixtureGen object3636 3637 constructor3638 Args:3639 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3640 Kwargs:3641 virtual_network_name (str): Name of virtual_network3642 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture3643 qos_forwarding_class (list): list of :class:`QosForwardingClass` type3644 network_ipam (list): list of tuple (:class:`NetworkIpam`, :class: `VnSubnetsType`) type3645 network_policy (list): list of tuple (:class:`NetworkPolicy`, :class: `VirtualNetworkPolicyType`) type3646 route_table (list): list of :class:`RouteTable` type3647 virtual_network_properties (instance): instance of :class:`VirtualNetworkType`3648 virtual_network_network_id (instance): instance of :class:`xsd:integer`3649 route_target_list (instance): instance of :class:`RouteTargetList`3650 router_external (instance): instance of :class:`xsd:boolean`3651 is_shared (instance): instance of :class:`xsd:boolean`3652 external_ipam (instance): instance of :class:`xsd:boolean`3653 flood_unknown_unicast (instance): instance of :class:`xsd:boolean`3654 id_perms (instance): instance of :class:`IdPermsType`3655 display_name (instance): instance of :class:`xsd:string`3656 '''3657 super(VirtualNetworkTestFixtureGen, self).__init__()3658 self._conn_drv = conn_drv3659 if not virtual_network_name:3660 self._name = 'default-virtual-network'3661 else:3662 self._name = virtual_network_name3663 self._obj = None3664 self._parent_fixt = parent_fixt3665 self._auto_prop_val = auto_prop_val3666 if qos_forwarding_class_refs:3667 for ln in qos_forwarding_class_refs:3668 self.add_qos_forwarding_class (ln)3669 if network_ipam_ref_infos:3670 for ln, ref in network_ipam_ref_infos:3671 self.add_network_ipam (ln, ref)3672 if network_policy_ref_infos:3673 for ln, ref in network_policy_ref_infos:3674 self.add_network_policy (ln, ref)3675 if route_table_refs:3676 for ln in route_table_refs:3677 self.add_route_table (ln)3678 self.virtual_network_properties = virtual_network_properties3679 self.virtual_network_network_id = virtual_network_network_id3680 self.route_target_list = route_target_list3681 self.router_external = router_external3682 self.is_shared = is_shared3683 self.external_ipam = external_ipam3684 self.flood_unknown_unicast = flood_unknown_unicast3685 self.id_perms = id_perms3686 self.display_name = display_name3687 #end __init__3688 def _update_links (self, update_server):3689 for ln in self.get_qos_forwarding_classs ():3690 self.add_qos_forwarding_class (ln.fixture (), update_server = update_server, add_link = False)3691 for ln in self.get_network_ipams ():3692 self.add_network_ipam (*ln.fixture (), update_server = update_server, add_link = False)3693 for ln in self.get_network_policys ():3694 self.add_network_policy (*ln.fixture (), update_server = update_server, add_link = False)3695 for ln in self.get_route_tables ():3696 self.add_route_table (ln.fixture (), update_server = update_server, add_link = False)3697 return None3698 #end _update_links3699 def add_qos_forwarding_class (self, lo, update_server = True, add_link = True):3700 '''3701 add :class:`QosForwardingClass` link to :class:`VirtualNetwork`3702 Args:3703 lo (:class:`QosForwardingClass`): obj to link3704 '''3705 if self._obj:3706 self._obj.add_qos_forwarding_class (lo)3707 if update_server:3708 self._conn_drv.virtual_network_update (self._obj)3709 if add_link:3710 self.add_link('qos_forwarding_class', cfixture.ConrtailLink('qos_forwarding_class', 'virtual_network', 'qos_forwarding_class', ['ref'], lo))3711 #end add_qos_forwarding_class_link3712 def get_qos_forwarding_classs (self):3713 return self.get_links ('qos_forwarding_class')3714 #end get_qos_forwarding_classs3715 def add_network_ipam (self, lo, ref, update_server = True, add_link = True):3716 '''3717 add :class:`NetworkIpam` link to :class:`VirtualNetwork`3718 Args:3719 lo (:class:`NetworkIpam`): obj to link3720 ref (:class:`VnSubnetsType`): property of the link object3721 '''3722 if self._obj:3723 self._obj.add_network_ipam (lo, ref)3724 if update_server:3725 self._conn_drv.virtual_network_update (self._obj)3726 if add_link:3727 self.add_link('network_ipam', cfixture.ConrtailLink('network_ipam', 'virtual_network', 'network_ipam', ['ref'], (lo, ref)))3728 #end add_network_ipam_link3729 def get_network_ipams (self):3730 return self.get_links ('network_ipam')3731 #end get_network_ipams3732 def add_network_policy (self, lo, ref, update_server = True, add_link = True):3733 '''3734 add :class:`NetworkPolicy` link to :class:`VirtualNetwork`3735 Args:3736 lo (:class:`NetworkPolicy`): obj to link3737 ref (:class:`VirtualNetworkPolicyType`): property of the link object3738 '''3739 if self._obj:3740 self._obj.add_network_policy (lo, ref)3741 if update_server:3742 self._conn_drv.virtual_network_update (self._obj)3743 if add_link:3744 self.add_link('network_policy', cfixture.ConrtailLink('network_policy', 'virtual_network', 'network_policy', ['ref'], (lo, ref)))3745 #end add_network_policy_link3746 def get_network_policys (self):3747 return self.get_links ('network_policy')3748 #end get_network_policys3749 def add_route_table (self, lo, update_server = True, add_link = True):3750 '''3751 add :class:`RouteTable` link to :class:`VirtualNetwork`3752 Args:3753 lo (:class:`RouteTable`): obj to link3754 '''3755 if self._obj:3756 self._obj.add_route_table (lo)3757 if update_server:3758 self._conn_drv.virtual_network_update (self._obj)3759 if add_link:3760 self.add_link('route_table', cfixture.ConrtailLink('route_table', 'virtual_network', 'route_table', ['ref'], lo))3761 #end add_route_table_link3762 def get_route_tables (self):3763 return self.get_links ('route_table')3764 #end get_route_tables3765 def populate (self):3766 self._obj.set_virtual_network_properties(self.virtual_network_properties or vnc_api.gen.resource_xsd.VirtualNetworkType.populate())3767 self._obj.set_virtual_network_network_id(self.virtual_network_network_id or GeneratedsSuper.populate_integer("virtual_network_network_id"))3768 self._obj.set_route_target_list(self.route_target_list or vnc_api.gen.resource_xsd.RouteTargetList.populate())3769 self._obj.set_router_external(self.router_external or GeneratedsSuper.populate_boolean("router_external"))3770 self._obj.set_is_shared(self.is_shared or GeneratedsSuper.populate_boolean("is_shared"))3771 self._obj.set_external_ipam(self.external_ipam or GeneratedsSuper.populate_boolean("external_ipam"))3772 self._obj.set_flood_unknown_unicast(self.flood_unknown_unicast or GeneratedsSuper.populate_boolean("flood_unknown_unicast"))3773 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3774 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3775 #end populate3776 def setUp(self):3777 super(VirtualNetworkTestFixtureGen, self).setUp()3778 if not self._parent_fixt:3779 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))3780 self._obj = vnc_api.VirtualNetwork(self._name, self._parent_fixt.getObj ())3781 try:3782 self._obj = self._conn_drv.virtual_network_read (fq_name=self._obj.get_fq_name())3783 self._update_links (update_server=True)3784 except NoIdError:3785 self._update_links (update_server=False)3786 if self._auto_prop_val:3787 self.populate ()3788 else:3789 self._obj.virtual_network_properties = self.virtual_network_properties3790 self._obj.virtual_network_network_id = self.virtual_network_network_id3791 self._obj.route_target_list = self.route_target_list3792 self._obj.router_external = self.router_external3793 self._obj.is_shared = self.is_shared3794 self._obj.external_ipam = self.external_ipam3795 self._obj.flood_unknown_unicast = self.flood_unknown_unicast3796 self._obj.id_perms = self.id_perms3797 self._obj.display_name = self.display_name3798 self._conn_drv.virtual_network_create(self._obj)3799 # read back for server allocated values3800 self._obj = self._conn_drv.virtual_network_read(id = self._obj.uuid)3801 #end setUp3802 def cleanUp(self):3803 if self._obj.get_virtual_machine_interface_back_refs() or self._obj.get_instance_ip_back_refs() or self._obj.get_physical_router_back_refs() or self._obj.get_logical_router_back_refs():3804 return3805 if self._obj.get_floating_ip_pools():3806 return3807 parent_fixt = getattr(self, '_parent_fixt', None)3808 if parent_fixt:3809 # non config-root child3810 parent_obj = self._parent_fixt.getObj()3811 # remove child from parent obj3812 for child_obj in parent_obj.get_virtual_networks():3813 if type(child_obj) == dict:3814 child_uuid = child_obj['uuid']3815 else:3816 child_uuid = child_obj.uuid3817 if child_uuid == self._obj.uuid:3818 parent_obj.virtual_networks.remove(child_obj)3819 break3820 self._conn_drv.virtual_network_delete(id = self._obj.uuid)3821 #end cleanUp3822 def getObj(self):3823 return self._obj3824 #end getObj3825#end class VirtualNetworkTestFixtureGen3826class ProjectTestFixtureGen(cfixture.ContrailFixture):3827 """3828 Fixture for :class:`.Project`3829 """3830 def __init__(self, conn_drv, project_name=None, parent_fixt=None, auto_prop_val=False, namespace_ref_infos = None, floating_ip_pool_refs = None, quota=None, id_perms=None, display_name=None):3831 '''3832 Create ProjectTestFixtureGen object3833 3834 constructor3835 Args:3836 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3837 Kwargs:3838 project_name (str): Name of project3839 parent_fixt (:class:`.DomainTestFixtureGen`): Parent fixture3840 namespace (list): list of tuple (:class:`Namespace`, :class: `SubnetType`) type3841 floating_ip_pool (list): list of :class:`FloatingIpPool` type3842 quota (instance): instance of :class:`QuotaType`3843 id_perms (instance): instance of :class:`IdPermsType`3844 display_name (instance): instance of :class:`xsd:string`3845 '''3846 super(ProjectTestFixtureGen, self).__init__()3847 self._conn_drv = conn_drv3848 if not project_name:3849 self._name = 'default-project'3850 else:3851 self._name = project_name3852 self._obj = None3853 self._parent_fixt = parent_fixt3854 self._auto_prop_val = auto_prop_val3855 if namespace_ref_infos:3856 for ln, ref in namespace_ref_infos:3857 self.add_namespace (ln, ref)3858 if floating_ip_pool_refs:3859 for ln in floating_ip_pool_refs:3860 self.add_floating_ip_pool (ln)3861 self.quota = quota3862 self.id_perms = id_perms3863 self.display_name = display_name3864 #end __init__3865 def _update_links (self, update_server):3866 for ln in self.get_namespaces ():3867 self.add_namespace (*ln.fixture (), update_server = update_server, add_link = False)3868 for ln in self.get_floating_ip_pools ():3869 self.add_floating_ip_pool (ln.fixture (), update_server = update_server, add_link = False)3870 return None3871 #end _update_links3872 def add_namespace (self, lo, ref, update_server = True, add_link = True):3873 '''3874 add :class:`Namespace` link to :class:`Project`3875 Args:3876 lo (:class:`Namespace`): obj to link3877 ref (:class:`SubnetType`): property of the link object3878 '''3879 if self._obj:3880 self._obj.add_namespace (lo, ref)3881 if update_server:3882 self._conn_drv.project_update (self._obj)3883 if add_link:3884 self.add_link('namespace', cfixture.ConrtailLink('namespace', 'project', 'namespace', ['ref'], (lo, ref)))3885 #end add_namespace_link3886 def get_namespaces (self):3887 return self.get_links ('namespace')3888 #end get_namespaces3889 def add_floating_ip_pool (self, lo, update_server = True, add_link = True):3890 '''3891 add :class:`FloatingIpPool` link to :class:`Project`3892 Args:3893 lo (:class:`FloatingIpPool`): obj to link3894 '''3895 if self._obj:3896 self._obj.add_floating_ip_pool (lo)3897 if update_server:3898 self._conn_drv.project_update (self._obj)3899 if add_link:3900 self.add_link('floating_ip_pool', cfixture.ConrtailLink('floating_ip_pool', 'project', 'floating_ip_pool', ['ref'], lo))3901 #end add_floating_ip_pool_link3902 def get_floating_ip_pools (self):3903 return self.get_links ('floating_ip_pool')3904 #end get_floating_ip_pools3905 def populate (self):3906 self._obj.set_quota(self.quota or vnc_api.gen.resource_xsd.QuotaType.populate())3907 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())3908 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))3909 #end populate3910 def setUp(self):3911 super(ProjectTestFixtureGen, self).setUp()3912 if not self._parent_fixt:3913 self._parent_fixt = self.useFixture(DomainTestFixtureGen(self._conn_drv, 'default-domain'))3914 self._obj = vnc_api.Project(self._name, self._parent_fixt.getObj ())3915 try:3916 self._obj = self._conn_drv.project_read (fq_name=self._obj.get_fq_name())3917 self._update_links (update_server=True)3918 except NoIdError:3919 self._update_links (update_server=False)3920 if self._auto_prop_val:3921 self.populate ()3922 else:3923 self._obj.quota = self.quota3924 self._obj.id_perms = self.id_perms3925 self._obj.display_name = self.display_name3926 self._conn_drv.project_create(self._obj)3927 # read back for server allocated values3928 self._obj = self._conn_drv.project_read(id = self._obj.uuid)3929 #end setUp3930 def cleanUp(self):3931 if self._obj.get_floating_ip_back_refs():3932 return3933 if self._obj.get_security_groups() or self._obj.get_virtual_networks() or self._obj.get_qos_queues() or self._obj.get_qos_forwarding_classs() or self._obj.get_network_ipams() or self._obj.get_network_policys() or self._obj.get_virtual_machine_interfaces() or self._obj.get_service_instances() or self._obj.get_route_tables() or self._obj.get_interface_route_tables() or self._obj.get_logical_routers() or self._obj.get_loadbalancer_pools() or self._obj.get_loadbalancer_healthmonitors() or self._obj.get_virtual_ips():3934 return3935 parent_fixt = getattr(self, '_parent_fixt', None)3936 if parent_fixt:3937 # non config-root child3938 parent_obj = self._parent_fixt.getObj()3939 # remove child from parent obj3940 for child_obj in parent_obj.get_projects():3941 if type(child_obj) == dict:3942 child_uuid = child_obj['uuid']3943 else:3944 child_uuid = child_obj.uuid3945 if child_uuid == self._obj.uuid:3946 parent_obj.projects.remove(child_obj)3947 break3948 self._conn_drv.project_delete(id = self._obj.uuid)3949 #end cleanUp3950 def getObj(self):3951 return self._obj3952 #end getObj3953#end class ProjectTestFixtureGen3954class QosForwardingClassTestFixtureGen(cfixture.ContrailFixture):3955 """3956 Fixture for :class:`.QosForwardingClass`3957 """3958 def __init__(self, conn_drv, qos_forwarding_class_name=None, parent_fixt=None, auto_prop_val=False, qos_queue_refs = None, dscp=None, trusted=None, id_perms=None, display_name=None):3959 '''3960 Create QosForwardingClassTestFixtureGen object3961 3962 constructor3963 Args:3964 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)3965 Kwargs:3966 qos_forwarding_class_name (str): Name of qos_forwarding_class3967 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture3968 qos_queue (list): list of :class:`QosQueue` type3969 dscp (instance): instance of :class:`xsd:integer`3970 trusted (instance): instance of :class:`xsd:boolean`3971 id_perms (instance): instance of :class:`IdPermsType`3972 display_name (instance): instance of :class:`xsd:string`3973 '''3974 super(QosForwardingClassTestFixtureGen, self).__init__()3975 self._conn_drv = conn_drv3976 if not qos_forwarding_class_name:3977 self._name = 'default-qos-forwarding-class'3978 else:3979 self._name = qos_forwarding_class_name3980 self._obj = None3981 self._parent_fixt = parent_fixt3982 self._auto_prop_val = auto_prop_val3983 if qos_queue_refs:3984 for ln in qos_queue_refs:3985 self.add_qos_queue (ln)3986 self.dscp = dscp3987 self.trusted = trusted3988 self.id_perms = id_perms3989 self.display_name = display_name3990 #end __init__3991 def _update_links (self, update_server):3992 for ln in self.get_qos_queues ():3993 self.add_qos_queue (ln.fixture (), update_server = update_server, add_link = False)3994 return None3995 #end _update_links3996 def add_qos_queue (self, lo, update_server = True, add_link = True):3997 '''3998 add :class:`QosQueue` link to :class:`QosForwardingClass`3999 Args:4000 lo (:class:`QosQueue`): obj to link4001 '''4002 if self._obj:4003 self._obj.add_qos_queue (lo)4004 if update_server:4005 self._conn_drv.qos_forwarding_class_update (self._obj)4006 if add_link:4007 self.add_link('qos_queue', cfixture.ConrtailLink('qos_queue', 'qos_forwarding_class', 'qos_queue', ['ref'], lo))4008 #end add_qos_queue_link4009 def get_qos_queues (self):4010 return self.get_links ('qos_queue')4011 #end get_qos_queues4012 def populate (self):4013 self._obj.set_dscp(self.dscp or GeneratedsSuper.populate_integer("dscp"))4014 self._obj.set_trusted(self.trusted or GeneratedsSuper.populate_boolean("trusted"))4015 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())4016 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))4017 #end populate4018 def setUp(self):4019 super(QosForwardingClassTestFixtureGen, self).setUp()4020 if not self._parent_fixt:4021 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))4022 self._obj = vnc_api.QosForwardingClass(self._name, self._parent_fixt.getObj ())4023 try:4024 self._obj = self._conn_drv.qos_forwarding_class_read (fq_name=self._obj.get_fq_name())4025 self._update_links (update_server=True)4026 except NoIdError:4027 self._update_links (update_server=False)4028 if self._auto_prop_val:4029 self.populate ()4030 else:4031 self._obj.dscp = self.dscp4032 self._obj.trusted = self.trusted4033 self._obj.id_perms = self.id_perms4034 self._obj.display_name = self.display_name4035 self._conn_drv.qos_forwarding_class_create(self._obj)4036 # read back for server allocated values4037 self._obj = self._conn_drv.qos_forwarding_class_read(id = self._obj.uuid)4038 #end setUp4039 def cleanUp(self):4040 if self._obj.get_virtual_network_back_refs() or self._obj.get_virtual_machine_interface_back_refs():4041 return4042 parent_fixt = getattr(self, '_parent_fixt', None)4043 if parent_fixt:4044 # non config-root child4045 parent_obj = self._parent_fixt.getObj()4046 # remove child from parent obj4047 for child_obj in parent_obj.get_qos_forwarding_classs():4048 if type(child_obj) == dict:4049 child_uuid = child_obj['uuid']4050 else:4051 child_uuid = child_obj.uuid4052 if child_uuid == self._obj.uuid:4053 parent_obj.qos_forwarding_classs.remove(child_obj)4054 break4055 self._conn_drv.qos_forwarding_class_delete(id = self._obj.uuid)4056 #end cleanUp4057 def getObj(self):4058 return self._obj4059 #end getObj4060#end class QosForwardingClassTestFixtureGen4061class DatabaseNodeTestFixtureGen(cfixture.ContrailFixture):4062 """4063 Fixture for :class:`.DatabaseNode`4064 """4065 def __init__(self, conn_drv, database_node_name=None, parent_fixt=None, auto_prop_val=False, database_node_ip_address=None, id_perms=None, display_name=None):4066 '''4067 Create DatabaseNodeTestFixtureGen object4068 4069 constructor4070 Args:4071 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)4072 Kwargs:4073 database_node_name (str): Name of database_node4074 parent_fixt (:class:`.GlobalSystemConfigTestFixtureGen`): Parent fixture4075 database_node_ip_address (instance): instance of :class:`xsd:string`4076 id_perms (instance): instance of :class:`IdPermsType`4077 display_name (instance): instance of :class:`xsd:string`4078 '''4079 super(DatabaseNodeTestFixtureGen, self).__init__()4080 self._conn_drv = conn_drv4081 if not database_node_name:4082 self._name = 'default-database-node'4083 else:4084 self._name = database_node_name4085 self._obj = None4086 self._parent_fixt = parent_fixt4087 self._auto_prop_val = auto_prop_val4088 self.database_node_ip_address = database_node_ip_address4089 self.id_perms = id_perms4090 self.display_name = display_name4091 #end __init__4092 def _update_links (self, update_server):4093 return None4094 #end _update_links4095 def populate (self):4096 self._obj.set_database_node_ip_address(self.database_node_ip_address or GeneratedsSuper.populate_string("database_node_ip_address"))4097 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())4098 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))4099 #end populate4100 def setUp(self):4101 super(DatabaseNodeTestFixtureGen, self).setUp()4102 if not self._parent_fixt:4103 self._parent_fixt = self.useFixture(GlobalSystemConfigTestFixtureGen(self._conn_drv, 'default-global-system-config'))4104 self._obj = vnc_api.DatabaseNode(self._name, self._parent_fixt.getObj ())4105 try:4106 self._obj = self._conn_drv.database_node_read (fq_name=self._obj.get_fq_name())4107 self._update_links (update_server=True)4108 except NoIdError:4109 self._update_links (update_server=False)4110 if self._auto_prop_val:4111 self.populate ()4112 else:4113 self._obj.database_node_ip_address = self.database_node_ip_address4114 self._obj.id_perms = self.id_perms4115 self._obj.display_name = self.display_name4116 self._conn_drv.database_node_create(self._obj)4117 # read back for server allocated values4118 self._obj = self._conn_drv.database_node_read(id = self._obj.uuid)4119 #end setUp4120 def cleanUp(self):4121 parent_fixt = getattr(self, '_parent_fixt', None)4122 if parent_fixt:4123 # non config-root child4124 parent_obj = self._parent_fixt.getObj()4125 # remove child from parent obj4126 for child_obj in parent_obj.get_database_nodes():4127 if type(child_obj) == dict:4128 child_uuid = child_obj['uuid']4129 else:4130 child_uuid = child_obj.uuid4131 if child_uuid == self._obj.uuid:4132 parent_obj.database_nodes.remove(child_obj)4133 break4134 self._conn_drv.database_node_delete(id = self._obj.uuid)4135 #end cleanUp4136 def getObj(self):4137 return self._obj4138 #end getObj4139#end class DatabaseNodeTestFixtureGen4140class RoutingInstanceTestFixtureGen(cfixture.ContrailFixture):4141 """4142 Fixture for :class:`.RoutingInstance`4143 """4144 def __init__(self, conn_drv, routing_instance_name=None, parent_fixt=None, auto_prop_val=False, routing_instance_ref_infos = None, route_target_ref_infos = None, service_chain_information=None, routing_instance_is_default=None, static_route_entries=None, default_ce_protocol=None, id_perms=None, display_name=None):4145 '''4146 Create RoutingInstanceTestFixtureGen object4147 4148 constructor4149 Args:4150 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)4151 Kwargs:4152 routing_instance_name (str): Name of routing_instance4153 parent_fixt (:class:`.VirtualNetworkTestFixtureGen`): Parent fixture4154 routing_instance (list): list of tuple (:class:`RoutingInstance`, :class: `ConnectionType`) type4155 route_target (list): list of tuple (:class:`RouteTarget`, :class: `InstanceTargetType`) type4156 service_chain_information (instance): instance of :class:`ServiceChainInfo`4157 routing_instance_is_default (instance): instance of :class:`xsd:boolean`4158 static_route_entries (instance): instance of :class:`StaticRouteEntriesType`4159 default_ce_protocol (instance): instance of :class:`DefaultProtocolType`4160 id_perms (instance): instance of :class:`IdPermsType`4161 display_name (instance): instance of :class:`xsd:string`4162 '''4163 super(RoutingInstanceTestFixtureGen, self).__init__()4164 self._conn_drv = conn_drv4165 if not routing_instance_name:4166 self._name = 'default-routing-instance'4167 else:4168 self._name = routing_instance_name4169 self._obj = None4170 self._parent_fixt = parent_fixt4171 self._auto_prop_val = auto_prop_val4172 if routing_instance_ref_infos:4173 for ln, ref in routing_instance_ref_infos:4174 self.add_routing_instance (ln, ref)4175 if route_target_ref_infos:4176 for ln, ref in route_target_ref_infos:4177 self.add_route_target (ln, ref)4178 self.service_chain_information = service_chain_information4179 self.routing_instance_is_default = routing_instance_is_default4180 self.static_route_entries = static_route_entries4181 self.default_ce_protocol = default_ce_protocol4182 self.id_perms = id_perms4183 self.display_name = display_name4184 #end __init__4185 def _update_links (self, update_server):4186 for ln in self.get_routing_instances ():4187 self.add_routing_instance (*ln.fixture (), update_server = update_server, add_link = False)4188 for ln in self.get_route_targets ():4189 self.add_route_target (*ln.fixture (), update_server = update_server, add_link = False)4190 return None4191 #end _update_links4192 def add_routing_instance (self, lo, ref, update_server = True, add_link = True):4193 '''4194 add :class:`RoutingInstance` link to :class:`RoutingInstance`4195 Args:4196 lo (:class:`RoutingInstance`): obj to link4197 ref (:class:`ConnectionType`): property of the link object4198 '''4199 if self._obj:4200 self._obj.add_routing_instance (lo, ref)4201 if update_server:4202 self._conn_drv.routing_instance_update (self._obj)4203 if add_link:4204 self.add_link('routing_instance', cfixture.ConrtailLink('routing_instance', 'routing_instance', 'routing_instance', ['ref'], (lo, ref)))4205 #end add_routing_instance_link4206 def get_routing_instances (self):4207 return self.get_links ('routing_instance')4208 #end get_routing_instances4209 def add_route_target (self, lo, ref, update_server = True, add_link = True):4210 '''4211 add :class:`RouteTarget` link to :class:`RoutingInstance`4212 Args:4213 lo (:class:`RouteTarget`): obj to link4214 ref (:class:`InstanceTargetType`): property of the link object4215 '''4216 if self._obj:4217 self._obj.add_route_target (lo, ref)4218 if update_server:4219 self._conn_drv.routing_instance_update (self._obj)4220 if add_link:4221 self.add_link('route_target', cfixture.ConrtailLink('route_target', 'routing_instance', 'route_target', ['ref'], (lo, ref)))4222 #end add_route_target_link4223 def get_route_targets (self):4224 return self.get_links ('route_target')4225 #end get_route_targets4226 def populate (self):4227 self._obj.set_service_chain_information(self.service_chain_information or vnc_api.gen.resource_xsd.ServiceChainInfo.populate())4228 self._obj.set_routing_instance_is_default(self.routing_instance_is_default or GeneratedsSuper.populate_boolean("routing_instance_is_default"))4229 self._obj.set_static_route_entries(self.static_route_entries or vnc_api.gen.resource_xsd.StaticRouteEntriesType.populate())4230 self._obj.set_default_ce_protocol(self.default_ce_protocol or vnc_api.gen.resource_xsd.DefaultProtocolType.populate())4231 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())4232 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))4233 #end populate4234 def setUp(self):4235 super(RoutingInstanceTestFixtureGen, self).setUp()4236 if not self._parent_fixt:4237 self._parent_fixt = self.useFixture(VirtualNetworkTestFixtureGen(self._conn_drv, 'default-virtual-network'))4238 self._obj = vnc_api.RoutingInstance(self._name, self._parent_fixt.getObj ())4239 try:4240 self._obj = self._conn_drv.routing_instance_read (fq_name=self._obj.get_fq_name())4241 self._update_links (update_server=True)4242 except NoIdError:4243 self._update_links (update_server=False)4244 if self._auto_prop_val:4245 self.populate ()4246 else:4247 self._obj.service_chain_information = self.service_chain_information4248 self._obj.routing_instance_is_default = self.routing_instance_is_default4249 self._obj.static_route_entries = self.static_route_entries4250 self._obj.default_ce_protocol = self.default_ce_protocol4251 self._obj.id_perms = self.id_perms4252 self._obj.display_name = self.display_name4253 self._conn_drv.routing_instance_create(self._obj)4254 # read back for server allocated values4255 self._obj = self._conn_drv.routing_instance_read(id = self._obj.uuid)4256 #end setUp4257 def cleanUp(self):4258 if self._obj.get_virtual_machine_interface_back_refs() or self._obj.get_routing_instance_back_refs():4259 return4260 if self._obj.get_bgp_routers():4261 return4262 parent_fixt = getattr(self, '_parent_fixt', None)4263 if parent_fixt:4264 # non config-root child4265 parent_obj = self._parent_fixt.getObj()4266 # remove child from parent obj4267 for child_obj in parent_obj.get_routing_instances():4268 if type(child_obj) == dict:4269 child_uuid = child_obj['uuid']4270 else:4271 child_uuid = child_obj.uuid4272 if child_uuid == self._obj.uuid:4273 parent_obj.routing_instances.remove(child_obj)4274 break4275 self._conn_drv.routing_instance_delete(id = self._obj.uuid)4276 #end cleanUp4277 def getObj(self):4278 return self._obj4279 #end getObj4280#end class RoutingInstanceTestFixtureGen4281class NetworkIpamTestFixtureGen(cfixture.ContrailFixture):4282 """4283 Fixture for :class:`.NetworkIpam`4284 """4285 def __init__(self, conn_drv, network_ipam_name=None, parent_fixt=None, auto_prop_val=False, virtual_DNS_refs = None, network_ipam_mgmt=None, id_perms=None, display_name=None):4286 '''4287 Create NetworkIpamTestFixtureGen object4288 4289 constructor4290 Args:4291 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)4292 Kwargs:4293 network_ipam_name (str): Name of network_ipam4294 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture4295 virtual_DNS (list): list of :class:`VirtualDns` type4296 network_ipam_mgmt (instance): instance of :class:`IpamType`4297 id_perms (instance): instance of :class:`IdPermsType`4298 display_name (instance): instance of :class:`xsd:string`4299 '''4300 super(NetworkIpamTestFixtureGen, self).__init__()4301 self._conn_drv = conn_drv4302 if not network_ipam_name:4303 self._name = 'default-network-ipam'4304 else:4305 self._name = network_ipam_name4306 self._obj = None4307 self._parent_fixt = parent_fixt4308 self._auto_prop_val = auto_prop_val4309 if virtual_DNS_refs:4310 for ln in virtual_DNS_refs:4311 self.add_virtual_DNS (ln)4312 self.network_ipam_mgmt = network_ipam_mgmt4313 self.id_perms = id_perms4314 self.display_name = display_name4315 #end __init__4316 def _update_links (self, update_server):4317 for ln in self.get_virtual_DNSs ():4318 self.add_virtual_DNS (ln.fixture (), update_server = update_server, add_link = False)4319 return None4320 #end _update_links4321 def add_virtual_DNS (self, lo, update_server = True, add_link = True):4322 '''4323 add :class:`VirtualDns` link to :class:`NetworkIpam`4324 Args:4325 lo (:class:`VirtualDns`): obj to link4326 '''4327 if self._obj:4328 self._obj.add_virtual_DNS (lo)4329 if update_server:4330 self._conn_drv.network_ipam_update (self._obj)4331 if add_link:4332 self.add_link('virtual_DNS', cfixture.ConrtailLink('virtual_DNS', 'network_ipam', 'virtual_DNS', ['ref'], lo))4333 #end add_virtual_DNS_link4334 def get_virtual_DNSs (self):4335 return self.get_links ('virtual_DNS')4336 #end get_virtual_DNSs4337 def populate (self):4338 self._obj.set_network_ipam_mgmt(self.network_ipam_mgmt or vnc_api.gen.resource_xsd.IpamType.populate())4339 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())4340 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))4341 #end populate4342 def setUp(self):4343 super(NetworkIpamTestFixtureGen, self).setUp()4344 if not self._parent_fixt:4345 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))4346 self._obj = vnc_api.NetworkIpam(self._name, self._parent_fixt.getObj ())4347 try:4348 self._obj = self._conn_drv.network_ipam_read (fq_name=self._obj.get_fq_name())4349 self._update_links (update_server=True)4350 except NoIdError:4351 self._update_links (update_server=False)4352 if self._auto_prop_val:4353 self.populate ()4354 else:4355 self._obj.network_ipam_mgmt = self.network_ipam_mgmt4356 self._obj.id_perms = self.id_perms4357 self._obj.display_name = self.display_name4358 self._conn_drv.network_ipam_create(self._obj)4359 # read back for server allocated values4360 self._obj = self._conn_drv.network_ipam_read(id = self._obj.uuid)4361 #end setUp4362 def cleanUp(self):4363 if self._obj.get_virtual_network_back_refs():4364 return4365 parent_fixt = getattr(self, '_parent_fixt', None)4366 if parent_fixt:4367 # non config-root child4368 parent_obj = self._parent_fixt.getObj()4369 # remove child from parent obj4370 for child_obj in parent_obj.get_network_ipams():4371 if type(child_obj) == dict:4372 child_uuid = child_obj['uuid']4373 else:4374 child_uuid = child_obj.uuid4375 if child_uuid == self._obj.uuid:4376 parent_obj.network_ipams.remove(child_obj)4377 break4378 self._conn_drv.network_ipam_delete(id = self._obj.uuid)4379 #end cleanUp4380 def getObj(self):4381 return self._obj4382 #end getObj4383#end class NetworkIpamTestFixtureGen4384class LogicalRouterTestFixtureGen(cfixture.ContrailFixture):4385 """4386 Fixture for :class:`.LogicalRouter`4387 """4388 def __init__(self, conn_drv, logical_router_name=None, parent_fixt=None, auto_prop_val=False, virtual_machine_interface_refs = None, route_target_refs = None, virtual_network_refs = None, service_instance_refs = None, id_perms=None, display_name=None):4389 '''4390 Create LogicalRouterTestFixtureGen object4391 4392 constructor4393 Args:4394 conn_drv (:class:`ConnectionDriver`): connection driver (eg. :class:`vnc_api.vnc_api.VncApi`, :class:`novaclient.client.Client`, etc)4395 Kwargs:4396 logical_router_name (str): Name of logical_router4397 parent_fixt (:class:`.ProjectTestFixtureGen`): Parent fixture4398 virtual_machine_interface (list): list of :class:`VirtualMachineInterface` type4399 route_target (list): list of :class:`RouteTarget` type4400 virtual_network (list): list of :class:`VirtualNetwork` type4401 service_instance (list): list of :class:`ServiceInstance` type4402 id_perms (instance): instance of :class:`IdPermsType`4403 display_name (instance): instance of :class:`xsd:string`4404 '''4405 super(LogicalRouterTestFixtureGen, self).__init__()4406 self._conn_drv = conn_drv4407 if not logical_router_name:4408 self._name = 'default-logical-router'4409 else:4410 self._name = logical_router_name4411 self._obj = None4412 self._parent_fixt = parent_fixt4413 self._auto_prop_val = auto_prop_val4414 if virtual_machine_interface_refs:4415 for ln in virtual_machine_interface_refs:4416 self.add_virtual_machine_interface (ln)4417 if route_target_refs:4418 for ln in route_target_refs:4419 self.add_route_target (ln)4420 if virtual_network_refs:4421 for ln in virtual_network_refs:4422 self.add_virtual_network (ln)4423 if service_instance_refs:4424 for ln in service_instance_refs:4425 self.add_service_instance (ln)4426 self.id_perms = id_perms4427 self.display_name = display_name4428 #end __init__4429 def _update_links (self, update_server):4430 for ln in self.get_virtual_machine_interfaces ():4431 self.add_virtual_machine_interface (ln.fixture (), update_server = update_server, add_link = False)4432 for ln in self.get_route_targets ():4433 self.add_route_target (ln.fixture (), update_server = update_server, add_link = False)4434 for ln in self.get_virtual_networks ():4435 self.add_virtual_network (ln.fixture (), update_server = update_server, add_link = False)4436 for ln in self.get_service_instances ():4437 self.add_service_instance (ln.fixture (), update_server = update_server, add_link = False)4438 return None4439 #end _update_links4440 def add_virtual_machine_interface (self, lo, update_server = True, add_link = True):4441 '''4442 add :class:`VirtualMachineInterface` link to :class:`LogicalRouter`4443 Args:4444 lo (:class:`VirtualMachineInterface`): obj to link4445 '''4446 if self._obj:4447 self._obj.add_virtual_machine_interface (lo)4448 if update_server:4449 self._conn_drv.logical_router_update (self._obj)4450 if add_link:4451 self.add_link('virtual_machine_interface', cfixture.ConrtailLink('virtual_machine_interface', 'logical_router', 'virtual_machine_interface', ['ref'], lo))4452 #end add_virtual_machine_interface_link4453 def get_virtual_machine_interfaces (self):4454 return self.get_links ('virtual_machine_interface')4455 #end get_virtual_machine_interfaces4456 def add_route_target (self, lo, update_server = True, add_link = True):4457 '''4458 add :class:`RouteTarget` link to :class:`LogicalRouter`4459 Args:4460 lo (:class:`RouteTarget`): obj to link4461 '''4462 if self._obj:4463 self._obj.add_route_target (lo)4464 if update_server:4465 self._conn_drv.logical_router_update (self._obj)4466 if add_link:4467 self.add_link('route_target', cfixture.ConrtailLink('route_target', 'logical_router', 'route_target', ['ref'], lo))4468 #end add_route_target_link4469 def get_route_targets (self):4470 return self.get_links ('route_target')4471 #end get_route_targets4472 def add_virtual_network (self, lo, update_server = True, add_link = True):4473 '''4474 add :class:`VirtualNetwork` link to :class:`LogicalRouter`4475 Args:4476 lo (:class:`VirtualNetwork`): obj to link4477 '''4478 if self._obj:4479 self._obj.add_virtual_network (lo)4480 if update_server:4481 self._conn_drv.logical_router_update (self._obj)4482 if add_link:4483 self.add_link('virtual_network', cfixture.ConrtailLink('virtual_network', 'logical_router', 'virtual_network', ['ref'], lo))4484 #end add_virtual_network_link4485 def get_virtual_networks (self):4486 return self.get_links ('virtual_network')4487 #end get_virtual_networks4488 def add_service_instance (self, lo, update_server = True, add_link = True):4489 '''4490 add :class:`ServiceInstance` link to :class:`LogicalRouter`4491 Args:4492 lo (:class:`ServiceInstance`): obj to link4493 '''4494 if self._obj:4495 self._obj.add_service_instance (lo)4496 if update_server:4497 self._conn_drv.logical_router_update (self._obj)4498 if add_link:4499 self.add_link('service_instance', cfixture.ConrtailLink('service_instance', 'logical_router', 'service_instance', ['ref'], lo))4500 #end add_service_instance_link4501 def get_service_instances (self):4502 return self.get_links ('service_instance')4503 #end get_service_instances4504 def populate (self):4505 self._obj.set_id_perms(self.id_perms or vnc_api.gen.resource_xsd.IdPermsType.populate())4506 self._obj.set_display_name(self.display_name or GeneratedsSuper.populate_string("display_name"))4507 #end populate4508 def setUp(self):4509 super(LogicalRouterTestFixtureGen, self).setUp()4510 if not self._parent_fixt:4511 self._parent_fixt = self.useFixture(ProjectTestFixtureGen(self._conn_drv, 'default-project'))4512 self._obj = vnc_api.LogicalRouter(self._name, self._parent_fixt.getObj ())4513 try:4514 self._obj = self._conn_drv.logical_router_read (fq_name=self._obj.get_fq_name())4515 self._update_links (update_server=True)4516 except NoIdError:4517 self._update_links (update_server=False)4518 if self._auto_prop_val:4519 self.populate ()4520 else:4521 self._obj.id_perms = self.id_perms4522 self._obj.display_name = self.display_name4523 self._conn_drv.logical_router_create(self._obj)4524 # read back for server allocated values4525 self._obj = self._conn_drv.logical_router_read(id = self._obj.uuid)4526 #end setUp4527 def cleanUp(self):4528 parent_fixt = getattr(self, '_parent_fixt', None)4529 if parent_fixt:4530 # non config-root child4531 parent_obj = self._parent_fixt.getObj()4532 # remove child from parent obj4533 for child_obj in parent_obj.get_logical_routers():4534 if type(child_obj) == dict:4535 child_uuid = child_obj['uuid']4536 else:4537 child_uuid = child_obj.uuid4538 if child_uuid == self._obj.uuid:4539 parent_obj.logical_routers.remove(child_obj)4540 break4541 self._conn_drv.logical_router_delete(id = self._obj.uuid)4542 #end cleanUp4543 def getObj(self):4544 return self._obj4545 #end getObj...

Full Screen

Full Screen

updater.py

Source:updater.py Github

copy

Full Screen

...21 if new_version > self.buildid:22 self.exit()23 logger.info("Update found")24 self._broadcast("Update found. The server will be updated as soon as all players have left the server")25 self.update_server()26 self.buildid = new_version27 self.run(first=False)28 else:29 logger.info("No update found")30 31 def run(self, first=True):32 if first:33 if not server_online((self.address, self.queryport)):34 self.update_server(False)35 self.buildid = get_version(self.steamcmd)36 while not server_online((self.address, self.queryport)): # wait for server to come alive37 time.sleep(self.sleep)38 self.exit = loop(self.check_for_updates, hours=1)39 @property40 def address(self):41 return self.config.get('server', 'address')42 @property43 def queryport(self):44 return self.config.getint("server", "queryport")45 @property46 def rconport(self):47 return self.config.getint("server", "rconport")48 @property49 def steamcmd(self):50 return self.config.get('paths', 'steamcmdpath')51 @property52 def arkfolder(self):53 return self.config.get('paths', 'arkfolder')54 @property55 def password(self):56 return self.config.get("server", "password")57 @property58 def buildid(self):59 return self.config.getint("updater", "buildid")60 @buildid.setter61 def buildid(self, value):62 if type(value) != int:63 raise ValueError()64 self.config.set("updater", "buildid", str(value))65 self.config.save_to_file()66 def _broadcast(self, message):67 broadcast(message, (self.address, self.rconport), self.password)68 def update_server(self, online=True):69 if online:70 while get_num_players((self.address, self.queryport)) >= 1:71 time.sleep(self.sleep)72 stop_server((self.address, self.rconport), self.password)73 # give some time for the server to stop74 time.sleep(10)75 update_server(self.steamcmd, self.arkfolder)...

Full Screen

Full Screen

test_server.py

Source:test_server.py Github

copy

Full Screen

...10 server.add_user(2)11 return server12def test_is_finished(server_max_user):13 assert server_max_user.is_finished() == False14 server_max_user.update_server()15 server_max_user.update_server()16 server_max_user.update_server()17 assert server_max_user.is_finished() == True18def test_calculate(base_server, server_max_user):19 base_server.calculate()20 assert base_server.get_total_cost() == 021 server_max_user.calculate()22 assert server_max_user.get_total_cost() == 123def test_user_connect(base_server, server_max_user):24 assert base_server.user_connect() == 025 assert server_max_user.user_connect() == 226def test_add_user(base_server, server_max_user):27 assert base_server.add_user(4) == True28 assert server_max_user.add_user(4) == False29def test_remove_user(base_server, server_max_user):30 server_max_user.update_server()31 server_max_user.update_server()32 server_max_user.update_server()33 assert server_max_user.user_connect() == 034 base_server.remove_user()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful