def add_netscaler(apiclient, zoneid, NSservice): """ Adds Netscaler device and enables NS provider""" cmd = listPhysicalNetworks.listPhysicalNetworksCmd() cmd.zoneid = zoneid physical_networks = apiclient.listPhysicalNetworks(cmd) if isinstance(physical_networks, list): physical_network = physical_networks[0] cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd() cmd.name = "Netscaler" cmd.physicalnetworkid = physical_network.id nw_service_providers = apiclient.listNetworkServiceProviders(cmd) if isinstance(nw_service_providers, list): netscaler_provider = nw_service_providers[0] else: cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd() cmd1.name = "Netscaler" cmd1.physicalnetworkid = physical_network.id netscaler_provider = apiclient.addNetworkServiceProvider(cmd1) netscaler = NetScaler.add(apiclient, NSservice, physicalnetworkid=physical_network.id) if netscaler_provider.state != "Enabled": cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd() cmd.id = netscaler_provider.id cmd.state = "Enabled" apiclient.updateNetworkServiceProvider(cmd) return netscaler
def add_netscaler(apiclient, zoneid, NSservice): """ Adds Netscaler device and enables NS provider""" cmd = listPhysicalNetworks.listPhysicalNetworksCmd() cmd.zoneid = zoneid physical_networks = apiclient.listPhysicalNetworks(cmd) if isinstance(physical_networks, list): physical_network = physical_networks[0] cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd() cmd.name = 'Netscaler' cmd.physicalnetworkid = physical_network.id nw_service_providers = apiclient.listNetworkServiceProviders(cmd) if isinstance(nw_service_providers, list): netscaler_provider = nw_service_providers[0] else: cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd() cmd1.name = 'Netscaler' cmd1.physicalnetworkid = physical_network.id netscaler_provider = apiclient.addNetworkServiceProvider(cmd1) netscaler = NetScaler.add( apiclient, NSservice, physicalnetworkid=physical_network.id ) if netscaler_provider.state != 'Enabled': cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd() cmd.id = netscaler_provider.id cmd.state = 'Enabled' apiclient.updateNetworkServiceProvider(cmd) return netscaler
def test_01_list_sec_storage_vm(self): """Test List secondary storage VMs """ # Validate the following: # 1. listSystemVM (systemvmtype=secondarystoragevm) # should return only ONE SSVM per zone # 2. The returned SSVM should be in Running state # 3. listSystemVM for secondarystoragevm should list publicip, # privateip and link-localip # 4. The gateway programmed on the ssvm by listSystemVm should be # the same as the gateway returned by listVlanIpRanges # 5. DNS entries must match those given for the zone list_ssvm_response = list_ssvms( self.apiclient, systemvmtype='secondarystoragevm', state='Running', ) self.assertEqual( isinstance(list_ssvm_response, list), True, "Check list response returns a valid list" ) # Verify SSVM response self.assertNotEqual( len(list_ssvm_response), 0, "Check list System VMs response" ) list_zones_response = list_zones(self.apiclient) self.assertEqual( isinstance(list_zones_response, list), True, "Check list response returns a valid list" ) self.debug("Number of zones: %s" % len(list_zones_response)) self.debug("Number of SSVMs: %s" % len(list_ssvm_response)) # Number of Sec storage VMs = No of Zones self.assertEqual( len(list_ssvm_response), len(list_zones_response), "Check number of SSVMs with number of zones" ) # For each secondary storage VM check private IP, # public IP, link local IP and DNS for ssvm in list_ssvm_response: self.debug("SSVM state: %s" % ssvm.state) self.assertEqual( ssvm.state, 'Running', "Check whether state of SSVM is running" ) self.assertEqual( hasattr(ssvm, 'privateip'), True, "Check whether SSVM has private IP field" ) self.assertEqual( hasattr(ssvm, 'linklocalip'), True, "Check whether SSVM has link local IP field" ) self.assertEqual( hasattr(ssvm, 'publicip'), True, "Check whether SSVM has public IP field" ) # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges( self.apiclient, zoneid=ssvm.zoneid ) self.assertEqual( isinstance(ipranges_response, list), True, "Check list response returns a valid list" ) iprange = ipranges_response[0] # Fetch corresponding Physical Network of SSVM's Zone listphyntwk = PhysicalNetwork.list( self.apiclient, zoneid=ssvm.zoneid ) # Execute the following assertion in all zones except EIP-ELB Zones if not ( self.zone.networktype.lower() == 'basic' and isinstance( NetScaler.list( self.apiclient, physicalnetworkid=listphyntwk[0].id), list) is True): self.assertEqual( ssvm.gateway, iprange.gateway, "Check gateway with that of corresponding ip range" ) # Fetch corresponding zone information from listZones zone_response = list_zones( self.apiclient, id=ssvm.zoneid ) self.assertEqual( isinstance(zone_response, list), True, "Check list response returns a valid list" ) self.assertEqual( ssvm.dns1, zone_response[0].dns1, "Check DNS1 with that of corresponding zone" ) self.assertEqual( ssvm.dns2, zone_response[0].dns2, "Check DNS2 with that of corresponding zone" ) return
def test_01_list_sec_storage_vm(self): """Test List secondary storage VMs """ # Validate the following: # 1. listSystemVM (systemvmtype=secondarystoragevm) # should return only ONE SSVM per zone # 2. The returned SSVM should be in Running state # 3. listSystemVM for secondarystoragevm should list publicip, # privateip and link-localip # 4. The gateway programmed on the ssvm by listSystemVm should be # the same as the gateway returned by listVlanIpRanges # 5. DNS entries must match those given for the zone list_ssvm_response = list_ssvms( self.apiclient, systemvmtype='secondarystoragevm', state='Running', ) self.assertEqual(isinstance(list_ssvm_response, list), True, "Check list response returns a valid list") # Verify SSVM response self.assertNotEqual(len(list_ssvm_response), 0, "Check list System VMs response") list_zones_response = list_zones(self.apiclient) self.assertEqual(isinstance(list_zones_response, list), True, "Check list response returns a valid list") self.debug("Number of zones: %s" % len(list_zones_response)) self.debug("Number of SSVMs: %s" % len(list_ssvm_response)) # Number of Sec storage VMs = No of Zones self.assertEqual(len(list_ssvm_response), len(list_zones_response), "Check number of SSVMs with number of zones") # For each secondary storage VM check private IP, # public IP, link local IP and DNS for ssvm in list_ssvm_response: self.debug("SSVM state: %s" % ssvm.state) self.assertEqual(ssvm.state, 'Running', "Check whether state of SSVM is running") self.assertEqual(hasattr(ssvm, 'privateip'), True, "Check whether SSVM has private IP field") self.assertEqual(hasattr(ssvm, 'linklocalip'), True, "Check whether SSVM has link local IP field") self.assertEqual(hasattr(ssvm, 'publicip'), True, "Check whether SSVM has public IP field") # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges(self.apiclient, zoneid=ssvm.zoneid) self.assertEqual(isinstance(ipranges_response, list), True, "Check list response returns a valid list") iprange = ipranges_response[0] # Fetch corresponding Physical Network of SSVM's Zone listphyntwk = PhysicalNetwork.list(self.apiclient, zoneid=ssvm.zoneid) # Execute the following assertion in all zones except EIP-ELB Zones if not (self.zone.networktype.lower() == 'basic' and isinstance( NetScaler.list(self.apiclient, physicalnetworkid=listphyntwk[0].id), list) is True): self.assertEqual( ssvm.gateway, iprange.gateway, "Check gateway with that of corresponding ip range") # Fetch corresponding zone information from listZones zone_response = list_zones(self.apiclient, id=ssvm.zoneid) self.assertEqual(isinstance(zone_response, list), True, "Check list response returns a valid list") self.assertEqual(ssvm.dns1, zone_response[0].dns1, "Check DNS1 with that of corresponding zone") self.assertEqual(ssvm.dns2, zone_response[0].dns2, "Check DNS2 with that of corresponding zone") return
def test_02_list_cpvm_vm(self): """Test List console proxy VMs """ # Validate the following: # 1. listSystemVM (systemvmtype=consoleproxy) should return # at least ONE CPVM per zone # 2. The returned ConsoleProxyVM should be in Running state # 3. listSystemVM for console proxy should list publicip, privateip # and link-localip # 4. The gateway programmed on the console proxy should be the same # as the gateway returned by listZones # 5. DNS entries must match those given for the zone list_cpvm_response = list_ssvms( self.apiclient, systemvmtype='consoleproxy', state='Running', ) self.assertEqual(isinstance(list_cpvm_response, list), True, "Check list response returns a valid list") # Verify CPVM response self.assertNotEqual(len(list_cpvm_response), 0, "Check list System VMs response") list_zones_response = list_zones(self.apiclient) # Number of Console Proxy VMs = No of Zones self.assertEqual(isinstance(list_zones_response, list), True, "Check list response returns a valid list") self.debug("Number of zones: %s" % len(list_zones_response)) self.debug("Number of CPVMs: %s" % len(list_cpvm_response)) self.assertEqual(len(list_cpvm_response), len(list_zones_response), "Check number of CPVMs with number of zones") # For each CPVM check private IP, public IP, link local IP and DNS for cpvm in list_cpvm_response: self.debug("CPVM state: %s" % cpvm.state) self.assertEqual(cpvm.state, 'Running', "Check whether state of CPVM is running") self.assertEqual(hasattr(cpvm, 'privateip'), True, "Check whether CPVM has private IP field") self.assertEqual(hasattr(cpvm, 'linklocalip'), True, "Check whether CPVM has link local IP field") self.assertEqual(hasattr(cpvm, 'publicip'), True, "Check whether CPVM has public IP field") # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges(self.apiclient, zoneid=cpvm.zoneid) self.assertEqual(isinstance(ipranges_response, list), True, "Check list response returns a valid list") # Fetch corresponding Physical Network of SSVM's Zone listphyntwk = PhysicalNetwork.list(self.apiclient, zoneid=cpvm.zoneid) # Execute the following assertion in all zones except EIP-ELB Zones if not (self.zone.networktype.lower() == 'basic' and isinstance( NetScaler.list(self.apiclient, physicalnetworkid=listphyntwk[0].id), list) is True): gatewayFound = False for iprange in ipranges_response: if iprange.gateway == cpvm.gateway: gatewayFound = True break self.assertTrue( gatewayFound, "Check gateway with that of corresponding ip range") # Fetch corresponding zone information from listZones zone_response = list_zones(self.apiclient, id=cpvm.zoneid) self.assertEqual(cpvm.dns1, zone_response[0].dns1, "Check DNS1 with that of corresponding zone") self.assertEqual(cpvm.dns2, zone_response[0].dns2, "Check DNS2 with that of corresponding zone")
def test_02_list_cpvm_vm(self): """Test List console proxy VMs """ # Validate the following: # 1. listSystemVM (systemvmtype=consoleproxy) should return # at least ONE CPVM per zone # 2. The returned ConsoleProxyVM should be in Running state # 3. listSystemVM for console proxy should list publicip, privateip # and link-localip # 4. The gateway programmed on the console proxy should be the same # as the gateway returned by listZones # 5. DNS entries must match those given for the zone list_cpvm_response = list_ssvms( self.apiclient, systemvmtype='consoleproxy', state='Running', ) self.assertEqual( isinstance(list_cpvm_response, list), True, "Check list response returns a valid list" ) # Verify CPVM response self.assertNotEqual( len(list_cpvm_response), 0, "Check list System VMs response" ) list_zones_response = list_zones(self.apiclient) # Number of Console Proxy VMs = No of Zones self.assertEqual( isinstance(list_zones_response, list), True, "Check list response returns a valid list" ) self.debug("Number of zones: %s" % len(list_zones_response)) self.debug("Number of CPVMs: %s" % len(list_cpvm_response)) self.assertEqual( len(list_cpvm_response), len(list_zones_response), "Check number of CPVMs with number of zones" ) # For each CPVM check private IP, public IP, link local IP and DNS for cpvm in list_cpvm_response: self.debug("CPVM state: %s" % cpvm.state) self.assertEqual( cpvm.state, 'Running', "Check whether state of CPVM is running" ) self.assertEqual( hasattr(cpvm, 'privateip'), True, "Check whether CPVM has private IP field" ) self.assertEqual( hasattr(cpvm, 'linklocalip'), True, "Check whether CPVM has link local IP field" ) self.assertEqual( hasattr(cpvm, 'publicip'), True, "Check whether CPVM has public IP field" ) # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges( self.apiclient, zoneid=cpvm.zoneid ) self.assertEqual( isinstance(ipranges_response, list), True, "Check list response returns a valid list" ) # Fetch corresponding Physical Network of SSVM's Zone listphyntwk = PhysicalNetwork.list( self.apiclient, zoneid=cpvm.zoneid ) # Execute the following assertion in all zones except EIP-ELB Zones if not ( self.zone.networktype.lower() == 'basic' and isinstance( NetScaler.list( self.apiclient, physicalnetworkid=listphyntwk[0].id), list) is True): gatewayFound = False for iprange in ipranges_response: if iprange.gateway == cpvm.gateway: gatewayFound = True break self.assertTrue( gatewayFound, "Check gateway with that of corresponding ip range" ) # Fetch corresponding zone information from listZones zone_response = list_zones( self.apiclient, id=cpvm.zoneid ) self.assertEqual( cpvm.dns1, zone_response[0].dns1, "Check DNS1 with that of corresponding zone" ) self.assertEqual( cpvm.dns2, zone_response[0].dns2, "Check DNS2 with that of corresponding zone" )