def test_05_router_basic(self): """Test router basic setup """ # Validate the following: # 1. verify that listRouters returned a 'Running' router # 2. router will have dns same as that seen in listZones # 3. router will have a guestIP and a linkLocalIp" list_router_response = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_router_response, list), True, "Check list response returns a valid list") self.assertNotEqual(len(list_router_response), 0, "Check list router response") for router in list_router_response: self.assertEqual(router.state, 'Running', "Check list router response for router state") zones = list_zones(self.apiclient, id=router.zoneid) self.assertEqual(isinstance(zones, list), True, "Check list response returns a valid list") zone = zones[0] self.assertEqual(router.dns1, zone.dns1, "Compare DNS1 of router and zone") self.assertEqual(router.dns2, zone.dns2, "Compare DNS2 of router and zone") self.assertEqual(hasattr(router, 'guestipaddress'), True, "Check whether router has guest IP field") self.assertEqual(hasattr(router, 'linklocalip'), True, "Check whether router has link local IP field") return
def test_06_router_advanced(self): """Test router advanced setup """ # Validate the following # 1. verify that listRouters returned a 'Running' router # 2. router will have dns and gateway as in listZones, listVlanIpRanges # 3. router will have guest,public and linklocal IPs list_router_response = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_router_response, list), True, "Check list response returns a valid list") self.assertNotEqual(len(list_router_response), 0, "Check list router response") for router in list_router_response: self.assertEqual(router.state, 'Running', "Check list router response for router state") zones = list_zones(self.apiclient, id=router.zoneid) self.assertEqual(isinstance(zones, list), True, "Check list response returns a valid list") zone = zones[0] self.assertEqual(router.dns1, zone.dns1, "Compare DNS1 of router and zone") self.assertEqual(router.dns2, zone.dns2, "Compare DNS2 of router and zone") self.assertEqual(hasattr(router, 'guestipaddress'), True, "Check whether router has guest IP field") self.assertEqual(hasattr(router, 'linklocalip'), True, "Check whether router has link local IP field") # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges(self.apiclient, zoneid=router.zoneid) self.assertEqual(isinstance(ipranges_response, list), True, "Check list response returns a valid list") iprange = ipranges_response[0] self.assertEqual( router.gateway, iprange.gateway, "Check gateway with that of corresponding IP range") 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 setUpCloudStack(cls): cls.spapi = spapi.Api.fromConfig(multiCluster=True) testClient = super(TestMigrateVMWithVolumes, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() storpool_primary_storage = cls.testdata[TestData.primaryStorage] cls.template_name = storpool_primary_storage.get("name") storpool_service_offerings = cls.testdata[TestData.serviceOffering] nfs_service_offerings = cls.testdata[TestData.serviceOfferingsPrimary] ceph_service_offerings = cls.testdata[TestData.serviceOfferingsCeph] nfs_disk_offerings = cls.testdata[TestData.nfsDiskOffering] ceph_disk_offerings = cls.testdata[TestData.cephDiskOffering] storage_pool = list_storage_pools(cls.apiclient, name=cls.template_name) nfs_storage_pool = list_storage_pools(cls.apiclient, name='primary') ceph_primary_storage = cls.testdata[TestData.primaryStorage4] cls.ceph_storage_pool = list_storage_pools( cls.apiclient, name=ceph_primary_storage.get("name"))[0] service_offerings = list_service_offering(cls.apiclient, name=cls.template_name) nfs_service_offering = list_service_offering(cls.apiclient, name='nfs') ceph_service_offering = list_service_offering( cls.apiclient, name=ceph_primary_storage.get("name")) if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) if service_offerings is None: service_offerings = ServiceOffering.create( cls.apiclient, storpool_service_offerings) else: service_offerings = service_offerings[0] if nfs_service_offering is None: nfs_service_offering = ServiceOffering.create( cls.apiclient, nfs_service_offerings) else: nfs_service_offering = nfs_service_offering[0] if ceph_service_offering is None: ceph_service_offering = ServiceOffering.create( cls.apiclient, ceph_service_offerings) else: ceph_service_offering = ceph_service_offering[0] nfs_disk_offering = list_disk_offering(cls.apiclient, name="nfs") if nfs_disk_offering is None: nfs_disk_offering = DiskOffering.create(cls.apiclient, nfs_disk_offerings) else: cls.nfs_disk_offering = nfs_disk_offering[0] ceph_disk_offering = list_disk_offering(cls.apiclient, name="ceph") if ceph_disk_offering is None: cls.ceph_disk_offering = DiskOffering.create( cls.apiclient, ceph_disk_offerings) else: cls.ceph_disk_offering = ceph_disk_offering[0] template = get_template(cls.apiclient, cls.zone.id, account="system") cls.nfs_storage_pool = nfs_storage_pool[0] if cls.nfs_storage_pool.state == "Maintenance": cls.nfs_storage_pool = StoragePool.cancelMaintenance( cls.apiclient, cls.nfs_storage_pool.id) if cls.ceph_storage_pool.state == "Maintenance": cls.ceph_storage_pool = StoragePool.cancelMaintenance( cls.apiclient, cls.ceph_storage_pool.id) cls.account = cls.helper.create_account(cls.apiclient, cls.services["account"], accounttype=1, domainid=cls.domain.id, roleid=1) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid, id=securitygroup.id) cls.vm = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=nfs_service_offering.id, diskofferingid=cls.nfs_disk_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls.vm2 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=ceph_service_offering.id, diskofferingid=cls.ceph_disk_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls.debug(pprint.pformat(template)) cls.debug(pprint.pformat(cls.hypervisor)) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.service_offering = service_offerings cls.nfs_service_offering = nfs_service_offering cls.debug(pprint.pformat(cls.service_offering)) cls.template = template cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def test_06_router_advanced(self): """Test router advanced setup """ # Validate the following # 1. verify that listRouters returned a 'Running' router # 2. router will have dns and gateway as in listZones, listVlanIpRanges # 3. router will have guest,public and linklocal IPs list_router_response = list_routers( self.apiclient, account=self.account.name, domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_router_response), 0, "Check list router response" ) for router in list_router_response: self.assertEqual( router.state, 'Running', "Check list router response for router state" ) zones = list_zones( self.apiclient, id=router.zoneid ) self.assertEqual( isinstance(zones, list), True, "Check list response returns a valid list" ) zone = zones[0] self.assertEqual( router.dns1, zone.dns1, "Compare DNS1 of router and zone" ) self.assertEqual( router.dns2, zone.dns2, "Compare DNS2 of router and zone" ) self.assertEqual( hasattr(router, 'guestipaddress'), True, "Check whether router has guest IP field" ) self.assertEqual( hasattr(router, 'linklocalip'), True, "Check whether router has link local IP field" ) # Fetch corresponding ip ranges information from listVlanIpRanges ipranges_response = list_vlan_ipranges( self.apiclient, zoneid=router.zoneid ) self.assertEqual( isinstance(ipranges_response, list), True, "Check list response returns a valid list" ) iprange = ipranges_response[0] self.assertEqual( router.gateway, iprange.gateway, "Check gateway with that of corresponding IP range" ) return
def test_05_router_basic(self): """Test router basic setup """ # Validate the following: # 1. verify that listRouters returned a 'Running' router # 2. router will have dns same as that seen in listZones # 3. router will have a guestIP and a linkLocalIp" list_router_response = list_routers( self.apiclient, account=self.account.name, domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_router_response), 0, "Check list router response" ) for router in list_router_response: self.assertEqual( router.state, 'Running', "Check list router response for router state" ) zones = list_zones( self.apiclient, id=router.zoneid ) self.assertEqual( isinstance(zones, list), True, "Check list response returns a valid list" ) zone = zones[0] self.assertEqual( router.dns1, zone.dns1, "Compare DNS1 of router and zone" ) self.assertEqual( router.dns2, zone.dns2, "Compare DNS2 of router and zone" ) self.assertEqual( hasattr(router, 'guestipaddress'), True, "Check whether router has guest IP field" ) self.assertEqual( hasattr(router, 'linklocalip'), True, "Check whether router has link local IP field" ) return
def setUpCloudStack(cls): super(TestRenameObjectsWithUuids, cls).setUpClass() cls.spapi = spapi.Api.fromConfig(multiCluster=True) cls.helper = HelperUtil(cls) cls._cleanup = [] testClient = super(TestRenameObjectsWithUuids, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z storpool_primary_storage = { "name" : "ssd", "zoneid": cls.zone.id, "url": "ssd", "scope": "zone", "capacitybytes": 4500000, "capacityiops": 155466464221111121, "hypervisor": "kvm", "provider": "StorPool", "tags": "ssd" } storpool_service_offerings = { "name": "ssd", "displaytext": "SP_CO_2 (Min IOPS = 10,000; Max IOPS = 15,000)", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "hypervisorsnapshotreserve": 200, "tags": "ssd" } storage_pool = list_storage_pools( cls.apiclient, name='ssd' ) service_offerings = list_service_offering( cls.apiclient, name='ssd' ) disk_offerings = list_disk_offering( cls.apiclient, name="Small" ) disk_offering_20 = list_disk_offering( cls.apiclient, name="Medium" ) disk_offering_100 = list_disk_offering( cls.apiclient, name="Large" ) cls.disk_offering = disk_offerings[0] cls.disk_offering_20 = disk_offering_20[0] cls.disk_offering_100 = disk_offering_100[0] cls.debug(pprint.pformat(storage_pool)) if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) if service_offerings is None: service_offerings = ServiceOffering.create(cls.apiclient, storpool_service_offerings) else: service_offerings = service_offerings[0] #The version of CentOS has to be supported template = get_template( cls.apiclient, cls.zone.id, account = "system" ) cls.pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id) cls.debug(pprint.pformat(template)) cls.debug(pprint.pformat(cls.hypervisor)) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.service_offering = service_offerings cls.debug(pprint.pformat(cls.service_offering)) cls.local_cluster = cls.get_local_cluster(zoneid = cls.zone.id) cls.host = cls.list_hosts_by_cluster_id(cls.local_cluster.id) assert len(cls.host) > 1, "Hosts list is less than 1" cls.host_on_local_1 = cls.host[0] cls.host_on_local_2 = cls.host[1] cls.remote_cluster = cls.get_remote_cluster(zoneid = cls.zone.id) cls.host_remote = cls.list_hosts_by_cluster_id(cls.remote_cluster.id) assert len(cls.host_remote) > 1, "Hosts list is less than 1" cls.host_on_remote1 = cls.host_remote[0] cls.host_on_remote2 = cls.host_remote[1] cls.volume_1 = Volume.create( cls.apiclient, {"diskname":"StorPoolDisk-1" }, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id, ) cls._cleanup.append(cls.volume_1) cls.volume = Volume.create( cls.apiclient, {"diskname":"StorPoolDisk-3" }, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id, ) cls._cleanup.append(cls.volume) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, hostid = cls.host_on_local_1.id, rootdisksize=10 ) cls.volume_on_remote = Volume.create( cls.apiclient, {"diskname":"StorPoolDisk-3" }, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id, ) cls._cleanup.append(cls.volume_on_remote) cls.virtual_machine_on_remote = VirtualMachine.create( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, hostid = cls.host_on_remote1.id, rootdisksize=10 ) cls.template = template cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" 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_03_copy_template(self): """Test secondary storage counts in multiple child domains # Steps 1. Create a parent domain and two sub-domains in it (also admin accounts of each domain) Repeat following steps for both the child domains 2. Register template in child domain 3. Check if the resource count for domain is updated correctly 4. Copy template to other zone 5. Verify that secondary storage count for the domain is doubled as there are two templates now """ zones = list_zones(self.apiclient) self.assertEqual(validateList(zones)[0], PASS, "zones list validation faield") if len(zones) < 2: self.skipTest("At least 2 zones should be present for this test case") users = None # Setting up account and domain hierarchy result = self.setupAccounts() self.assertEqual(result[0], PASS, result[1]) users = result[2] for domain, admin in users.items(): self.account = admin self.domain = domain try: builtin_info = get_builtin_template_info(self.apiclient, self.zone.id) self.services["template_2"]["url"] = builtin_info[0] self.services["template_2"]["hypervisor"] = builtin_info[1] self.services["template_2"]["format"] = builtin_info[2] template = Template.register(self.apiclient, self.services["template_2"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) template.download(self.apiclient) templates = Template.list(self.apiclient, templatefilter=\ self.services["template_2"]["templatefilter"], id=template.id) if validateList(templates)[0] == FAIL: raise Exception("templates list validation failed") templateSize = int(int(templates[0].size) / (1024**3)) expectedCount = templateSize result = isDomainResourceCountEqualToExpectedCount( self.apiclient, self.domain.id, expectedCount, RESOURCE_SECONDARY_STORAGE) self.assertFalse(result[0], result[1]) self.assertTrue(result[2], "Resource count does not match") templateDestinationZoneId = None for zone in zones: if template.zoneid != zone.id : templateDestinationZoneId = zone.id break template.copy(self.apiclient, destzoneid=templateDestinationZoneId, sourcezoneid = template.zoneid) expectedCount *= 2 result = isDomainResourceCountEqualToExpectedCount( self.apiclient, self.domain.id, expectedCount, RESOURCE_SECONDARY_STORAGE) self.assertFalse(result[0], result[1]) self.assertTrue(result[2], "Resource count does not match") except Exception as e: self.fail("Failed to get zone list: %s" % e) return
def setUpCloudStack(cls): cls._cleanup = [] cls.spapi = spapi.Api.fromConfig(multiCluster=True) testClient = super(TestResizeVolumes, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() storpool_primary_storage = cls.testdata[TestData.primaryStorage] cls.template_name = storpool_primary_storage.get("name") storpool_service_offerings = cls.testdata[TestData.serviceOfferingsIops] storpool_disk_offerings = { "name": "iops", "displaytext": "Testing IOPS on StorPool", "customizediops": True, "storagetype": "shared", "tags" : cls.template_name, } storage_pool = list_storage_pools( cls.apiclient, name = cls.template_name ) service_offerings = list_service_offering( cls.apiclient, name='iops' ) disk_offerings = list_disk_offering( cls.apiclient, name="iops" ) if disk_offerings is None: disk_offerings = DiskOffering.create(cls.apiclient, storpool_disk_offerings, custom = True) else: disk_offerings = disk_offerings[0] cls.disk_offerings = disk_offerings if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) if service_offerings is None: service_offerings = ServiceOffering.create(cls.apiclient, storpool_service_offerings) else: service_offerings = service_offerings[0] template = get_template( cls.apiclient, cls.zone.id, account = "system" ) cls.debug(pprint.pformat(template)) cls.debug(pprint.pformat(cls.hypervisor)) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.account = cls.helper.create_account( cls.apiclient, cls.services["account"], accounttype = 1, domainid=cls.domain.id, ) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid, id = securitygroup.id) cls.service_offering = service_offerings cls.debug(pprint.pformat(cls.service_offering)) cls.local_cluster = cls.helper.get_local_cluster(cls.apiclient, zoneid = cls.zone.id) cls.host = cls.helper.list_hosts_by_cluster_id(cls.apiclient, cls.local_cluster.id) assert len(cls.host) > 1, "Hosts list is less than 1" cls.host_on_local_1 = cls.host[0] cls.host_on_local_2 = cls.host[1] cls.remote_cluster = cls.helper.get_remote_cluster(cls.apiclient, zoneid = cls.zone.id) cls.host_remote = cls.helper.list_hosts_by_cluster_id(cls.apiclient, cls.remote_cluster.id) assert len(cls.host_remote) > 1, "Hosts list is less than 1" cls.host_on_remote1 = cls.host_remote[0] cls.host_on_remote2 = cls.host_remote[1] cls.volume_1 = cls.helper.create_custom_disk( cls.apiclient, {"diskname":"StorPoolDisk" }, zoneid=cls.zone.id, size = 5, miniops = 2000, maxiops = 5000, account=cls.account.name, domainid=cls.account.domainid, diskofferingid=cls.disk_offerings.id, ) cls.volume_2 = cls.helper.create_custom_disk( cls.apiclient, {"diskname":"StorPoolDisk" }, zoneid=cls.zone.id, size = 5, miniops = 2000, maxiops = 5000, account=cls.account.name, domainid=cls.account.domainid, diskofferingid=cls.disk_offerings.id, ) cls.volume = cls.helper.create_custom_disk( cls.apiclient, {"diskname":"StorPoolDisk" }, zoneid=cls.zone.id, size = 5, miniops = 2000, maxiops = 5000, account=cls.account.name, domainid=cls.account.domainid, diskofferingid=cls.disk_offerings.id, ) cls.virtual_machine = cls.helper.create_vm_custom( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, account=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, minIops = 1000, maxIops = 5000, rootdisksize = 10 ) cls.virtual_machine2= cls.helper.create_vm_custom( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, account=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, minIops = 1000, maxIops = 5000, rootdisksize = 10 ) cls.virtual_machine_live_migration_1 = cls.helper.create_vm_custom( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, account=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, minIops = 1000, maxIops = 5000, hostid = cls.host_on_local_1.id, rootdisksize = 10 ) cls.virtual_machine_live_migration_2= cls.helper.create_vm_custom( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=template.id, account=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, minIops = 1000, maxIops = 5000, hostid = cls.host_on_remote1.id, rootdisksize = 10 ) cls.template = template cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def test_03_copy_template(self): """Test secondary storage counts in multiple child domains # Steps 1. Create a parent domain and two sub-domains in it (also admin accounts of each domain) Repeat following steps for both the child domains 2. Register template in child domain 3. Check if the resource count for domain is updated correctly 4. Copy template to other zone 5. Verify that secondary storage count for the domain is doubled as there are two templates now """ zones = list_zones(self.apiclient) self.assertEqual( validateList(zones)[0], PASS, "zones list validation faield") if len(zones) < 2: self.skipTest( "At least 2 zones should be present for this test case") users = None # Setting up account and domain hierarchy result = self.setupAccounts() self.assertEqual(result[0], PASS, result[1]) users = result[2] for domain, admin in users.items(): self.account = admin self.domain = domain try: builtin_info = get_builtin_template_info( self.apiclient, self.zone.id) self.services["template_2"]["url"] = builtin_info[0] self.services["template_2"]["hypervisor"] = builtin_info[1] self.services["template_2"]["format"] = builtin_info[2] template = Template.register(self.apiclient, self.services["template_2"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) template.download(self.apiclient) templates = Template.list(self.apiclient, templatefilter=\ self.services["template_2"]["templatefilter"], id=template.id) if validateList(templates)[0] == FAIL: raise Exception("templates list validation failed") templateSize = int(int(templates[0].size) / (1024**3)) expectedCount = templateSize result = isDomainResourceCountEqualToExpectedCount( self.apiclient, self.domain.id, expectedCount, RESOURCE_SECONDARY_STORAGE) self.assertFalse(result[0], result[1]) self.assertTrue(result[2], "Resource count does not match") templateDestinationZoneId = None for zone in zones: if template.zoneid != zone.id: templateDestinationZoneId = zone.id break template.copy(self.apiclient, destzoneid=templateDestinationZoneId, sourcezoneid=template.zoneid) expectedCount *= 2 result = isDomainResourceCountEqualToExpectedCount( self.apiclient, self.domain.id, expectedCount, RESOURCE_SECONDARY_STORAGE) self.assertFalse(result[0], result[1]) self.assertTrue(result[2], "Resource count does not match") except Exception as e: self.fail("Failed to get zone list: %s" % e) return
def setUpCloudStack(cls): cls.testClient = super(TestNewPrimaryStorage, cls).getClsTestClient() cls.cleanup = [] cls.apiclient = cls.testClient.getApiClient() cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z cls.debug("################## zone %s" % cls.zone) cls.template_name = cls.testdata[TestData.primaryStorage3].get("name") cls.debug("################## template_name %s" % cls.template_name) cls.storage_pool_id = "spStoragePoolId" cls.sp_primary_storage, cls.spapiRemote, cls.spapi = cls.helper.create_sp_template_and_storage_pool( cls.apiclient, cls.template_name, cls.testdata[TestData.primaryStorage3], cls.zone.id) disk_offerings = list_disk_offering(cls.apiclient, name="Small") cls.disk_offerings = disk_offerings[0] diskOffering = { "name": cls.template_name, "displaytext": "test new primary storage disk offerigns", "disksize": 128, "tags": cls.template_name, "storagetype": "shared" } cls.sp_disk_offering = DiskOffering.create(cls.apiclient, diskOffering) cls.cleanup.append(cls.sp_disk_offering) sp_offerings = { "name": cls.template_name, "displaytext": cls.template_name, "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "tags": cls.template_name } cls.serviceOfferings = ServiceOffering.create(cls.apiclient, sp_offerings) cls.template = get_template(cls.apiclient, cls.zone.id, account="system")
def setUpCloudStack(cls): cls._cleanup = [] cls.spapi = spapi.Api.fromConfig(multiCluster=True) testClient = super(TestStoragePool, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z cls.debug("##################### zone %s" % cls.zone) td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() storpool_primary_storage = { "name": "ssd", TestData.scope: "ZONE", "url": "ssd", TestData.provider: "StorPool", "path": "/dev/storpool", TestData.capacityBytes: 2251799813685248, TestData.hypervisor: "KVM" } storpool_without_qos = { "name": "ssd", "displaytext": "ssd", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "hypervisorsnapshotreserve": 200, "tags": "ssd" } storpool_qos_template = { "name": "qos", "displaytext": "qos", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "hypervisorsnapshotreserve": 200, "tags": "ssd" } disk_offering_ssd = { "name": "ssd", "displaytext": "SP_DO_1 (5GB Min IOPS = 300; Max IOPS = 500)", "disksize": 10, "customizediops": False, "hypervisorsnapshotreserve": 200, TestData.tags: "ssd", "storagetype": "shared" } disk_offering_qos = { "name": "qos", "displaytext": "SP_DO_1 (5GB Min IOPS = 300; Max IOPS = 500)", "disksize": 10, "customizediops": False, "hypervisorsnapshotreserve": 200, TestData.tags: "ssd", "storagetype": "shared" } cls.template_name = storpool_primary_storage.get("name") cls.template_name_2 = "qos" storage_pool = list_storage_pools(cls.apiclient, name="ssd") cls.primary_storage = storage_pool[0] if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) service_offerings_ssd = list_service_offering(cls.apiclient, name=cls.template_name) service_offerings_qos = list_service_offering(cls.apiclient, name=cls.template_name_2) if service_offerings_ssd is None: service_offerings_ssd = ServiceOffering.create( cls.apiclient, storpool_without_qos) else: service_offerings_ssd = service_offerings_ssd[0] if service_offerings_qos is None: service_offerings_qos = ServiceOffering.create( cls.apiclient, storpool_qos_template) ResourceDetails.create(cls.apiclient, resourceid=service_offerings_qos.id, resourcetype="ServiceOffering", details={"SP_TEMPLATE": "qos"}, fordisplay=True) else: service_offerings_qos = service_offerings_qos[0] cls.service_offering_ssd = service_offerings_ssd cls.service_offering_qos = service_offerings_qos cls.disk_offering_ssd = list_disk_offering(cls.apiclient, name=cls.template_name) cls.disk_offering_qos = list_disk_offering(cls.apiclient, name=cls.template_name_2) if cls.disk_offering_ssd is None: cls.disk_offering_ssd = DiskOffering.create( cls.apiclient, disk_offering_ssd) else: cls.disk_offering_ssd = cls.disk_offering_ssd[0] if cls.disk_offering_qos is None: cls.disk_offering_qos = DiskOffering.create( cls.apiclient, disk_offering_qos) ResourceDetails.create(cls.apiclient, resourceid=cls.disk_offering_qos.id, resourcetype="DiskOffering", details={"SP_TEMPLATE": "qos"}, fordisplay=True) else: cls.disk_offering_qos = cls.disk_offering_qos[0] #The version of CentOS has to be supported template = get_template(cls.apiclient, cls.zone.id, account="system") if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskofferingid"] = cls.disk_offering_ssd.id cls.account = cls.helper.create_account(cls.apiclient, cls.services["account"], accounttype=1, domainid=cls.domain.id, roleid=1) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid, id=securitygroup.id) cls.volume_1 = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls.volume_2 = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_ssd.id, hypervisor=cls.hypervisor, rootdisksize=10) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume_1) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume_2) cls.template = template cls.hostid = cls.virtual_machine.hostid cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def setUpClass(cls): cls.spapi = spapi.Api.fromConfig(multiCluster=True) testClient = super(TestStoragePool, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.userapiclient = testClient.getUserApiClient( UserName="******", DomainName="ROOT") cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z storpool_primary_storage = { "name": "ssd", "zoneid": cls.zone.id, "url": "ssd", "scope": "zone", "capacitybytes": 4500000, "capacityiops": 155466464221111121, "hypervisor": "kvm", "provider": "StorPool", "tags": "ssd" } storpool_service_offerings = { "name": "ssd", "displaytext": "SP_CO_2 (Min IOPS = 10,000; Max IOPS = 15,000)", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "hypervisorsnapshotreserve": 200, "tags": "ssd" } storage_pool = list_storage_pools(cls.apiclient, name='ssd') service_offerings = list_service_offering(cls.apiclient, name='ssd') disk_offerings = list_disk_offering(cls.apiclient, name="Small") cls.disk_offerings = disk_offerings[0] if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) if service_offerings is None: service_offerings = ServiceOffering.create( cls.apiclient, storpool_service_offerings) else: service_offerings = service_offerings[0] template = get_template(cls.apiclient, cls.zone.id, account="system") if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.service_offering = service_offerings user = list_users(cls.apiclient, account='StorPoolUser', domainid=cls.domain.id) account = list_accounts(cls.apiclient, id=user[0].accountid) if account is None: role = Role.list(cls.apiclient, name='User') cmd = createAccount.createAccountCmd() cmd.email = '*****@*****.**' cmd.firstname = 'StorPoolUser' cmd.lastname = 'StorPoolUser' cmd.password = '******' cmd.username = '******' cmd.roleid = role[0].id account = cls.apiclient.createAccount(cmd) else: account = account[0] cls.account = account # cls.tmp_files = [] # cls.keypair = SSHKeyPair.create( # cls.apiclient, # name=random_gen() + ".pem", # account=cls.account.name, # domainid=cls.account.domainid) # # keyPairFilePath = tempfile.gettempdir() + os.sep + cls.keypair.name # # Clenaup at end of execution # cls.tmp_files.append(keyPairFilePath) # # cls.debug("File path: %s" % keyPairFilePath) # # f = open(keyPairFilePath, "w+") # f.write(cls.keypair.privatekey) # f.close() # # os.system("chmod 400 " + keyPairFilePath) # # cls.keyPairFilePath = keyPairFilePath cls.volume_1 = Volume.create( cls.userapiclient, {"diskname": "StorPoolDisk-1"}, zoneid=cls.zone.id, diskofferingid=cls.disk_offerings.id, ) cls.volume_2 = Volume.create( cls.userapiclient, {"diskname": "StorPoolDisk-2"}, zoneid=cls.zone.id, diskofferingid=cls.disk_offerings.id, ) cls.volume = Volume.create( cls.userapiclient, {"diskname": "StorPoolDisk-3"}, zoneid=cls.zone.id, diskofferingid=cls.disk_offerings.id, ) cls.virtual_machine = VirtualMachine.create( cls.userapiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10, ) cls.virtual_machine2 = VirtualMachine.create( cls.userapiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10, ) cls.template = template cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" cls._cleanup = [] cls._cleanup.append(cls.virtual_machine) cls._cleanup.append(cls.virtual_machine2) cls._cleanup.append(cls.volume_1) cls._cleanup.append(cls.volume_2) cls._cleanup.append(cls.volume) return
def setUpCloudStack(cls): testClient = super(TestStoragePool, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.unsupportedHypervisor = False cls.hypervisor = testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None cls._cleanup = [] zones = list_zones(cls.apiclient) for z in zones: if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp: cls.zone = z td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() cls.account = cls.helper.create_account(cls.apiclient, cls.services["account"], accounttype=1, domainid=cls.domain.id, roleid=1) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account=cls.account.name, domainid=cls.account.domainid, id=securitygroup.id) storpool_primary_storage = cls.testdata[TestData.primaryStorage] storpool_service_offerings = cls.testdata[TestData.serviceOffering] cls.template_name = storpool_primary_storage.get("name") storage_pool = list_storage_pools(cls.apiclient, name=cls.template_name) service_offerings = list_service_offering(cls.apiclient, name=cls.template_name) disk_offerings = list_disk_offering(cls.apiclient, name="Small") disk_offering_20 = list_disk_offering(cls.apiclient, name="Medium") disk_offering_100 = list_disk_offering(cls.apiclient, name="Large") cls.disk_offerings = disk_offerings[0] cls.disk_offering_20 = disk_offering_20[0] cls.disk_offering_100 = disk_offering_100[0] cls.debug(pprint.pformat(storage_pool)) if storage_pool is None: storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.storage_pool = storage_pool cls.debug(pprint.pformat(storage_pool)) if service_offerings is None: service_offerings = ServiceOffering.create( cls.apiclient, storpool_service_offerings) else: service_offerings = service_offerings[0] #The version of CentOS has to be supported template = get_template(cls.apiclient, cls.zone.id, account="system") cls.debug(pprint.pformat(template)) cls.debug(pprint.pformat(cls.hypervisor)) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.service_offering = service_offerings cls.debug(pprint.pformat(cls.service_offering)) cls.local_cluster = cls.helper.get_local_cluster(cls.apiclient, zoneid=cls.zone.id) cls.host = cls.helper.list_hosts_by_cluster_id(cls.apiclient, cls.local_cluster.id) cls.remote_cluster = cls.helper.get_remote_cluster(cls.apiclient, zoneid=cls.zone.id) cls.host_remote = cls.helper.list_hosts_by_cluster_id( cls.apiclient, cls.remote_cluster.id) cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskofferingid"] = cls.disk_offerings.id cls.volume_1 = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls.volume = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, hostid=cls.host[0].id, rootdisksize=10) cls.virtual_machine2 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, hostid=cls.host[0].id, rootdisksize=10) cls.virtual_machine3 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, hostid=cls.host[0].id, rootdisksize=10) cls.template = template cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def test_04_copy_template(self, value): """Test copy template between zones Steps and validations: This test requires at least two zones present in the setup 1. Create a root domain/child domain admin account 2. Register and download a template in the account 3. Verify the secondary storage resource count of the account equals the size of the template 4. Copy this template to other zone 5. Verify that the secondary storage resource count is now doubled as there are two templates now in two zones under the admin account """ zones = list_zones(self.apiclient) self.assertEqual( validateList(zones)[0], PASS, "zones list validation faield") if len(zones) < 2: self.skipTest( "At least 2 zones should be present for this test case") response = self.setupAccount(value) self.assertEqual(response[0], PASS, response[1]) builtin_info = get_builtin_template_info(self.apiclient, self.zone.id) self.services["template_2"]["url"] = builtin_info[0] self.services["template_2"]["hypervisor"] = builtin_info[1] self.services["template_2"]["format"] = builtin_info[2] try: template = Template.register(self.apiclient, self.services["template_2"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor) template.download(self.apiclient) except Exception as e: self.fail("Failed to register template: %s" % e) templates = Template.list(self.apiclient, templatefilter=\ self.services["template_2"]["templatefilter"], id=template.id) self.assertEqual(validateList(templates)[0],PASS,\ "templates list validation failed") templateSize = (templates[0].size / (1024**3)) expectedCount = templateSize response = matchResourceCount(self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id) self.assertEqual(response[0], PASS, response[1]) templateDestinationZoneId = None for zone in zones: if template.zoneid != zone.id: templateDestinationZoneId = zone.id break template.copy(self.apiclient, destzoneid=templateDestinationZoneId, sourcezoneid=template.zoneid) expectedCount = (templateSize * 2) response = matchResourceCount(self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id) self.assertEqual(response[0], PASS, response[1]) 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_04_copy_template(self, value): """Test copy template between zones Steps and validations: This test requires at least two zones present in the setup 1. Create a root domain/child domain admin account 2. Register and download a template in the account 3. Verify the secondary storage resource count of the account equals the size of the template 4. Copy this template to other zone 5. Verify that the secondary storage resource count is now doubled as there are two templates now in two zones under the admin account """ zones = list_zones(self.apiclient) self.assertEqual(validateList(zones)[0], PASS, "zones list validation faield") if len(zones) < 2: self.skipTest("At least 2 zones should be present for this test case") response = self.setupAccount(value) self.assertEqual(response[0], PASS, response[1]) builtin_info = get_builtin_template_info(self.apiclient, self.zone.id) self.services["template_2"]["url"] = builtin_info[0] self.services["template_2"]["hypervisor"] = builtin_info[1] self.services["template_2"]["format"] = builtin_info[2] try: template = Template.register( self.apiclient, self.services["template_2"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor, ) template.download(self.apiclient) except Exception as e: self.fail("Failed to register template: %s" % e) templates = Template.list( self.apiclient, templatefilter=self.services["template_2"]["templatefilter"], id=template.id ) self.assertEqual(validateList(templates)[0], PASS, "templates list validation failed") templateSize = templates[0].size / (1024 ** 3) expectedCount = templateSize response = matchResourceCount( self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id ) self.assertEqual(response[0], PASS, response[1]) templateDestinationZoneId = None for zone in zones: if template.zoneid != zone.id: templateDestinationZoneId = zone.id break template.copy(self.apiclient, destzoneid=templateDestinationZoneId, sourcezoneid=template.zoneid) expectedCount = templateSize * 2 response = matchResourceCount( self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id ) self.assertEqual(response[0], PASS, response[1]) return
def setUpCloudStack(cls): testClient = super(TestVmSnapshot, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False # Setup test data td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.name == cls.getClsConfig().mgtSvr[0].zone: cls.zone = z assert cls.zone is not None cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) #The version of CentOS has to be supported template = get_template( cls.apiclient, cls.zone.id, account = "system" ) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.template = template cls.account = cls.helper.create_account( cls.apiclient, cls.services["account"], accounttype = 1, domainid=cls.domain.id, roleid = 1 ) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid, id = securitygroup.id) primarystorage = cls.testdata[TestData.primaryStorage] serviceOffering = cls.testdata[TestData.serviceOffering] storage_pool = list_storage_pools( cls.apiclient, name = primarystorage.get("name") ) cls.primary_storage = storage_pool[0] disk_offering = list_disk_offering( cls.apiclient, name="ssd" ) assert disk_offering is not None service_offering_only = list_service_offering( cls.apiclient, name="ssd" ) if service_offering_only is not None: cls.service_offering_only = service_offering_only[0] else: cls.service_offering_only = ServiceOffering.create( cls.apiclient, serviceOffering) assert cls.service_offering_only is not None cls.disk_offering = disk_offering[0] # Create 1 data volume_1 cls.volume = Volume.create( cls.apiclient, cls.testdata[TestData.volume_1], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id, size=10 ) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_only.id, hypervisor=cls.hypervisor, rootdisksize=10 ) cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return