def vgpu_serviceoffering_creation(self,gtype,nvidiamodel): self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': nvidiamodel}, {'vgpuType':gtype}] self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["vgpu"]["service_offerings"][gtype] ) list_service_response = ServiceOffering.list( self.apiclient, id=self.service_offering.id ) if list_service_response is None: raise unittest.SkipTest("Check Service Offering list for %s service offering" %(gtype)) self.assertEqual( list_service_response[0].serviceofferingdetails.vgpuType, gtype, "Failed To Create Service Offering . Check vGPU Service Offering list for K2 passthrough" ) self.assertEqual( list_service_response[0].displaytext, self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"], "Check server displaytext in createServiceOfferings" ) self.assertEqual( list_service_response[0].name, self.testdata["vgpu"]["service_offerings"][gtype]["name"], "Check name in createServiceOffering" ) return(self.service_offering)
def setUpClass(cls): cls.testClient = super(TestHostHighAvailability, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering_with_ha = ServiceOffering.create( cls.api_client, cls.services["service_offering_with_ha"], offerha=True ) cls.service_offering_without_ha = ServiceOffering.create( cls.api_client, cls.services["service_offering_without_ha"], offerha=False ) cls._cleanup = [ cls.service_offering_with_ha, cls.service_offering_without_ha, ] return
def setUpClass(cls): cls.testClient = super(TestUpdateResourceCount, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering_custom = ServiceOffering.create( cls.api_client, cls.services["service_offering_custom"] ) cls.service_offering_normal = ServiceOffering.create( cls.api_client, cls.services["service_offering_normal"] ) cls._cleanup = [cls.service_offering_custom, cls.service_offering_normal] return
def setUpClass(cls): cls.testClient = super(TestMultipleChildDomains, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() #cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.testdata["mode"] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.testdata["ostype"] ) # Create service, disk offerings etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering_multiple_cores"] ) cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering_multiple_cores"] ) cls._cleanup = [] return
def setUpClass(cls): testClient = super(TestScaleVm, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'): cls.unsupportedHypervisor = True return # Get Zone, Domain and templates domain = get_domain(cls.apiclient) zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = zone.networktype template = get_template( cls.apiclient, zone.id, cls.services["ostype"] ) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] # Set Zones and disk offerings ?? cls.services["small"]["zoneid"] = zone.id cls.services["small"]["template"] = template.id # Create account, service offerings, vm. cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"] ) cls.big_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["big"] ) # create a virtual machine cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) cls._cleanup = [ cls.small_offering, cls.account ]
def test_02_failure_to_create_service_offering_with_customized_iops(self): try: ServiceOffering.create( self.apiClient, self.testdata[TestData.systemOfferingFailure] ) except: return self.assert_(False, "The service offering was created, but should not have been.")
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestChangeServiceOfferingForVmWithSnapshots, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.unsupportedHypervisor = False if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"): cls.unsupportedHypervisor = True return cls.domain = get_domain(cls.api_client) cls.zone = get_zone( cls.api_client, cls.testClient.getZoneForTests() ) cls.services["small"]["zoneid"] = cls.zone.id cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) if cls.template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] test_offerings = Utils().added_service_offerings for offering in test_offerings: cls.services["service_offerings"][offering] = test_offerings[offering] # Create 2 different service offerings cls.service_offering_1 = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["testOffering1"] ) cls._cleanup.append(cls.service_offering_1) cls.service_offering_2 = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["testOffering2"] ) cls._cleanup.append(cls.service_offering_2) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def setUpClass(cls): cls.testClient = super(TestMemoryLimits, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestRedundantRouterNetworkCleanups, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True ) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering, ] return
def setUpClass(cls): cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv', 'lxc']: raise unittest.SkipTest("Snapshots feature is not supported on %s" % cls.hypervisor.lower()) cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cloudstackTestClient = super(TestSecondaryStorageLimits, cls).getClsTestClient() cls.api_client = cloudstackTestClient.getApiClient() cls.hypervisor = cloudstackTestClient.getHypervisorInfo() # Fill services from the external config file cls.services = cloudstackTestClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.hypervisor = cloudstackTestClient.getHypervisorInfo() cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id cls._cleanup = [] try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) if cls.service_offering == FAILED: raise Exception("Creating service offering failed") except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setup class: %s" % e) return
def setUpClass(cls): testClient = super(TestCreateVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls.sparse_disk_offering = DiskOffering.create(cls.apiclient, cls.services["sparse_disk_offering"]) cls.custom_disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"], custom=True) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) 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["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id cls.services["diskname"] = cls.services["volume"]["diskname"] # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offerings"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) cls._cleanup = [cls.service_offering, cls.disk_offering, cls.custom_disk_offering, cls.account]
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: assert False, "get_template() failed to return template " # for testing with specific template # self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"], templatetype='USER', services = {"template":'31f52a4d-5681-43f7-8651-ad4aaf823618'}) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCRedundancy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [cls.service_offering] cls.logger = logging.getLogger('TestVPCRedundancy') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) return
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: cls.unsupportedHypervisor = True return cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup.append(cls.service_offering) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.testdata = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): cloudstackTestClient = super(TestVolumeLimits, cls).getClsTestClient() cls.api_client = cloudstackTestClient.getApiClient() cls.hypervisor = cloudstackTestClient.getHypervisorInfo() # Fill services from the external config file cls.services = cloudstackTestClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls._cleanup = [] cls.unsupportedStorageType = False if cls.hypervisor.lower() == 'lxc': if not find_storage_pool_type(cls.api_client, storagetype='rbd'): cls.unsupportedStorageType = True return cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering ] return
def setUpClass(cls): cls.testClient = super(TestMaxProjectNetworks, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.domain = get_domain(cls.api_client) cls.services['mode'] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True ) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering ] return
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("Template creation from root volume is not supported in LXC") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering ] return
def setUpClass(cls): testClient = super(TestDeployVmWithUserData, cls).getClsTestClient() cls.apiClient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.zone = get_zone(cls.apiClient, testClient.getZoneForTests()) if cls.zone.localstorageenabled: #For devcloud since localstroage is enabled cls.services["service_offerings"]["storagetype"] = "local" cls.service_offering = ServiceOffering.create( cls.apiClient, cls.services["service_offerings"] ) cls.account = Account.create(cls.apiClient, services=cls.services["account"]) cls.cleanup = [cls.account] cls.template = get_template( cls.apiClient, cls.zone.id, cls.services["ostype"] ) if cls.template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) # Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit. # CS however allows for upto 4K bytes in the code. So this must succeed. # Overall, the query length must not exceed 4K, for then the json decoder # will fail this operation at the marvin client side itcls. user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) cls.services["virtual_machine"]["userdata"] = user_data
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): testClient = super(TestSameVMName, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ try: cls.skiptest = False if cls.hypervisor.lower() not in ['vmware']: cls.skiptest = True # Create an account cls.account_1 = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls.account_2 = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) # Create user api client of the account cls.userapiclient_1 = testClient.getUserApiClient( UserName=cls.account_1.name, DomainName=cls.account_1.domain ) cls.userapiclient_2 = testClient.getUserApiClient( UserName=cls.account_2.name, DomainName=cls.account_2.domain ) # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup = [ cls.account_1, cls.account_2, cls.service_offering, ] except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): cls.testClient = super(TestVPC, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.unsupportedHypervisor = False if cls.hypervisor.lower() == 'hyperv': cls._cleanup = [] cls.unsupportedHypervisor = True return cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestAffinityRules, cls).getClsTestClient() if cls.testClient.getHypervisorInfo().lower() != "vmware": raise unittest.SkipTest("VMWare tests only valid on VMWare hypervisor") cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup = [cls.account] return
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCNetworkPFRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [cls.service_offering] return
def setUpClass(cls): testClient = super(TestConcurrentSnapshotLimit, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.supportedHypervisor = True if cls.hypervisor.lower() in [ "hyperv", "lxc"]: cls.supportedHypervisor = False return # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) return
def setUpClass(cls): cls.testClient = super(TestAffinityRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup = [cls.account] return
def setUpClass(cls): cls.testClient = super(TestHighAvailability, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod( cls.api_client, zone_id=cls.zone.id ) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("Template creation from root volume is not supported in LXC") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls._cleanup = [ cls.service_offering, ] return
def test_03_deploy_vm_project_limit_reached(self): """Test TTry to deploy VM with admin account where account has not used the resources but @ project they are not available""" # Validate the following # 1. Try to deploy VM with admin account where account has not used the # resources but @ project they are not available # 2. Deploy VM should error out saying ResourceAllocationException # with "resource limit exceeds" self.debug("Creating service offering with 3 CPU cores") so = self.testdata["service_offering"] so["cpunumber"] = 3 self.service_offering = ServiceOffering.create( self.apiclient, so ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts(account_limit=4, domain_limit=4, project_limit=2) api_client_admin = self.testClient.getUserApiClient( UserName=self.child_do_admin.name, DomainName=self.child_do_admin.domain) self.debug("Deploying instance in account 2 when CPU limit is reached") with self.assertRaises(Exception): self.createInstance(project=self.project, service_off=self.service_offering, api_client=api_client_admin) return
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 td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() storpool_primary_storage = cls.testdata[TestData.primaryStorage] storpool_primary_storage_ssd2 = cls.testdata[TestData.primaryStorage2] storpool_service_offerings_ssd = cls.testdata[TestData.serviceOffering] storpool_service_offerings_ssd2 = cls.testdata[TestData.serviceOfferingssd2] cls.template_name = storpool_primary_storage.get("name") cls.template_name_2 = storpool_primary_storage_ssd2.get("name") storage_pool = list_storage_pools( cls.apiclient, name = cls.template_name ) storage_pool2 = list_storage_pools( cls.apiclient, name = cls.template_name_2 ) cls.primary_storage = storage_pool[0] cls.primary_storage2 = storage_pool2[0] service_offerings_ssd = list_service_offering( cls.apiclient, name = cls.template_name ) service_offerings_ssd2 = list_service_offering( cls.apiclient, name = cls.template_name_2 ) 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_ssd is None: service_offerings_ssd = ServiceOffering.create(cls.apiclient, storpool_service_offerings_ssd) else: service_offerings_ssd = service_offerings_ssd[0] if service_offerings_ssd2 is None: service_offerings_ssd2 = ServiceOffering.create(cls.apiclient, storpool_service_offerings_ssd2) else: service_offerings_ssd2 = service_offerings_ssd2[0] #The version of CentOS has to be supported template = get_template( cls.apiclient, cls.zone.id, account = "system" ) 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.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.services["diskofferingid"] = disk_offerings[0].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.service_offering = service_offerings_ssd cls.service_offering_ssd2 = service_offerings_ssd2 cls.debug(pprint.pformat(cls.service_offering)) 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.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.vm_migrate = 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.vm_cluster = 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.hostid = cls.virtual_machine.hostid return
def test_01_multiple_child_domains(self): """Test memory limits with multiple child domains""" # Validate the following # 1. Create Domain1 with 4 GB RAM and 2 child domains with 2 GB # each. # 2. Deploy VM's by Domain1 admin1/user1/ Domain2 user1/Admin1 account # and verify the resource updates # 3. Deploy VM by admin account after reaching max parent domain limit # 4. Deploy VM with child account after reaching max child domain limit # 5. Delete user account and verify the resource updates # 6. Destroy user/admin account VM's and verify the child & Parent # domain resource updates self.debug("Creating service offering with 2 GB RAM") self.services["service_offering"]["memory"] = 2048 self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() api_client_cadmin_1 = self.testClient.getUserApiClient( UserName=self.cadmin_1.name, DomainName=self.cadmin_1.domain) api_client_cadmin_2 = self.testClient.getUserApiClient( UserName=self.cadmin_2.name, DomainName=self.cadmin_2.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) vm_2 = self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_1 = account_list[0].memorytotal self.debug(resource_count_cadmin_1) account_list = Account.list(self.apiclient, id=self.cadmin_2.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_2 = account_list[0].memorytotal self.debug(resource_count_cadmin_2) self.debug( "Creating instance when Memory limit is fully used in parent domain" ) with self.assertRaises(Exception): self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) self.debug( "Creating instance when Memory limit is fully used in child domain" ) with self.assertRaises(Exception): self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) self.debug("Destroying instances: %s, %s" % (vm_1.name, vm_2.name)) try: vm_1.delete(self.apiclient) vm_2.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) self.debug("Checking resource count for account: %s" % self.cadmin_1.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_1 = account_list[0].memorytotal self.assertEqual(resource_count_cadmin_1, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) #RAM self.debug("Checking resource count for account: %s" % self.cadmin_2.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_2 = account_list[0].memorytotal self.assertEqual(resource_count_cadmin_2, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) #RAM return
def setUpClass(cls): testClient = super(TestXDCCPInterop, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype hosts = list_hosts( cls.apiclient, type="Routing" ) if hosts is None: raise unittest.SkipTest( "There are no hypervisor's available.Check list hosts response") for hypervisorhost in hosts : if hypervisorhost.hypervisor == "XenServer": cls.uploadtemplateformat="VHD" break elif hypervisorhost.hypervisor== "VMware": cls.uploadtemplateformat="OVA" break elif hypervisorhost.hypervisor== "KVM": cls.uploadtemplateformat="KVM" break if cls.uploadtemplateformat=="KVM": assert False, "Interop is not supported on KVM" cls.uploadurl=cls.services["interop"][cls.uploadtemplateformat]["url"] cls.xtemplate = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) if cls.xtemplate == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id, admin=False ) cls.debug(cls.account.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["large"] ) cls.template = get_windows_template( cls.apiclient, cls.zone.id, ostype_desc="Windows 8 (64-bit)") #cls.template = get_windows_template(cls.apiclient, cls.zone.id ,ostype_desc="Windows Server 2012 (64-bit)") if cls.template == FAILED: if "http://pleaseupdateURL/" in cls.uploadurl: raise unittest.SkipTest( "Check Test Data file if it has the valid template URL") cls.template = Template.register( cls.apiclient, cls.services["interop"][cls.uploadtemplateformat], zoneid=cls.zone.id, domainid=cls.account.domainid, account=cls.account.name ) timeout = cls.services["vgpu"]["timeout"] while True: time.sleep(cls.services["vgpu"]["sleep"]) list_template_response = Template.list( cls.apiclient, templatefilter=cls.services["templatefilter"], id=cls.template.id ) if (isinstance(list_template_response, list)) is not True: raise unittest.SkipTest( "Check list template api response returns a valid list") if len(list_template_response) is None: raise unittest.SkipTest( "Check template registered is in List Templates") template_response = list_template_response[0] if template_response.isready: break if timeout == 0: raise unittest.SkipTest( "Failed to download template(ID: %s). " % template_response.id) timeout = timeout - 1 cls.volume=[] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls.services["medium"]["zoneid"] = cls.zone.id cls.services["medium"]["template"] = cls.template.id user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) cls.services["virtual_machine"]["userdata"] = user_data # cls.services["large"]["zoneid"] = cls.zone.id # cls.services["large"]["template"] = cls.template.id cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["medium"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services['mode'], startvm="false" ) cls.user_api_client = cls.testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) cls.cleanup = [ cls.service_offering, cls.account ]
def setUp(self): self.apiclient = self.testClient.getApiClient() self.services = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) template = get_template(self.apiclient, self.zone.id, self.services["ostype"]) if template == FAILED: self.fail( "get_template() failed to return template with description %s" % self.services["ostype"]) self.services["virtual_machine"]["zoneid"] = self.zone.id # Create an account, network, VM and IP addresses self.account = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offerings"]) self.vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id) # Wait for VM to come up time.sleep(120) src_nat_ip_addrs = list_publicIP(self.apiclient, account=self.account.name, domainid=self.account.domainid) try: src_nat_ip_addr = src_nat_ip_addrs[0] except Exception as e: raise Exception( "Warning: Exception during fetching source NAT: %s" % e) self.public_ip = PublicIPAddress.create( self.apiclient, self.vm_1.account, self.vm_1.zoneid, self.vm_1.domainid, self.services["virtual_machine"]) # Open up firewall port for SSH FireWallRule.create(self.apiclient, ipaddressid=self.public_ip.ipaddress.id, protocol=self.services["lbrule"]["protocol"], cidrlist=['0.0.0.0/0'], startport=self.services["lbrule"]["publicport"], endport=self.services["lbrule"]["publicport"]) lb_rule = LoadBalancerRule.create(self.apiclient, self.services["lbrule"], src_nat_ip_addr.id, self.account.name) lb_rule.assign(self.apiclient, [self.vm_1]) self.nat_rule = NATRule.create(self.apiclient, self.vm_1, self.services["natrule"], ipaddressid=self.public_ip.ipaddress.id) self.cleanup = [ self.nat_rule, lb_rule, self.vm_1, self.service_offering, self.account, ] return
def setUpClass(cls): testClient = super(TestDeltaSnapshots, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls.snapshots_created = [] cls._cleanup = [] cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.skiptest = False if cls.hypervisor.lower() not in ["xenserver"]: cls.skiptest = True try: # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) if cls.testdata["configurableData"][ "restartManagementServerThroughTestCase"]: # Set snapshot delta max value Configurations.update(cls.apiclient, name="snapshot.delta.max", value="3") # Restart management server cls.RestartServer() time.sleep(120) configs = Configurations.list(cls.apiclient, name="snapshot.delta.max") cls.delta_max = configs[0].value cls.vm = VirtualMachine.create( cls.apiclient, cls.testdata["small"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, zoneid=cls.zone.id, mode=cls.zone.networktype) except Exception as e: cls.tearDownClass() raise e return
def setUp(self): self.cleanup = [] def signal_handler(signal, frame): self.tearDown() sys.exit(0) # assign the signal handler immediately signal.signal(signal.SIGINT, signal_handler) self.hypervisor = self.testClient.getHypervisorInfo() try: self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.services = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) # if local storage is enabled, alter the offerings to use # localstorage if self.zone.localstorageenabled: self.services["service_offerings"]["tiny"][ "storagetype"] = 'local' template = get_template(self.apiclient, self.zone.id, self.services["ostype"]) # Set Zones and disk offerings self.services["small"]["zoneid"] = self.zone.id self.services["small"]["template"] = template.id self.services["iso1"]["zoneid"] = self.zone.id self.services["network"]["zoneid"] = self.zone.id # Create Account, VMs, NAT Rules etc self.account = Account.create(self.apiclient, self.services["account"], domainid=domain.id) self.cleanup.insert(0, self.account) self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offerings"]["tiny"]) self.cleanup.insert(0, self.service_offering) #################### # Network offering self.network_offering = NetworkOffering.create( self.apiclient, self.services["network_offering"], ) self.cleanup.insert(0, self.network_offering) self.network_offering.update( self.apiclient, state='Enabled') # Enable Network offering self.services["network"][ "networkoffering"] = self.network_offering.id self.network_offering_shared = NetworkOffering.create( self.apiclient, self.services["network_offering_shared"], ) self.cleanup.insert(0, self.network_offering_shared) self.network_offering_shared.update( self.apiclient, state='Enabled') # Enable Network offering self.services["network2"][ "networkoffering"] = self.network_offering_shared.id ################ # Test Network self.test_network = Network.create( self.apiclient, self.services["network"], self.account.name, self.account.domainid, ) self.cleanup.insert(0, self.test_network) self.test_network2 = Network.create( self.apiclient, self.services["network2"], self.account.name, self.account.domainid, zoneid=self.services["network"]["zoneid"]) self.cleanup.insert(0, self.test_network2) except Exception as ex: self.debug("Exception during NIC test SETUP!: " + str(ex))
def setUpClass(cls): testClient = super(TestCpuCapServiceOfferings, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() cls._cleanup = [] cls.hypervisorNotSupported = False if cls.hypervisor.lower() not in ["kvm"]: cls.hypervisorNotSupported = True return domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) if template == FAILED: assert False, "get_test_template() failed to return template" cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id cls.services["small"]["hypervisor"] = cls.hypervisor cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][ 0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) offering_data = { 'displaytext': 'TestOffering', 'cpuspeed': 512, 'cpunumber': 2, 'name': 'TestOffering', 'memory': 1024 } cls.offering = ServiceOffering.create(cls.apiclient, offering_data, limitcpuuse=True) def getHost(self, hostId=None): response = list_hosts(self.apiclient, type='Routing', hypervisor='kvm', id=hostId) # Check if more than one kvm hosts are available in order to successfully configure host-ha if response and len(response) > 0: self.host = response[0] return self.host raise self.skipTest( "Not enough KVM hosts found, skipping host-ha test") cls.host = getHost(cls) cls.vm = VirtualMachine.create(cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.offering.id, mode=cls.services["mode"], hostid=cls.host.id) cls._cleanup = [cls.offering, cls.account]
def test_06_disk_offering_strictness_false(self): """Test to see change service offering is possible when disk offering strictness is set to false """ # Validate the following # 1. Create service offering linked a disk offering and disk offering strictness is false # 2. Create a VM with that service offering # 3. Create another service offering with a different disk offering and disk offering strictness is false # 4. Try change service offering for VM should succeed if self.hypervisor.lower() == "lxc": self.skipTest( "Skipping this test for {} due to bug CS-38153".format( self.hypervisor)) offering_data = { 'displaytext': 'TestDiskOfferingStrictnessFalse', 'cpuspeed': 512, 'cpunumber': 2, 'name': 'TestDiskOfferingStrictnessFalse', 'memory': 1024, 'diskofferingstrictness': False } self.serviceOfferingWithDiskOfferingStrictnessFalse = ServiceOffering.create( self.apiclient, offering_data, ) self._cleanup.append( self.serviceOfferingWithDiskOfferingStrictnessFalse) self.virtual_machine_with_diskoffering_strictness_false = VirtualMachine.create( self.apiclient, self.services["small"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self. serviceOfferingWithDiskOfferingStrictnessFalse.id, mode=self.services["mode"]) try: self.virtual_machine_with_diskoffering_strictness_false.stop( self.apiclient) timeout = self.services["timeout"] while True: time.sleep(self.services["sleep"]) # Ensure that VM is in stopped state list_vm_response = list_virtual_machines( self.apiclient, id=self.virtual_machine_with_diskoffering_strictness_false. id) if isinstance(list_vm_response, list): vm = list_vm_response[0] if vm.state == 'Stopped': self.debug("VM state: %s" % vm.state) break if timeout == 0: raise Exception( "Failed to stop VM (ID: %s) in change service offering" % vm.id) timeout = timeout - 1 except Exception as e: self.fail("Failed to stop VM: %s" % e) self.disk_offering2 = DiskOffering.create( self.apiclient, self.services["disk_offering"], ) self._cleanup.append(self.disk_offering2) offering_data = { 'displaytext': 'TestDiskOfferingStrictnessFalse2', 'cpuspeed': 1000, 'cpunumber': 2, 'name': 'TestDiskOfferingStrictnessFalse2', 'memory': 1024, 'diskofferingstrictness': False, 'diskofferingid': self.disk_offering2.id } self.serviceOfferingWithDiskOfferingStrictnessFalse2 = ServiceOffering.create( self.apiclient, offering_data, ) self._cleanup.append( self.serviceOfferingWithDiskOfferingStrictnessFalse2) cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd( ) cmd.id = self.virtual_machine_with_diskoffering_strictness_false.id cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessFalse2.id self.apiclient.changeServiceForVirtualMachine(cmd) list_vm_response = VirtualMachine.list( self.apiclient, id=self.virtual_machine_with_diskoffering_strictness_false.id) vm_response = list_vm_response[0] self.assertEqual( vm_response.id, self.virtual_machine_with_diskoffering_strictness_false.id, "Check virtual machine ID of upgraded VM") self.assertEqual( vm_response.serviceofferingid, self.serviceOfferingWithDiskOfferingStrictnessFalse2.id, "Check service offering of the VM") return
def test_05_disk_offering_strictness_true(self): """Test to see change service offering is not possible when disk offering strictness is set to true """ # Validate the following # 1. Create service offering linked a disk offering and disk offering strictness is true # 2. Create a VM with that service offering # 3. Create another service offering with a different disk offering # 4. Try change service offering for VM and it will fail since disk offering strictness is true (not allowed to change the disk offering) if self.hypervisor.lower() == "lxc": self.skipTest( "Skipping this test for {} due to bug CS-38153".format( self.hypervisor)) offering_data = { 'displaytext': 'TestDiskOfferingStrictnessTrue', 'cpuspeed': 512, 'cpunumber': 2, 'name': 'TestDiskOfferingStrictnessTrue', 'memory': 1024, 'diskofferingstrictness': True } self.serviceOfferingWithDiskOfferingStrictnessTrue = ServiceOffering.create( self.apiclient, offering_data, ) self._cleanup.append( self.serviceOfferingWithDiskOfferingStrictnessTrue) self.virtual_machine_with_diskoffering_strictness_true = VirtualMachine.create( self.apiclient, self.services["small"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self. serviceOfferingWithDiskOfferingStrictnessTrue.id, mode=self.services["mode"]) try: self.virtual_machine_with_diskoffering_strictness_true.stop( self.apiclient) timeout = self.services["timeout"] while True: time.sleep(self.services["sleep"]) # Ensure that VM is in stopped state list_vm_response = list_virtual_machines( self.apiclient, id=self.virtual_machine_with_diskoffering_strictness_true. id) if isinstance(list_vm_response, list): vm = list_vm_response[0] if vm.state == 'Stopped': self.debug("VM state: %s" % vm.state) break if timeout == 0: raise Exception( "Failed to stop VM (ID: %s) in change service offering" % vm.id) timeout = timeout - 1 except Exception as e: self.fail("Failed to stop VM: %s" % e) offering_data = { 'displaytext': 'TestDiskOfferingStrictnessTrue2', 'cpuspeed': 1000, 'cpunumber': 2, 'name': 'TestDiskOfferingStrictnessTrue2', 'memory': 1024, 'diskofferingstrictness': True } self.serviceOfferingWithDiskOfferingStrictnessTrue2 = ServiceOffering.create( self.apiclient, offering_data, ) self._cleanup.append( self.serviceOfferingWithDiskOfferingStrictnessTrue2) cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd( ) cmd.id = self.virtual_machine_with_diskoffering_strictness_true.id cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessTrue2.id with self.assertRaises(Exception) as e: self.apiclient.changeServiceForVirtualMachine(cmd) self.debug( "Upgrade VM with new service offering having different disk offering operation failed as expected with exception: %s" % e.exception) return
def setUpClass(cls): testClient = super(TestKubernetesCluster, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = testClient.getHypervisorInfo() cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.hypervisorNotSupported = False if cls.hypervisor.lower() not in ["kvm", "vmware", "xenserver"]: cls.hypervisorNotSupported = True cls.setup_failed = False cls._cleanup = [] cls.kubernetes_version_ids = [] if cls.hypervisorNotSupported == False: cls.endpoint_url = Configurations.list( cls.apiclient, name="endpoint.url")[0].value if "localhost" in cls.endpoint_url: endpoint_url = "http://%s:%d/client/api " % ( cls.mgtSvrDetails["mgtSvrIp"], cls.mgtSvrDetails["port"]) cls.debug("Setting endpoint.url to %s" % (endpoint_url)) Configurations.update(cls.apiclient, "endpoint.url", endpoint_url) cls.initial_configuration_cks_enabled = Configurations.list( cls.apiclient, name="cloud.kubernetes.service.enabled")[0].value if cls.initial_configuration_cks_enabled not in ["true", True]: cls.debug( "Enabling CloudStack Kubernetes Service plugin and restarting management server" ) Configurations.update(cls.apiclient, "cloud.kubernetes.service.enabled", "true") cls.restartServer() cls.updateVmwareSettings(False) cls.cks_service_offering = None if cls.setup_failed == False: try: cls.kubernetes_version_1_20_9 = cls.addKubernetesSupportedVersion( cls.services["cks_kubernetes_versions"]["1.20.9"]) cls.kubernetes_version_ids.append( cls.kubernetes_version_1_20_9.id) except Exception as e: cls.setup_failed = True cls.debug( "Failed to get Kubernetes version ISO in ready state, version=%s, url=%s, %s" % (cls.services["cks_kubernetes_versions"]["1.20.9"] ["semanticversion"], cls.services["cks_kubernetes_versions"]["1.20.9"] ["url"], e)) if cls.setup_failed == False: try: cls.kubernetes_version_1_21_5 = cls.addKubernetesSupportedVersion( cls.services["cks_kubernetes_versions"]["1.21.5"]) cls.kubernetes_version_ids.append( cls.kubernetes_version_1_21_5.id) except Exception as e: cls.setup_failed = True cls.debug( "Failed to get Kubernetes version ISO in ready state, version=%s, url=%s, %s" % (cls.services["cks_kubernetes_versions"]["1.21.5"] ["semanticversion"], cls.services["cks_kubernetes_versions"]["1.21.5"] ["url"], e)) if cls.setup_failed == False: cks_offering_data = cls.services["cks_service_offering"] cks_offering_data["name"] = 'CKS-Instance-' + random_gen() cls.cks_service_offering = ServiceOffering.create( cls.apiclient, cks_offering_data) cls._cleanup.append(cls.cks_service_offering) cls.domain = get_domain(cls.apiclient) cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) return
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestBrocadeVcs, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.brocade_services = cls.services["brocade"] try: """ Adds Brocade device and enables NS provider""" cmd = listPhysicalNetworks.listPhysicalNetworksCmd() cmd.zoneid = cls.zone.id physical_networks = cls.api_client.listPhysicalNetworks(cmd) if isinstance(physical_networks, list): physical_network = physical_networks[0] cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd() cmd.name = 'BrocadeVcs' cmd.physicalnetworkid = physical_network.id nw_service_providers = cls.api_client.listNetworkServiceProviders( cmd) if isinstance(nw_service_providers, list): brocade_provider = nw_service_providers[0] else: cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd() cmd1.name = 'BrocadeVcs' cmd1.physicalnetworkid = physical_network.id brocade_provider = cls.api_client.addNetworkServiceProvider( cmd1) cmd2 = addBrocadeVcsDevice.addBrocadeVcsDeviceCmd() cmd2.physicalnetworkid = physical_network.id cmd2.username = cls.brocade_services["username"] cmd2.password = cls.brocade_services["password"] cmd2.hostname = cls.brocade_services["ipaddress"] cls.brocade = cls.api_client.addBrocadeVcsDevice(cmd2) if brocade_provider.state != 'Enabled': cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd( ) cmd.id = brocade_provider.id cmd.state = 'Enabled' cls.api_client.updateNetworkServiceProvider(cmd) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True) cls._cleanup.append(cls.network_offering) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setUpClass: %s" % e) return
def test_01_so_removal_resource_update(self): self.service_offering_it_1 = ServiceOffering.create( self.api_client, self.services["service_offering_it_1"], domainid=self.domain.id) self.cleanup.append(self.service_offering_it_1) self.service_offering_it_2 = ServiceOffering.create( self.api_client, self.services["service_offering_it_2"], domainid=self.domain.id) self.cleanup.append(self.service_offering_it_2) vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine_1"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering_it_1.id) self.debug("Deployed VM in account: %s, ID: %s" % (self.account.name, vm_1.id)) self.cleanup.append(vm_1) vm_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine_2"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering_it_2.id) self.debug("Deployed VM in account: %s, ID: %s" % (self.account.name, vm_2.id)) self.cleanup.append(vm_2) CPU_RESOURCE_ID = 8 RAM_RESOURCE_ID = 9 cores = int(self.get_resource_amount(CPU_RESOURCE_ID)) ram = int(self.get_resource_amount(RAM_RESOURCE_ID)) self.assertEqual( cores, self.services['service_offering_it_1']['cpunumber'] + self.services['service_offering_it_2']['cpunumber']) self.assertEqual( ram, self.services['service_offering_it_1']['memory'] + self.services['service_offering_it_2']['memory']) self.service_offering_it_2.delete(self.apiclient) self.cleanup = self.cleanup[0:-1] cores = int(self.get_resource_amount(CPU_RESOURCE_ID)) ram = int(self.get_resource_amount(RAM_RESOURCE_ID)) self.assertEqual( cores, self.services['service_offering_it_1']['cpunumber'] + self.services['service_offering_it_2']['cpunumber']) self.assertEqual( ram, self.services['service_offering_it_1']['memory'] + self.services['service_offering_it_2']['memory'])
def setUpCloudStack(cls): super(TestMigrationFromUuidToGlobalId, cls).setUpClass() cls._cleanup = [] cls.helper = HelperUtil(cls) with open(cls.ARGS.cfg) as json_text: cfg.logger.info(cls.ARGS.cfg) cfg.logger.info(json_text) conf = json.load(json_text) cfg.logger.info(conf) zone = conf['mgtSvr'][0].get('zone') cls.helper.build_commit(cls.ARGS.uuid, cls.ARGS) cfg.logger.info("Starting CloudStack") cls.mvn_proc = subprocess.Popen( ['mvn', '-pl', ':cloud-client-ui', 'jetty:run'], cwd=cls.ARGS.forked, preexec_fn=os.setsid, stdout=cfg.misc, stderr=subprocess.STDOUT, ) cls.mvn_proc_grp = os.getpgid(cls.mvn_proc.pid) cfg.logger.info("Started CloudStack in process group %d", cls.mvn_proc_grp) cfg.logger.info("Waiting for a while to give it a chance to start") proc = subprocess.Popen(["tail", "-f", cfg.misc_name], shell=False, bufsize=0, stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: cfg.logger.info("tail ended, was this expected?") cfg.logger.info("Stopping CloudStack") os.killpg(cls.mvn_proc_grp, signal.SIGINT) break if "[INFO] Started Jetty Server" in line: cfg.logger.info("got it!") break proc.terminate() proc.wait() time.sleep(15) cfg.logger.info("Processing with the setup") cls.obj_marvininit = cls.helper.marvin_init(cls.ARGS.cfg) cls.testClient = cls.obj_marvininit.getTestClient() cls.apiclient = cls.testClient.getApiClient() dbclient = cls.testClient.getDbConnection() v = dbclient.execute( "select * from configuration where name='sp.migration.to.global.ids.completed'" ) cfg.logger.info("Configuration setting for update of db is %s", v) if len(v) > 0: update = dbclient.execute( "update configuration set value='false' where name='sp.migration.to.global.ids.completed'" ) cfg.logger.info("DB configuration table was updated %s", update) td = TestData() cls.testdata = td.testdata cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, zone_name=zone) cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) cls.host = list_hosts(cls.apiclient, zoneid=cls.zone.id) #The version of CentOS has to be supported cls.template = get_template(cls.apiclient, cls.zone.id, account="system") if cls.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"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id cls.sp_template_1 = "-".join(["test-ssd-b", random_gen()]) cfg.logger.info( pprint.pformat("############################ %s" % cls.zone)) storpool_primary_storage = { "name": cls.sp_template_1, "zoneid": cls.zone.id, "url": "SP_API_HTTP=10.2.87.30:81;SP_AUTH_TOKEN=1234567890;SP_TEMPLATE=%s" % cls.sp_template_1, "scope": "zone", "capacitybytes": 564325555333, "capacityiops": 155466, "hypervisor": "kvm", "provider": "StorPool", "tags": cls.sp_template_1 } cls.storpool_primary_storage = storpool_primary_storage host, port, auth = cls.getCfgFromUrl( url=storpool_primary_storage["url"]) cls.spapi = spapi.Api(host=host, port=port, auth=auth) storage_pool = list_storage_pools( cls.apiclient, name=storpool_primary_storage["name"]) if storage_pool is None: newTemplate = sptypes.VolumeTemplateCreateDesc( name=storpool_primary_storage["name"], placeAll="ssd", placeTail="ssd", placeHead="ssd", replication=1) template_on_local = cls.spapi.volumeTemplateCreate(newTemplate) storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage) else: storage_pool = storage_pool[0] cls.primary_storage = storage_pool storpool_service_offerings_ssd = { "name": cls.sp_template_1, "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": cls.sp_template_1 } service_offerings_ssd = list_service_offering( cls.apiclient, name=storpool_service_offerings_ssd["name"]) if service_offerings_ssd is None: service_offerings_ssd = ServiceOffering.create( cls.apiclient, storpool_service_offerings_ssd) else: service_offerings_ssd = service_offerings_ssd[0] cls.service_offering = service_offerings_ssd cfg.logger.info(pprint.pformat(cls.service_offering)) cls.sp_template_2 = "-".join(["test-ssd2-b", random_gen()]) storpool_primary_storage2 = { "name": cls.sp_template_2, "zoneid": cls.zone.id, "url": "SP_API_HTTP=10.2.87.30:81;SP_AUTH_TOKEN=1234567890;SP_TEMPLATE=%s" % cls.sp_template_2, "scope": "zone", "capacitybytes": 564325555333, "capacityiops": 1554, "hypervisor": "kvm", "provider": "StorPool", "tags": cls.sp_template_2 } cls.storpool_primary_storage2 = storpool_primary_storage2 storage_pool = list_storage_pools( cls.apiclient, name=storpool_primary_storage2["name"]) if storage_pool is None: newTemplate = sptypes.VolumeTemplateCreateDesc( name=storpool_primary_storage2["name"], placeAll="ssd", placeTail="ssd", placeHead="ssd", replication=1) template_on_local = cls.spapi.volumeTemplateCreate(newTemplate) storage_pool = StoragePool.create(cls.apiclient, storpool_primary_storage2) else: storage_pool = storage_pool[0] cls.primary_storage2 = storage_pool storpool_service_offerings_ssd2 = { "name": cls.sp_template_2, "displaytext": "SP_CO_2", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "tags": cls.sp_template_2 } service_offerings_ssd2 = list_service_offering( cls.apiclient, name=storpool_service_offerings_ssd2["name"]) if service_offerings_ssd2 is None: service_offerings_ssd2 = ServiceOffering.create( cls.apiclient, storpool_service_offerings_ssd2) else: service_offerings_ssd2 = service_offerings_ssd2[0] cls.service_offering2 = service_offerings_ssd2 os.killpg(cls.mvn_proc_grp, signal.SIGTERM) time.sleep(30) cls.mvn_proc = subprocess.Popen( ['mvn', '-pl', ':cloud-client-ui', 'jetty:run'], cwd=cls.ARGS.forked, preexec_fn=os.setsid, stdout=cfg.misc, stderr=subprocess.STDOUT, ) cls.mvn_proc_grp = os.getpgid(cls.mvn_proc.pid) cfg.logger.info("Started CloudStack in process group %d", cls.mvn_proc_grp) cfg.logger.info("Waiting for a while to give it a chance to start") proc = subprocess.Popen(["tail", "-f", cfg.misc_name], shell=False, bufsize=0, stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: cfg.logger.info("tail ended, was this expected?") cfg.logger.info("Stopping CloudStack") os.killpg(cls.mvn_proc_grp, signal.SIGINT) break if "[INFO] Started Jetty Server" in line: cfg.logger.info("got it!") break proc.terminate() proc.wait() time.sleep(15) disk_offering = list_disk_offering(cls.apiclient, name="Small") assert disk_offering is not None cls.disk_offering = disk_offering[0] account = list_accounts(cls.apiclient, name="admin") cls.account = account[0] cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine) cls.virtual_machine2 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine2) cls.virtual_machine3 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine3) cls.virtual_machine4 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine4) #check that ROOT disk is created with uuid root_volume = list_volumes(cls.apiclient, virtualmachineid=cls.virtual_machine3.id, type="ROOT") try: spvolume = cls.spapi.volumeList(volumeName=root_volume[0].id) except spapi.ApiError as err: cfg.logger.info("Root volume is not created with UUID") raise Exception(err) 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) cls._cleanup.append(cls.volume) cls.volume2 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_2], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume2) cls.virtual_machine4.stop(cls.apiclient, forced=True) cls.virtual_machine4.attach_volume(cls.apiclient, cls.volume2) cls.virtual_machine4.detach_volume(cls.apiclient, cls.volume2) vol = list_volumes(cls.apiclient, id=cls.volume2.id) cls.random_data_vm_snapshot1 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" volume_attached = cls.virtual_machine.attach_volume( cls.apiclient, cls.volume) cls.helper.write_on_disks(cls.random_data_vm_snapshot1, cls.virtual_machine, cls.test_dir, cls.random_data) MemorySnapshot = False cls.vm_snapshot1 = cls.helper.create_vm_snapshot( MemorySnapshot, cls.virtual_machine) cls.helper.delete_random_data_after_vmsnpashot(cls.vm_snapshot1, cls.virtual_machine, cls.test_dir, cls.random_data) cls.random_data_vm_snapshot2 = random_gen(size=100) cls.helper.write_on_disks(cls.random_data_vm_snapshot2, cls.virtual_machine, cls.test_dir, cls.random_data) cls.vm_snapshot2 = cls.helper.create_vm_snapshot( MemorySnapshot, cls.virtual_machine) cls.helper.delete_random_data_after_vmsnpashot(cls.vm_snapshot2, cls.virtual_machine, cls.test_dir, cls.random_data) #vm snapshot to be deleted without revert cls.random_data_vm_snapshot3 = random_gen(size=100) cls.helper.write_on_disks(cls.random_data_vm_snapshot3, cls.virtual_machine, cls.test_dir, cls.random_data) cls.vm_snapshot_for_delete = cls.helper.create_vm_snapshot( MemorySnapshot, cls.virtual_machine) cls.helper.delete_random_data_after_vmsnpashot( cls.vm_snapshot_for_delete, cls.virtual_machine, cls.test_dir, cls.random_data) cls.snapshot_on_secondary = cls.helper.create_snapshot( False, cls.virtual_machine2) cls._cleanup.append(cls.snapshot_on_secondary) cls.template_on_secondary = cls.helper.create_template_from_snapshot( cls.services, snapshotid=cls.snapshot_on_secondary.id) cls._cleanup.append(cls.template_on_secondary) cls.snapshot_bypassed = cls.helper.create_snapshot( False, cls.virtual_machine2) cls._cleanup.append(cls.snapshot_bypassed) cls.template_bypased = cls.helper.create_template_from_snapshot( cls.services, snapshotid=cls.snapshot_bypassed.id) cls._cleanup.append(cls.template_bypased) #change to latest commit with globalId implementation cls.helper.switch_to_globalid_commit(cls.ARGS.globalid, cls.ARGS) cfg.logger.info("The setup is done, proceeding with the tests")
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestLbStickyPolicy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() # Fill testdata from the external config file cls.testdata = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.testdata["ostype"] ) cls.testdata["configurableData"]["netscaler"]["lbdevicededicated"] = False try: cls.exception_string = "Connection limit to CFE exceeded" cls.skiptest = False cls.netscaler = add_netscaler( cls.api_client, cls.zone.id, cls.testdata["configurableData"]["netscaler"]) cls._cleanup.append(cls.netscaler) cls.network_offering = NetworkOffering.create( cls.api_client, cls.testdata["nw_off_isolated_netscaler"], conservemode=True ) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls.testdata["small"]["zoneid"] = cls.zone.id cls.testdata["small"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering"] ) cls.account = Account.create( cls.api_client, cls.testdata["account"], admin=True, domainid=cls.domain.id ) cls._cleanup.insert(0, cls.account) # Creating network using the network offering created cls.network = Network.create( cls.api_client, cls.testdata["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id ) # Spawn an instance in that network cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.testdata["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network.id)] ) cls.public_ip = PublicIPAddress.create( cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network.id ) except Exception as e: if cls.exception_string.lower() in e.lower(): cls.skiptest = True cls.exception_msg = e else: cls.tearDownClass() raise Exception("Warning: Exception in setUpClass: %s" % e) return
def setUpClass(cls): # Set up API client testclient = super(TestScaleIOVolumes, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.configData = testclient.getParsedTestDataConfig() cls.dbConnection = testclient.getDbConnection() cls.testdata = TestData().testdata # Get Resources from Cloud Infrastructure cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId]) cls.cluster = list_clusters(cls.apiClient)[0] cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor=TestData.hypervisor_type) cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId]) # Create test account cls.account = Account.create(cls.apiClient, cls.testdata["account"], admin=1) # Set up connection to make customized API calls cls.user = User.create(cls.apiClient, cls.testdata["user"], account=cls.account.name, domainid=cls.domain.id) url = cls.testdata[TestData.url] primarystorage = cls.testdata[TestData.primaryStorage] cls.primary_storage = StoragePool.create( cls.apiClient, primarystorage, scope=primarystorage[TestData.scope], zoneid=cls.zone.id, provider=primarystorage[TestData.provider], tags=primarystorage[TestData.tags], hypervisor=primarystorage[TestData.hypervisor]) cls.compute_offering = ServiceOffering.create( cls.apiClient, cls.testdata[TestData.computeOffering]) cls.disk_offering = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOffering]) if TestData.migrationTests: primarystorage_sameinst = cls.testdata[ TestData.primaryStorageSameInstance] cls.primary_storage_same_inst = StoragePool.create( cls.apiClient, primarystorage_sameinst, scope=primarystorage_sameinst[TestData.scope], zoneid=cls.zone.id, provider=primarystorage_sameinst[TestData.provider], tags=primarystorage_sameinst[TestData.tags], hypervisor=primarystorage_sameinst[TestData.hypervisor]) primarystorage_distinctinst = cls.testdata[ TestData.primaryStorageDistinctInstance] cls.primary_storage_distinct_inst = StoragePool.create( cls.apiClient, primarystorage_distinctinst, scope=primarystorage_distinctinst[TestData.scope], zoneid=cls.zone.id, provider=primarystorage_distinctinst[TestData.provider], tags=primarystorage_distinctinst[TestData.tags], hypervisor=primarystorage_distinctinst[TestData.hypervisor]) cls.disk_offering_same_inst = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOfferingSameInstance]) cls.disk_offering_distinct_inst = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOfferingDistinctInstance]) # Create VM and volume for tests cls.virtual_machine = VirtualMachine.create( cls.apiClient, cls.testdata[TestData.virtualMachine], accountid=cls.account.name, zoneid=cls.zone.id, serviceofferingid=cls.compute_offering.id, templateid=cls.template.id, domainid=cls.domain.id, startvm=False) TestScaleIOVolumes._start_vm(cls.virtual_machine) 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) # Resources that are to be destroyed cls._cleanup = [ cls.volume, cls.virtual_machine, cls.compute_offering, cls.disk_offering, cls.user, cls.account ]
def test_01_positive_tests_vm_operations_basic_zone(self): """ Positive tests for VMLC test path - Basic Zone # 1. List created service offering in setUpClass by name # 2. List registered template with name # 3. Create VM in account # 4. Enable networking for reaching to VM thorugh SSH # 5. Check VM accessibility through SSH # 6. Stop vm and verify vm is not accessible # 7. Start vm and verify vm is not accessible # 8. Reboot vm and verify vm is not accessible # 9. Destroy and recover VM # 10. Change service offering of VM to a different service offering # 11. Verify that the cpuspeed, cpunumber and memory of VM matches to # as specified in new service offering # 12. Start VM and verify VM accessibility # 13. Find suitable host for VM to migrate and migrate the VM # 14. Verify VM accessibility on new host """ # List created service offering in setUpClass by name listServiceOfferings = ServiceOffering.list( self.apiclient, name=self.service_offering_1.name, listall=True) self.assertEqual( validateList(listServiceOfferings)[0], PASS, "List validation failed for service offerings list") self.assertEqual( listServiceOfferings[0].name, self.service_offering_1.name, "Names of created service offering and\ listed service offering not matching") # List registered template with name listTemplates = Template.list(self.userapiclient, templatefilter="self", name=self.template.name, listall=True, zone=self.zone.id) self.assertEqual( validateList(listTemplates)[0], PASS, "List validation failed for\ templates list") self.assertEqual( listTemplates[0].name, self.template.name, "Names of created template and listed template\ not matching") # Enable networking for reaching to VM thorugh SSH security_group = SecurityGroup.create(self.apiclient, self.testdata["security_group"], account=self.account.name, domainid=self.account.domainid) self.cleanup.append(security_group) # Authorize Security group to SSH to VM security_group.authorize(self.apiclient, self.testdata["ingress_rule"], account=self.account.name, domainid=self.account.domainid) # Create VM in account self.virtual_machine = VirtualMachine.create( self.userapiclient, self.testdata["small"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering_1.id, zoneid=self.zone.id, securitygroupids=[ security_group.id, ]) # Check VM accessibility try: SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Stop VM and verify VM is not accessible self.virtual_machine.stop(self.userapiclient) with self.assertRaises(Exception): SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password, retries=0) # Start VM and verify that it is accessible self.virtual_machine.start(self.userapiclient) try: SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Reboot VM and verify that it is accessible self.virtual_machine.reboot(self.userapiclient) try: SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Destroy and recover VM self.virtual_machine.delete(self.userapiclient, expunge=False) self.virtual_machine.recover(self.apiclient) # Change service offering of VM and verify that it is changed self.virtual_machine.change_service_offering( self.userapiclient, serviceOfferingId=self.service_offering_2.id) VerifyChangeInServiceOffering(self, self.virtual_machine, self.service_offering_2) # Start VM and verify that it is accessible self.virtual_machine.start(self.userapiclient) try: SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Find suitable host for VM to migrate and migrate the VM # Verify that it is accessible on the new host host = findSuitableHostForMigration(self.apiclient, self.virtual_machine.id) if host is None: self.fail(ERROR_NO_HOST_FOR_MIGRATION) self.virtual_machine.migrate(self.apiclient, host.id) try: SshClient(host=self.virtual_machine.ssh_ip, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) return
def setUpClass(cls): testClient = super(TestPathVMLC, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient) cls._cleanup = [] try: # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # If local storage is enabled, alter the offerings to use # localstorage if cls.zone.localstorageenable: cls.testdata["service_offering"]["storagetype"] = 'local' # Create 3 service offerings with different values for # for cpunumber, cpuspeed, and memory cls.testdata["service_offering"]["cpunumber"] = "1" cls.testdata["service_offering"]["cpuspeed"] = "128" cls.testdata["service_offering"]["memory"] = "256" cls.service_offering_1 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering_1) cls.testdata["service_offering"]["cpunumber"] = "2" cls.testdata["service_offering"]["cpuspeed"] = "256" cls.testdata["service_offering"]["memory"] = "512" cls.service_offering_2 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering_2) # Create isolated network offering cls.isolated_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["isolated_network_offering"]) cls._cleanup.append(cls.isolated_network_offering) # Create shared network offering cls.testdata["shared_network_offering_all_services"][ "specifyVlan"] = "True" cls.testdata["shared_network_offering_all_services"][ "specifyIpRanges"] = "True" cls.shared_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["shared_network_offering_all_services"]) cls._cleanup.append(cls.shared_network_offering) cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["nw_offering_isolated_vpc"]) cls._cleanup.append(cls.isolated_network_offering_vpc) cls.vpc_off = VpcOffering.create(cls.apiclient, cls.testdata["vpc_offering"]) cls.vpc_off.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.vpc_off) # This variable will store the id of vpc network whenever # test case creates it # If not created, it will be None and will not be used cls.vpcid = None # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) # Register a private template in the account builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id) cls.testdata["privatetemplate"]["url"] = builtin_info[0] cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1] cls.testdata["privatetemplate"]["format"] = builtin_info[2] # Register new template cls.template = Template.register(cls.userapiclient, cls.testdata["privatetemplate"], zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid) # Wait for template to download cls.template.download(cls.apiclient) # Check that we are able to login to the created account respose = User.login(cls.apiclient, username=cls.account.name, password=cls.testdata["account"]["password"]) assert respose.sessionkey is not None,\ "Login to the CloudStack should be successful\ response shall have non Null key" except Exception as e: cls.tearDownClass() raise e return
def test_01_change_service_offering(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Upgrade and downgrade service offering # 4. Resource count should list properly for the domain self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in list(users.items()): self.account = admin self.domain = domain #Resetting memory count in service offering self.services["service_offering"]["memory"] = 2048 self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % vm.name) try: vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_stop = account_list[0].memorytotal self.assertEqual( resource_count_after_stop, expected_resource_count, "Resource count should be same after stopping the instance") self.debug("Creating service offering with 5 GB RAM") self.services["service_offering"]["memory"] = 5120 self.service_offering_5gb = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering_5gb) self.debug( "Upgrade service offering of instance %s from %s to %s" % (vm.name, self.service_offering.name, self.service_offering_5gb.name)) try: vm.change_service_offering( self.apiclient, serviceOfferingId=self.service_offering_5gb.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) update_resource_count(self.apiclient, domainid=self.domain.id, rtype=9) #RAM account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_upgrade = account_list[0].memorytotal self.debug(resource_count_after_upgrade) self.assertTrue( resource_count_after_upgrade > resource_count_after_stop, "Resource count should be more than before, after upgrading service offering" ) self.debug( "Down grade service offering of instance %s from %s to %s" % (vm.name, self.service_offering_5gb.name, self.service_offering.name)) try: vm.change_service_offering( self.apiclient, serviceOfferingId=self.service_offering.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) update_resource_count(self.apiclient, domainid=self.domain.id, rtype=9) #RAM account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_downgrade = account_list[0].memorytotal self.debug(resource_count_after_downgrade) self.assertTrue( resource_count_after_downgrade < resource_count_after_upgrade, "Resource count should be less than before, after downgrading service offering" ) self.debug("Starting instance: %s" % vm.name) try: vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_start = account_list[0].memorytotal self.assertTrue( resource_count_after_start == resource_count_after_downgrade, "Resource count should be same after starting the instance") return
def setUpCloudStack(cls): super(TestLiveMigration, cls).setUpClass() cls._cleanup = [] testClient = super(TestLiveMigration, 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() cls.template_name = cls.testdata[TestData.primaryStorage].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 = cls.helper.create_sp_template_and_storage_pool( cls.apiclient, cls.template_name, cls.testdata[TestData.primaryStorage], cls.zone.id) 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, cls.testdata[TestData.serviceOffering]) 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.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.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = disk_offerings[0].id cls.account = Account.create(cls.apiclient, cls.services["account"], 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.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.volume_on_remote = 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_on_local_1.id, rootdisksize=10) cls.virtual_machine_on_remote = 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_on_remote1.id, rootdisksize=10) cls.virtual_machine_migr_btw_cl = 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_on_local_1.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_positive_tests_vm_operations_advanced_zone(self, value): """ Positive tests for VMLC test path - Advanced Zone # 1. List created service offering in setUpClass by name # 2. List registered template with name # 3. Create VM in account # 4. Enable networking for reaching to VM thorugh SSH # 5. Check VM accessibility through SSH # 6. Stop vm and verify vm is not accessible # 7. Start vm and verify vm is not accessible # 8. Reboot vm and verify vm is not accessible # 9. Destroy and recover VM # 10. Change service offering of VM to a different service offering # 11. Verify that the cpuspeed, cpunumber and memory of VM matches to # as specified in new service offering # 12. Start VM and verify VM accessibility # 13. Find suitable host for VM to migrate and migrate the VM # 14. Verify VM accessibility on new host """ # List created service offering in setUpClass by name listServiceOfferings = ServiceOffering.list( self.apiclient, name=self.service_offering_1.name, listall=True) self.assertEqual( validateList(listServiceOfferings)[0], PASS, "List validation failed for service offerings list") self.assertEqual( listServiceOfferings[0].name, self.service_offering_1.name, "Names of created service offering\ and listed service offering not matching") # List registered template with name listTemplates = Template.list(self.userapiclient, templatefilter="self", name=self.template.name, listall=True, zone=self.zone.id) self.assertEqual( validateList(listTemplates)[0], PASS, "List validation failed for templates list") self.assertEqual( listTemplates[0].name, self.template.name, "Names of created template and listed template\ not matching") network = CreateNetwork(self, value) # Create VM in account self.virtual_machine = VirtualMachine.create( self.userapiclient, self.testdata["small"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering_1.id, networkids=[ network.id, ], zoneid=self.zone.id) publicip = PublicIPAddress.create(self.userapiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=self.vpcid) if value == VPC_NETWORK: lb_rule = LoadBalancerRule.create( self.apiclient, self.testdata["vpclbrule"], ipaddressid=publicip.ipaddress.id, accountid=self.account.name, domainid=self.account.domainid, networkid=network.id, vpcid=self.vpcid) lb_rule.assign(self.apiclient, [self.virtual_machine]) # Opening up the ports in VPC NetworkACL.create(self.apiclient, networkid=network.id, services=self.testdata["natrule"], traffictype='Ingress') elif value == ISOLATED_NETWORK: FireWallRule.create(self.userapiclient, ipaddressid=publicip.ipaddress.id, protocol='TCP', cidrlist=[self.testdata["fwrule"]["cidr"]], startport=self.testdata["fwrule"]["startport"], endport=self.testdata["fwrule"]["endport"]) NATRule.create(self.userapiclient, self.virtual_machine, self.testdata["natrule"], ipaddressid=publicip.ipaddress.id, networkid=network.id) # Check VM accessibility try: SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Stop VM and verify VM is not accessible self.virtual_machine.stop(self.userapiclient) with self.assertRaises(Exception): SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password, retries=0) # Start VM and verify that it is accessible self.virtual_machine.start(self.userapiclient) try: SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Reboot VM and verify that it is accessible self.virtual_machine.reboot(self.userapiclient) try: SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Destroy and recover VM self.virtual_machine.delete(self.apiclient, expunge=False) self.virtual_machine.recover(self.apiclient) # Change service offering of VM and verify that it is changed self.virtual_machine.change_service_offering( self.userapiclient, serviceOfferingId=self.service_offering_2.id) VerifyChangeInServiceOffering(self, self.virtual_machine, self.service_offering_2) # Start VM and verify that it is accessible self.virtual_machine.start(self.userapiclient) try: SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) # Find suitable host for VM to migrate and migrate the VM # Verify that it is accessible on the new host host = findSuitableHostForMigration(self.apiclient, self.virtual_machine.id) if host is None: self.fail(ERROR_NO_HOST_FOR_MIGRATION) self.virtual_machine.migrate(self.apiclient, host.id) try: SshClient(host=publicip.ipaddress.ipaddress, port=22, user=self.virtual_machine.username, passwd=self.virtual_machine.password) except Exception as e: self.fail("Exception while SSHing to VM: %s" % e) return
def test1_attach_volume(self): """ @desc: Unable to attach 7th Disk to windows server 2012R2 instance. Add a valid windows server 2012 URL to execute this test case Step1: Set global config vmware.root.disk.controller to 'osdefault' Step2: Deploy a Windows 2012 R2 instance. Step3: Attach 6 disks to the VM. Step4: Try attaching a 7th disk to the VM Verify that step4 succeeds without any exception """ self.hypervisor = str(get_hypervisor_type(self.api_client)).lower() if self.hypervisor != "vmware": self.skipTest("This test can be run only on vmware") self.updateConfigurAndRestart("vmware.root.disk.controller", "osdefault") self.services["Windows Server 2012"][ "url"] = "http://10.147.28.7/templates/Windows2012/WindowsServer2012R2.ova.gz", template = Template.register(self.userapiclient, self.services["Windows Server 2012"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.assertIsNotNone( template, "Failed to register Windows server 2012 R2 template") self.debug("Registered a template with format {} and id {}".format( self.services["Windows Server 2012"]["format"], template.id)) template.download(self.userapiclient) self.cleanup.append(template) # Creating a big service offering for windows VM launch big_service_offering = ServiceOffering.create( self.apiClient, self.services["service_offerings"]["big"]) self.cleanup.append(big_service_offering) vm = VirtualMachine.create(self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=big_service_offering.id, templateid=template.id, zoneid=self.zone.id) self.assertIsNotNone(vm, "Failed to deploy virtual machine") self.cleanup.append(vm) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS, "list vm response returned invalid list") for i in range(0, 7): self.services["volume"]["diskname"] = i disk = Volume.create(self.userapiclient, self.services["volume"], zoneid=self.zone.id, diskofferingid=self.disk_offering.id) self.assertIsNotNone(disk, "Failed to create custom volume") self.cleanup.append(disk) try: vm.attach_volume(self.userapiclient, disk) list_volumes = Volume.list(self.userapiclient, listall=self.services["listall"], id=disk.id) attached_volume = list_volumes[0] self.assertEqual( disk.id, attached_volume.id, "list volume response does not match with the volume created and attached to vm" ) except Exception as e: self.fail( "Failed to attach {} data disk to Windows server 2012 R2 vm " .format(i)) return
def setUpClass(cls): cls.logger = logging.getLogger('TestRouterDHCPHosts') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.testClient = super(TestRouterDHCPHosts, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][ 0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.logger.debug("Creating Admin Account for domain %s on zone %s" % (cls.domain.id, cls.zone.id)) # Create an account, network, VM and IP addresses cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.logger.debug("Creating Service Offering on zone %s" % (cls.zone.id)) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.services["isolated_network_offering"]["egress_policy"] = "true" cls.logger.debug("Creating Network Offering on zone %s" % (cls.zone.id)) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["isolated_network_offering"], conservemode=True) cls.network_offering.update(cls.api_client, state='Enabled') cls.logger.debug("Creating Network for Account %s using offering %s" % (cls.account.name, cls.network_offering.id)) cls.network = Network.create(cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id) cls.logger.debug( "Creating VM1 for Account %s using offering %s with IP 10.1.1.50" % (cls.account.name, cls.service_offering.id)) cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.domain.id, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network.id)], ipaddress="10.1.1.50") cls.logger.debug( "Creating VM2 for Account %s using offering %s with IP 10.1.1.51" % (cls.account.name, cls.service_offering.id)) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.domain.id, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network.id)], ipaddress="10.1.1.51") cls.services["natrule1"] = { "privateport": 22, "publicport": 222, "protocol": "TCP" } cls.services["natrule2"] = { "privateport": 22, "publicport": 223, "protocol": "TCP" } cls.services["configurableData"] = { "host": { "port": 22 }, "input": "INPUT", "forward": "FORWARD" } cls._cleanup = [ cls.vm_2, cls.network, cls.network_offering, cls.service_offering, cls.account ] return
def setUpClass(cls): testClient = super(TestVolumes, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"] ) cls.resized_disk_offering = DiskOffering.create( cls.apiclient, cls.services["resized_disk_offering"] ) cls.custom_resized_disk_offering = DiskOffering.create( cls.apiclient, cls.services["resized_disk_offering"], custom=True ) template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) 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["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = cls.disk_offering.id cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id cls.services['customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id # Create VMs, VMs etc cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) cls.volume = Volume.create( cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid ) cls._cleanup = [ cls.resized_disk_offering, cls.custom_resized_disk_offering, cls.service_offering, cls.disk_offering, cls.volume, cls.account ]
def setUpClass(cls): cls.logger = logging.getLogger('TestRedundantIsolateNetworks') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.testClient = super(TestRedundantIsolateNetworks, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.template = get_test_template(cls.api_client, cls.zone.id, cls.hypervisor) if cls.template == FAILED: assert False, "get_test_template() failed to return template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id # Create an account, network, VM and IP addresses cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.services["nw_off_persistent_RVR_egress_true"] = cls.services[ "nw_off_persistent_RVR"].copy() cls.services["nw_off_persistent_RVR_egress_true"][ "egress_policy"] = "true" cls.services["nw_off_persistent_RVR_egress_false"] = cls.services[ "nw_off_persistent_RVR"].copy() cls.services["nw_off_persistent_RVR_egress_false"][ "egress_policy"] = "false" cls.services["egress_80"] = { "startport": 80, "endport": 80, "protocol": "TCP", "cidrlist": ["0.0.0.0/0"] } cls.services["egress_53"] = { "startport": 53, "endport": 53, "protocol": "UDP", "cidrlist": ["0.0.0.0/0"] } cls._cleanup = [cls.service_offering, cls.account] return
def setUp(self): self.testdata = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) self.hosts = [] suitablecluster = None clusters = Cluster.list(self.apiclient) self.assertTrue(isinstance(clusters, list) and len(clusters) > 0, msg = "No clusters found") for cluster in clusters: self.hosts = Host.list(self.apiclient, clusterid=cluster.id, type='Routing') if isinstance(self.hosts, list) and len(self.hosts) >= 2: suitablecluster = cluster break self.assertEqual(validateList(self.hosts)[0], PASS, "hosts list validation failed") if len(self.hosts) < 2: self.skipTest("Atleast 2 hosts required in cluster for VM HA test") #update host tags for host in self.hosts: Host.update(self.apiclient, id=host.id, hosttags=self.testdata["service_offerings"]["hasmall"]["hosttags"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["hasmall"] ) #deploy ha vm self.virtual_machine = VirtualMachine.create( self.apiclient, self.testdata["virtual_machine"], accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=self.template.id ) list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id) self.debug( "Verify listVirtualMachines response for virtual machine: %s"\ % self.virtual_machine.id ) self.assertTrue(isinstance(list_vms, list) and len(list_vms) == 1, msg = "List VM response was empty") self.virtual_machine = list_vms[0] self.mock_checkhealth = SimulatorMock.create( apiclient=self.apiclient, command="CheckHealthCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_ping = SimulatorMock.create( apiclient=self.apiclient, command="PingCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_checkvirtualmachine = SimulatorMock.create( apiclient=self.apiclient, command="CheckVirtualMachineCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_pingtest = SimulatorMock.create( apiclient=self.apiclient, command="PingTestCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, value="result:fail") self.mock_checkonhost_list = [] for host in self.hosts: if host.id != self.virtual_machine.hostid: self.mock_checkonhost_list.append(SimulatorMock.create( apiclient=self.apiclient, command="CheckOnHostCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=host.id, value="result:fail")) #build cleanup list self.cleanup = [ self.service_offering, self.account, self.mock_checkhealth, self.mock_ping, self.mock_checkvirtualmachine, self.mock_pingtest ] self.cleanup = self.cleanup + self.mock_checkonhost_list
def setUpClass(cls): testClient = super(TestVMLifeCycle, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #if local storage is enabled, alter the offerings to use localstorage #this step is needed for devcloud if cls.zone.localstorageenabled == True: cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' cls.services["service_offerings"]["small"]["storagetype"] = 'local' cls.services["service_offerings"]["medium"][ "storagetype"] = 'local' template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id cls.services["medium"]["zoneid"] = cls.zone.id cls.services["medium"]["template"] = template.id cls.services["iso1"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) cls.small_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"]) cls.medium_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["medium"]) #create small and large virtual machines cls.small_virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls.medium_virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["medium"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.medium_offering.id, mode=cls.services["mode"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls._cleanup = [cls.small_offering, cls.medium_offering, cls.account]
def setUpCloudStack(cls): super(MigrationUuidToGlobalIdTags, cls).setUpClass() cls._cleanup = [] cls.helper = HelperUtil(cls) cls.helper.build_commit(cls.ARGS.uuid, cls.ARGS) cfg.logger.info("Starting CloudStack") cls.mvn_proc = subprocess.Popen( ['mvn', '-pl', ':cloud-client-ui', 'jetty:run'], cwd=cls.ARGS.forked, preexec_fn=os.setsid, stdout=cfg.misc, stderr=subprocess.STDOUT, ) cls.mvn_proc_grp = os.getpgid(cls.mvn_proc.pid) cfg.logger.info("Started CloudStack in process group %d", cls.mvn_proc_grp) cfg.logger.info("Waiting for a while to give it a chance to start") proc = subprocess.Popen(["tail", "-f", cfg.misc_name], shell=False, bufsize=0, stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: cfg.logger.info("tail ended, was this expected?") cfg.logger.info("Stopping CloudStack") os.killpg(cls.mvn_proc_grp, signal.SIGTERM) break if "[INFO] Started Jetty Server" in line: cfg.logger.info("got it!") break proc.terminate() proc.wait() time.sleep(15) cfg.logger.info("Processing with the setup") cls.obj_marvininit = cls.helper.marvin_init(cls.ARGS.cfg) cls.testClient = cls.obj_marvininit.getTestClient() cls.apiclient = cls.testClient.getApiClient() dbclient = cls.testClient.getDbConnection() v = dbclient.execute( "select * from configuration where name='sp.migration.to.global.ids.completed'" ) cfg.logger.info("Configuration setting for update of db is %s", v) if len(v) > 0: update = dbclient.execute( "update configuration set value='false' where name='sp.migration.to.global.ids.completed'" ) cfg.logger.info("DB configuration table was updated %s", update) cls.spapi = spapi.Api.fromConfig(multiCluster=True) td = TestData() cls.testdata = td.testdata cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) #The version of CentOS has to be supported cls.template = get_template(cls.apiclient, cls.zone.id, account="system") if cls.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"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.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="Small") assert disk_offering is not None service_offering = list_service_offering(cls.apiclient, name="ssd") if service_offering is not None: cls.service_offering = service_offering[0] else: cls.service_offering = ServiceOffering.create( cls.apiclient, serviceOffering) assert cls.service_offering is not None cls.disk_offering = disk_offering[0] account = list_accounts(cls.apiclient, name="admin") cls.account = account[0] cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine) cls.virtual_machine2 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine2) cls.virtual_machine3 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine3) cls.virtual_machine4 = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%s" % uuid.uuid4()}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering.id, hypervisor=cls.hypervisor, rootdisksize=10) cls._cleanup.append(cls.virtual_machine4) 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) cls._cleanup.append(cls.volume) cls.volume2 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_2], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume2) cls.volume3 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_3], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume3) cls.volume4 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_4], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume4) cls.random_data_vm_snapshot1 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" volume_attached = cls.virtual_machine3.attach_volume( cls.apiclient, cls.volume3) cls.helper.write_on_disks(cls.random_data_vm_snapshot1, cls.virtual_machine3, cls.test_dir, cls.random_data) MemorySnapshot = False cls.vm_snapshot1 = cls.helper.create_vm_snapshot( MemorySnapshot, cls.virtual_machine3) cls.helper.delete_random_data_after_vmsnpashot(cls.vm_snapshot1, cls.virtual_machine3, cls.test_dir, cls.random_data) #for test 01 cls.virtual_machine.attach_volume(cls.apiclient, cls.volume) #for test 03 the volume has to be created with uuid before to switch to commit with globalid implementation cls.virtual_machine.attach_volume(cls.apiclient, cls.volume4) cls.virtual_machine.stop(cls.apiclient, forced=True) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume4) cls.virtual_machine.start(cls.apiclient) #change to latest commit with globalId implementation cls.helper.switch_to_globalid_commit(cls.ARGS.globalid, cls.ARGS) cfg.logger.info("The setup is done, proceeding with the tests")
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestVMOwnership, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype # Get and set template id for VM creation. cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.hypervisor = cls.testClient.getHypervisorInfo() def create_domain_account_user(parentDomain=None): domain = Domain.create( cls.api_client, cls.services["domain"], parentdomainid=parentDomain.id if parentDomain else None) cls._cleanup.append(domain) # Create an Account associated with domain account = Account.create(cls.api_client, cls.services["account"], domainid=domain.id) cls._cleanup.append(account) # Create an User, Project, Volume associated with account user = User.create(cls.api_client, cls.services["user"], account=account.name, domainid=account.domainid) cls._cleanup.append(user) project = Project.create(cls.api_client, cls.services["project"], account=account.name, domainid=account.domainid) cls._cleanup.append(project) volume = Volume.create(cls.api_client, cls.services["volume"], zoneid=cls.zone.id, account=account.name, domainid=account.domainid, diskofferingid=cls.disk_offering.id) cls._cleanup.append(volume) return { 'domain': domain, 'account': account, 'user': user, 'project': project, 'volume': volume } # Create disk offerings. try: cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"]) # Create service offerings. cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) # Cleanup cls._cleanup.append(cls.service_offering) # Create domain, account, user, project and volumes. cls.domain_account_user1 = create_domain_account_user() cls.domain_account_user2 = create_domain_account_user() cls.sdomain_account_user1 = create_domain_account_user( cls.domain_account_user1['domain']) cls.sdomain_account_user2 = create_domain_account_user( cls.domain_account_user2['domain']) cls.ssdomain_account_user2 = create_domain_account_user( cls.sdomain_account_user2['domain']) except Exception as e: raise e return
def setUpClass(cls): # Set up API client testclient = super(TestVMSnapshots, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.configData = testclient.getParsedTestDataConfig() cls.testdata = TestData().testdata # Set up XenAPI connection host_ip = "https://" + \ list_hosts(cls.apiClient, clusterid=cls.testdata[TestData.clusterId], name="XenServer-6.5-1")[0].ipaddress cls.xen_session = XenAPI.Session(host_ip) xenserver = cls.testdata[TestData.xenServer] cls.xen_session.xenapi.login_with_password( xenserver[TestData.username], xenserver[TestData.password]) # Set up SolidFire connection solidfire = cls.testdata[TestData.solidFire] cls.sfe = ElementFactory.create(solidfire[TestData.mvip], solidfire[TestData.username], solidfire[TestData.password]) # Get Resources from Cloud Infrastructure cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId]) template = get_template(cls.apiClient, cls.zone.id, cls.configData["ostype"]) cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId]) # Create test account cls.account = Account.create(cls.apiClient, cls.testdata[TestData.account], admin=1) # Set up connection to make customized API calls user = User.create(cls.apiClient, cls.testdata[TestData.user], account=cls.account.name, domainid=cls.domain.id) url = cls.testdata[TestData.url] api_url = "http://" + url + ":8080/client/api" userkeys = User.registerUserKeys(cls.apiClient, user.id) cls.cs_api = SignedAPICall.CloudStack(api_url, userkeys.apikey, userkeys.secretkey) primarystorage = cls.testdata[TestData.primaryStorage] cls.primary_storage = StoragePool.create( cls.apiClient, primarystorage, scope=primarystorage[TestData.scope], zoneid=cls.zone.id, provider=primarystorage[TestData.provider], tags=primarystorage[TestData.tags], capacityiops=primarystorage[TestData.capacityIops], capacitybytes=primarystorage[TestData.capacityBytes], hypervisor=primarystorage[TestData.hypervisor]) compute_offering = ServiceOffering.create( cls.apiClient, cls.testdata[TestData.computeOffering]) cls.disk_offering = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOffering]) # Create VM and volume for tests cls.virtual_machine = VirtualMachine.create( cls.apiClient, cls.testdata[TestData.virtualMachine], accountid=cls.account.name, zoneid=cls.zone.id, serviceofferingid=compute_offering.id, templateid=template.id, domainid=cls.domain.id, startvm=True) cls._cleanup = [ cls.virtual_machine, compute_offering, cls.disk_offering, user, cls.account ]
def setUpClass(cls): cls.testClient = super(TestTemplates, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services # Get Zone, Domain and templates cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.domain = get_domain(cls.api_client) cls.services['mode'] = cls.zone.networktype template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.templateSupported = True cls._cleanup = [] if cls.hypervisor.lower() in ['lxc']: cls.templateSupported = False return cls.services["virtual_machine"]["zoneid"] = cls.zone.id try: cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], ) cls._cleanup.append(cls.service_offering) # create virtual machine cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine cls.virtual_machine.stop(cls.api_client) listvolumes = Volume.list( cls.api_client, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True ) assert validateList(listvolumes)[0] == PASS, "volumes list is empty" cls.volume = listvolumes[0] except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e)