def setUpClass(cls): cloudstackTestClient = super(TestResizeVolume, 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.resourcetypemapping = {RESOURCE_PRIMARY_STORAGE: 10, RESOURCE_SECONDARY_STORAGE: 11} 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.hypervisor = str(get_hypervisor_type(cls.api_client)).lower() # Creating service offering with normal config cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) cls.services["disk_offering"]["disksize"] = 5 cls.disk_offering_5_GB = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls._cleanup.append(cls.disk_offering_5_GB) cls.services["disk_offering"]["disksize"] = 20 cls.disk_offering_20_GB = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls._cleanup.append(cls.disk_offering_20_GB) except Exception as e: cls.tearDownClass() raise unittest.SkipTest( "Failure while creating disk offering: %s" % e) return
def setUpClass(cls): cls.testClient = super(TestInstanceNameFlagTrue, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor != "vmware": raise unittest.SkipTest("Instance name configuration value\ is effective only on vmware hypervisor") 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"]) # Create account cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.account_2 = Account.create(cls.api_client, cls.services["account_2"], admin=True, domainid=cls.domain.id) 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.account, cls.account_2] return
def setUpClass(cls): cls.testClient = super(TestCreateVMSnapshotTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls._cleanup = [] 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.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.api_client) if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [ cls.service_offering, cls.account, ] return
def setUpClass(cls): testClient = super(TestNestedVirtualization, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.logger = logging.getLogger('TestNestedVirtualization') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.services["isolated_network"]["zoneid"] = cls.zone.id cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"]) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) cls.hypervisor = get_hypervisor_type(cls.apiclient) cls.isolated_network_offering = NetworkOffering.create( cls.apiclient, cls.services["isolated_network_offering"]) # Enable Isolated Network offering cls.isolated_network_offering.update(cls.apiclient, state='Enabled') if cls.template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls.cleanup = [cls.account]
def setUpClass(cls): cls.testClient = super(TestSnapshots, 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.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["domainid"] = cls.domain.id cls.services["volume"]["zoneid"] = cls.services["server_with_disk"]["zoneid"] = cls.zone.id cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskoffering"] = cls.disk_offering.id cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) # Get Hypervisor Type cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower() cls._cleanup = [cls.service_offering, cls.disk_offering] return
def setUpClass(cls): testClient = super(TestISO, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.apiclient) if cls.hypervisor.lower() in ["simulator", "lxc"]: cls.unsupportedHypervisor = True return # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services["domainid"] = cls.domain.id cls.services["iso1"]["zoneid"] = cls.zone.id cls.services["iso2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id # populate second zone id for iso copy cmd = listZones.listZonesCmd() cls.zones = cls.apiclient.listZones(cmd) if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") # Create an account, ISOs etc. cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Finding the OsTypeId from Ostype ostypes = list_os_types(cls.apiclient, description=cls.services["ostype"]) if not isinstance(ostypes, list): raise unittest.SkipTest("OSTypeId for given description not found") cls.services["iso1"]["ostypeid"] = ostypes[0].id cls.services["iso2"]["ostypeid"] = ostypes[0].id cls.services["ostypeid"] = ostypes[0].id cls.iso_1 = Iso.create(cls.apiclient, cls.services["iso1"], account=cls.account.name, domainid=cls.account.domainid) try: cls.iso_1.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s" % (cls.iso_1.id, e)) cls.iso_2 = Iso.create(cls.apiclient, cls.services["iso2"], account=cls.account.name, domainid=cls.account.domainid) try: cls.iso_2.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s" % (cls.iso_2.id, e)) return
def test_Scale_VM(self): """ @desc: 1. Enable dynamic scaling in Global settings 2. Register an CentOS 7 tempplate(with tools) and tick dynamic scaling 3. Deploy VM with this template 4.Start the VM and try to change service offering """ self.hypervisor = str(get_hypervisor_type(self.api_client)).lower() if self.hypervisor != "xenserver": self.skipTest("This test can be run only on xenserver") self.updateConfigurAndRestart("enable.dynamic.scale.vm","true") template = Template.register( self.userapiclient, self.services["CentOS7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid ) self.assertIsNotNone(template,"Failed to register CentOS 7 template") self.debug( "Registered a template with format {} and id {}".format( self.services["CentOS7template"]["format"],template.id) ) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create( self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.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") self.assertEqual(status[1].state,"Running", "vm is not running") service_offering = ServiceOffering.create( self.apiClient, self.services["service_offerings"]["big"] ) time.sleep(self.services["sleep"]) vm.scale(self.userapiclient,service_offering.id) scaleresponse = VirtualMachine.list(self.userapiclient,id=vm.id) scalestatus = validateList(scaleresponse) self.assertEqual(scalestatus[0],PASS,"list vm response returned invalid list") self.assertEqual(scalestatus[1].serviceofferingname,service_offering.name, " service offering is not same") self.assertEqual(scalestatus[1].serviceofferingid,service_offering.id, " service offering ids are not same") return
def test_03_attach_ISO_in_RHEL7OSVM(self): """ @desc:Incorrect guest os mapping in vmware for Rhel7. Add a valid RHEL7 URL to execute this test case Step1 :Register an RHEL 7 template Step2 :Launch a VM Step3: Try to attach VMware Tools ISO Step4: Verify VMware tools ISO attached correctly """ 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.services["Rhel7template"][ "url"] = "http://10.147.28.7/templates/rhel71.ova", template = Template.register(self.userapiclient, self.services["Rhel7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor) self.debug("Registered a template with format {} and id {}".format( self.services["Rhel7template"]["format"], template.id)) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create(self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=template.id, zoneid=self.zone.id) 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") list_default_iso_response = list_isos(self.api_client, name="vmware-tools.iso", account="system", isready="true") status = validateList(list_default_iso_response) self.assertEqual(PASS, status[0], "ISO list is empty") self.debug("Registered a ISO with name {}".format( list_default_iso_response[0].name)) try: vm.attach_iso(self.userapiclient, list_default_iso_response[0]) except CloudstackAPIException as e: self.fail("Attached ISO failed : %s" % e) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS, "list vm response returned invalid list") attachedIsoName = response[0].isoname self.assertEqual(attachedIsoName, "vmware-tools.iso", "vmware-tools.iso not attached") return
def test_Scale_VM(self): """ @desc: 1. Enable dynamic scaling in Global settings 2. Register an CentOS 7 tempplate(with tools) and tick dynamic scaling 3. Deploy VM with this template 4.Start the VM and try to change service offering """ self.hypervisor = str(get_hypervisor_type(self.api_client)).lower() if self.hypervisor != "xenserver": self.skipTest("This test can be run only on xenserver") self.updateConfigurAndRestart("enable.dynamic.scale.vm", "true") template = Template.register(self.userapiclient, self.services["CentOS7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.assertIsNotNone(template, "Failed to register CentOS 7 template") self.debug("Registered a template with format {} and id {}".format( self.services["CentOS7template"]["format"], template.id)) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create(self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.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") self.assertEqual(status[1].state, "Running", "vm is not running") service_offering = ServiceOffering.create( self.apiClient, self.services["service_offerings"]["big"]) time.sleep(self.services["sleep"]) vm.scale(self.userapiclient, service_offering.id) scaleresponse = VirtualMachine.list(self.userapiclient, id=vm.id) scalestatus = validateList(scaleresponse) self.assertEqual(scalestatus[0], PASS, "list vm response returned invalid list") self.assertEqual(scalestatus[1].serviceofferingname, service_offering.name, " service offering is not same") self.assertEqual(scalestatus[1].serviceofferingid, service_offering.id, " service offering ids are not same") return
def setUpClass(cls): cloudstackTestClient = super(TestResizeVolume, 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.resourcetypemapping = { RESOURCE_PRIMARY_STORAGE: 10, RESOURCE_SECONDARY_STORAGE: 11 } 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.hypervisor = str(get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor.lower() in ['hyperv']: raise unittest.SkipTest( "Volume resize is not supported on %s" % cls.hypervisor) # Creating service offering with normal config cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) cls.services["disk_offering"]["disksize"] = 5 cls.disk_offering_5_GB = DiskOffering.create( cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering_5_GB) cls.services["disk_offering"]["disksize"] = 20 cls.disk_offering_20_GB = DiskOffering.create( cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering_20_GB) except Exception as e: cls.tearDownClass() raise unittest.SkipTest( "Failure while creating disk offering: %s" % e) return
def setUpClass(cls): testClient = super(TestVmSnapshot, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) return
def setUpClass(cls): cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls._cleanup = [] # 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.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.api_client) if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id cls.services["template"] = template.id # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["server"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ cls.service_offering, cls.account, ] return
def setUpClass(cls): cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls._cleanup = [] # 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.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.api_client) if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id cls.services["template"] = template.id # Create VMs, NAT Rules etc 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) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["server"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup.append(cls.virtual_machine) return
def setUpClass(cls): cls.testClient = super(TestNetworkMigration, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.test_data = cls.testClient.getParsedTestDataConfig() cls.services = Services().services hypervisor = get_hypervisor_type(cls.api_client) if hypervisor.lower() not in ["vmware", "kvm"]: raise unittest.SkipTest("This feature is supported " "only on Vmware and KVM") # Get Domain, Zone, Template 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.test_data["ostype"]) cls.services["virtual_machine"]["template"] = cls.template.id if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.test_data["service_offerings"]["tiny"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.test_data["service_offerings"]["tiny"][ "storagetype"] = 'shared' cls.service_offering = ServiceOffering.create( cls.api_client, cls.test_data["service_offerings"]["tiny"]) # Create Network offering without userdata cls.network_offering_nouserdata = NetworkOffering.create( cls.api_client, cls.test_data["network_offering"]) # Enable Network offering cls.network_offering_nouserdata.update(cls.api_client, state='Enabled') # Create Network Offering with all the serices cls.network_offering_all = NetworkOffering.create( cls.api_client, cls.test_data["isolated_network_offering"]) # Enable Network offering cls.network_offering_all.update(cls.api_client, state='Enabled') cls.native_vpc_network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nw_offering_isolated_vpc"], conservemode=False) cls.native_vpc_network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering_nouserdata, cls.network_offering_all, cls.native_vpc_network_offering ]
def setUpClass(cls): cls.testClient = super( TestInstanceNameFlagTrue, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor != "vmware": raise unittest.SkipTest("Instance name configuration value\ is effective only on vmware hypervisor") 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"] ) # Create account cls.account = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.account_2 = Account.create( cls.api_client, cls.services["account_2"], admin=True, domainid=cls.domain.id ) 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.account, cls.account_2] return
def setUpClass(cls): cls.testClient = super(TestSnapshots, 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 = str(get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls._cleanup.append(cls.disk_offering) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["volume"]["zoneid"] = cls.services[ "server_with_disk"]["zoneid"] = cls.zone.id cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskoffering"] = cls.disk_offering.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup.append(cls.service_offering) return
def setUpClass(cls): cls.testClient = super(TestAdapterTypeForNic, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() cls.hypervisor = get_hypervisor_type(cls.api_client) # 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_test_template( cls.api_client, cls.zone.id, cls.hypervisor) # Create Accounts & networks cls.testdata["isolated_network"]["zoneid"] = cls.zone.id cls._cleanup = [] cls.account = Account.create( cls.api_client, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.userapiclient = cls.testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering) # Create Shared Network Offering cls.isolated_network_offering = NetworkOffering.create( cls.api_client, cls.testdata["isolated_network_offering"]) cls._cleanup.append(cls.isolated_network_offering) # Enable Isolated Network offering cls.isolated_network_offering.update(cls.api_client, state='Enabled') return
def setUpClass(cls): cls.testClient = super(TestSnapshots, 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.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["domainid"] = cls.domain.id cls.services["volume"]["zoneid"] = cls.services["server_with_disk"]["zoneid"] = cls.zone.id cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskoffering"] = cls.disk_offering.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls.virtual_machine = cls.virtual_machine_with_disk = VirtualMachine.create( cls.api_client, cls.services["server_with_disk"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) # Get Hypervisor Type cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower() cls._cleanup = [cls.service_offering, cls.disk_offering, cls.account] return
def setUpClass(cls): cls.testClient = super(TestSnapshots, 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.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["volume"]["zoneid"] = cls.services[ "server_with_disk"]["zoneid"] = cls.zone.id cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskoffering"] = cls.disk_offering.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) # Get Hypervisor Type cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower() cls._cleanup = [ cls.service_offering, cls.disk_offering ] return
def setUpClass(cls): testClient = super(TestNestedVirtualization, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.logger = logging.getLogger('TestNestedVirtualization') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = get_hypervisor_type(cls.apiclient) cls.services['mode'] = cls.zone.networktype cls.services["isolated_network"]["zoneid"] = cls.zone.id cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls.template = get_test_template( cls.apiclient, cls.zone.id, cls.hypervisor ) cls.isolated_network_offering = NetworkOffering.create( cls.apiclient, cls.services["isolated_network_offering"]) # Enable Isolated Network offering cls.isolated_network_offering.update(cls.apiclient, state='Enabled') if cls.template == FAILED: assert False, "get_test_template() failed to return template" cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls.cleanup = [cls.account]
def setUpClass(cls): cls.testClient = super(TestAdapterTypeForNic, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() cls.hypervisor = get_hypervisor_type(cls.api_client) # 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_test_template(cls.api_client, cls.zone.id, cls.hypervisor) # Create Accounts & networks cls.testdata["isolated_network"]["zoneid"] = cls.zone.id cls._cleanup = [] cls.account = Account.create(cls.api_client, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.userapiclient = cls.testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering) # Create Shared Network Offering cls.isolated_network_offering = NetworkOffering.create( cls.api_client, cls.testdata["isolated_network_offering"]) cls._cleanup.append(cls.isolated_network_offering) # Enable Isolated Network offering cls.isolated_network_offering.update(cls.api_client, state='Enabled') return
def setUpClass(cls): cls.testClient = super(TestSnapshots, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = test_data # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["diskoffering"] = cls.disk_offering.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [ cls.service_offering, cls.disk_offering ] return
def setUpClass(cls): testClient = super(TestISO, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.apiclient) if cls.hypervisor.lower() in ["simulator", "lxc"]: cls.unsupportedHypervisor = True return # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services["domainid"] = cls.domain.id cls.services["iso1"]["zoneid"] = cls.zone.id cls.services["iso2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id # populate second zone id for iso copy cmd = listZones.listZonesCmd() cls.zones = cls.apiclient.listZones(cmd) if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") # Create an account, ISOs etc. cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) # Finding the OsTypeId from Ostype ostypes = list_os_types( cls.apiclient, description=cls.services["ostype"] ) if not isinstance(ostypes, list): raise unittest.SkipTest("OSTypeId for given description not found") cls.services["iso1"]["ostypeid"] = ostypes[0].id cls.services["iso2"]["ostypeid"] = ostypes[0].id cls.services["ostypeid"] = ostypes[0].id cls.iso_1 = Iso.create( cls.apiclient, cls.services["iso1"], account=cls.account.name, domainid=cls.account.domainid ) try: cls.iso_1.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s" % (cls.iso_1.id, e)) cls.iso_2 = Iso.create( cls.apiclient, cls.services["iso2"], account=cls.account.name, domainid=cls.account.domainid ) try: cls.iso_2.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s" % (cls.iso_2.id, e)) return
def setUpClass(cls): testClient = super(TestVmSnapshot, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False # Setup test data td = TestData() cls.testdata = td.testdata cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) #The version of CentOS has to be supported template = get_template(cls.apiclient, cls.zone.id, account="system") import pprint 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.template = template primarystorage = cls.testdata[TestData.primaryStorage] primarystorage2 = cls.testdata[TestData.primaryStorage2] serviceOffering = cls.testdata[TestData.serviceOffering] serviceOfferingOnly = cls.testdata[TestData.serviceOfferingOnly] storage_pool = list_storage_pools(cls.apiclient, name=primarystorage.get("name")) cls.primary_storage = storage_pool[0] storage_pool = list_storage_pools(cls.apiclient, name=primarystorage2.get("name")) cls.primary_storage2 = 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="tags" # ) # if service_offering is not None: # cls.service_offering = service_offering[0] # else: # cls.service_offering = ServiceOffering.create( # cls.apiclient, # serviceOffering) #=============================================================================== service_offering_only = list_service_offering(cls.apiclient, name="cloud-test-dev-2") if service_offering_only is not None: cls.service_offering_only = service_offering_only[0] else: cls.service_offering_only = ServiceOffering.create( cls.apiclient, serviceOfferingOnly) assert cls.service_offering_only is not None cls.disk_offering = disk_offering[0] account = list_accounts(cls.apiclient, name="admin") cls.account = account[0] # Create 1 data volume_1 cls.volume = Volume.create(cls.apiclient, cls.testdata[TestData.volume_1], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name": "StorPool-%d" % random.randint(0, 100)}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering_only.id, hypervisor=cls.hypervisor, rootdisksize=10) # Resources that are to be destroyed cls._cleanup = [cls.virtual_machine, cls.volume] cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def setUpCloudStack(cls): super(TestMigrationFromUuidToGlobalIdVolumes, 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 cls._cleanup.append(cls.service_offering) 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 cls._cleanup.append(cls.service_offering2) 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") disk_offering_20 = list_disk_offering(cls.apiclient, name="Medium") disk_offering_100 = list_disk_offering(cls.apiclient, name="Large") assert disk_offering is not None assert disk_offering_20 is not None assert disk_offering_100 is not None cls.disk_offering = disk_offering[0] cls.disk_offering_20 = disk_offering_20[0] cls.disk_offering_100 = disk_offering_100[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.virtual_machine5 = 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_machine5) cls.virtual_machine6 = 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_machine6) cls.volume1 = 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.volume1) 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.volume5 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_5], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume5) cls.volume6 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_6], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls._cleanup.append(cls.volume6) cls.volume7 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_7], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls.volume8 = Volume.create(cls.apiclient, cls.testdata[TestData.volume_7], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id) cls.virtual_machine.stop(cls.apiclient, forced=True) cls.volume_on_sp_1 = cls.virtual_machine.attach_volume( cls.apiclient, cls.volume1) vol = list_volumes(cls.apiclient, id=cls.volume3.id) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume3) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume3) vol = list_volumes(cls.apiclient, id=cls.volume3.id) cls.volume_on_sp_3 = vol[0] cls.virtual_machine.attach_volume(cls.apiclient, cls.volume2) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume2) cls.virtual_machine3.attach_volume(cls.apiclient, cls.volume4) cls.virtual_machine3.detach_volume(cls.apiclient, cls.volume4) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume5) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume5) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume6) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume6) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume7) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume7) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume8) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume8) cls.virtual_machine.start(cls.apiclient) list_root = list_volumes(cls.apiclient, virtualmachineid=cls.virtual_machine5.id, type="ROOT") cls.snapshot_uuid1 = Snapshot.create(cls.apiclient, volume_id=list_root[0].id) cls._cleanup.append(cls.snapshot_uuid1) cls.snapshot_uuid2 = Snapshot.create(cls.apiclient, volume_id=list_root[0].id) cls._cleanup.append(cls.snapshot_uuid2) #Snapshot on secondary cls.helper.bypass_secondary(False) cls.snapshot_uuid_on_secondary = Snapshot.create( cls.apiclient, volume_id=list_root[0].id) cls._cleanup.append(cls.snapshot_uuid_on_secondary) cls.snapshot_uuid3 = Snapshot.create(cls.apiclient, volume_id=cls.volume7.id) cls._cleanup.append(cls.snapshot_uuid3) cls.snapshot_uuid4 = Snapshot.create(cls.apiclient, volume_id=cls.volume7.id) cls._cleanup.append(cls.snapshot_uuid4) cls.snapshot_uuid_bypassed = Snapshot.create(cls.apiclient, volume_id=list_root[0].id) cls._cleanup.append(cls.snapshot_uuid_bypassed) Volume.delete(cls.volume7, cls.apiclient) cls.helper.switch_to_globalid_commit(cls.ARGS.globalid, cls.ARGS) cfg.logger.info("The setup is done, proceeding with the tests")
def setUp(self): self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() if self.noSuitableHost or self.unsupportedHypervisor: self.hypervisor = get_hypervisor_type(self.apiclient) if self.hypervisor.lower() not in ["vmware"]: self.skipTest("Skipping test because suitable hypervisor/host not\ present") self.testdata = self.testClient.getParsedTestDataConfig() self.cleanup = [] # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) # Creating Account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) if self.hypervisor.lower() in ["xenserver"]: # Before running this test for Xen Server, register a windows template with ostype as # 'Windows 7 (32-bit)' self.template = get_template( self.apiclient, self.zone.id, self.testdata["ostype"]) self.cleanup.append(self.template) self.testdata["mode"] = self.zone.networktype if self.template == FAILED: assert False, "get_template() failed to return template with description %s" % self.testdata[ "ostype"] self.testdata["small"]["zoneid"] = self.zone.id self.testdata["small"]["template"] = self.template.id self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [ { 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, { 'vgpuType': 'GRID K120Q'}] # create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["vgpu260qwin"], ) self.cleanup.append(self.service_offering) elif self.hypervisor.lower() in ["vmware"]: self.testdata["isolated_network"]["zoneid"] = self.zone.id self.userapiclient = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain ) self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]) # Create Shared Network Offering self.isolated_network_offering = NetworkOffering.create( self.apiclient, self.testdata["isolated_network_offering"]) # Enable Isolated Network offering self.isolated_network_offering.update(self.apiclient, state='Enabled') # Register a private template in the account with nic adapter vmxnet3 # Also add required 3D GPU details for enabling it self.template = Template.register( self.userapiclient, self.testdata["configurableData"]["vmxnet3template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, details=[{"mks.enable3d" : "true", "mks.use3dRenderer" : "automatic", "svga.autodetect" : "false", "svga.vramSize" : "131072"}] )
def setUpCloudStack(cls): super(TestMigrationFromUuidToGlobalId, 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) #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.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( True, 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 setUp(self): self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() if self.noSuitableHost or self.unsupportedHypervisor: self.hypervisor = get_hypervisor_type(self.apiclient) if self.hypervisor.lower() not in ["vmware"]: self.skipTest("Skipping test because suitable hypervisor/host not\ present") 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()) # Before running this test for Xen Server, register a windows template with ostype as # 'Windows 7 (32-bit)' 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 ) self.cleanup = [] if self.hypervisor.lower() in ["xenserver"]: self.testdata["mode"] = self.zone.networktype if self.template == FAILED: assert False, "get_template() failed to return template with description %s" % self.testdata[ "ostype"] self.testdata["small"]["zoneid"] = self.zone.id self.testdata["small"]["template"] = self.template.id self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [ { 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, { 'vgpuType': 'GRID K120Q'}] # create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["vgpu260qwin"], ) # build cleanup list self.cleanup = [ self.service_offering, self.account ] elif self.hypervisor.lower() in ["vmware"]: self.testdata["isolated_network"]["zoneid"] = self.zone.id self.userapiclient = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain ) self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]) self.cleanup.append(self.service_offering) # Create Shared Network Offering self.isolated_network_offering = NetworkOffering.create( self.apiclient, self.testdata["isolated_network_offering"]) self.cleanup.append(self.isolated_network_offering) # Enable Isolated Network offering self.isolated_network_offering.update(self.apiclient, state='Enabled')
def test_08_migrate_vm(self): """Test migrate VM """ # Validate the following # 1. Environment has enough hosts for migration # 2. DeployVM on suitable host (with another host in the cluster) # 3. Migrate the VM and assert migration successful suitable_hosts = None hosts = Host.list( self.apiclient, zoneid=self.zone.id, type='Routing' ) self.assertEqual(validateList(hosts)[0], PASS, "hosts list validation failed") if len(hosts) < 2: self.skipTest("At least two hosts should be present in the zone for migration") hypervisor = str(get_hypervisor_type(self.apiclient)).lower() # For KVM, two hosts used for migration should be present in same cluster # For XenServer and VMware, migration is possible between hosts belonging to different clusters # with the help of XenMotion and Vmotion respectively. if hypervisor.lower() in ["kvm","simulator"]: #identify suitable host clusters = [h.clusterid for h in hosts] #find hosts withe same clusterid clusters = [cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1] if len(clusters) <= 1: self.skipTest("In " + hypervisor.lower() + " Live Migration needs two hosts within same cluster") suitable_hosts = [host for host in hosts if host.clusterid == clusters[0]] else: suitable_hosts = hosts target_host = suitable_hosts[0] migrate_host = suitable_hosts[1] #deploy VM on target host self.vm_to_migrate = VirtualMachine.create( self.apiclient, self.services["small"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.small_offering.id, mode=self.services["mode"], hostid=target_host.id ) self.debug("Migrating VM-ID: %s to Host: %s" % ( self.vm_to_migrate.id, migrate_host.id )) self.vm_to_migrate.migrate(self.apiclient, migrate_host.id) retries_cnt = 3 while retries_cnt >=0: list_vm_response = VirtualMachine.list(self.apiclient, id=self.vm_to_migrate.id) self.assertNotEqual( list_vm_response, None, "Check virtual machine is listed" ) vm_response = list_vm_response[0] self.assertEqual(vm_response.id,self.vm_to_migrate.id,"Check virtual machine ID of migrated VM") self.assertEqual(vm_response.hostid,migrate_host.id,"Check destination hostID of migrated VM") retries_cnt = retries_cnt - 1 return
def setUpCloudStack(cls): super(TestMigrationFromUuidToGlobalIdVolumes, 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.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) 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] serviceOffering2 = cls.testdata[TestData.serviceOfferingssd2] 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" ) disk_offering_20 = list_disk_offering( cls.apiclient, name="Medium" ) disk_offering_100 = list_disk_offering( cls.apiclient, name="Large" ) assert disk_offering is not None assert disk_offering_20 is not None assert disk_offering_100 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 service_offering2 = list_service_offering( cls.apiclient, name="ssd2" ) if service_offering2 is not None: cls.service_offering2 = service_offering2[0] else: cls.service_offering2 = ServiceOffering.create( cls.apiclient, serviceOffering2) assert cls.service_offering2 is not None cls.disk_offering = disk_offering[0] cls.disk_offering_20 = disk_offering_20[0] cls.disk_offering_100 = disk_offering_100[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.virtual_machine5 = 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_machine5) cls.virtual_machine6 = 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_machine6) cls.volume1 = 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.volume1) 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.volume5 = Volume.create( cls.apiclient, cls.testdata[TestData.volume_5], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id ) cls._cleanup.append(cls.volume5) cls.volume6 = Volume.create( cls.apiclient, cls.testdata[TestData.volume_6], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id ) cls._cleanup.append(cls.volume6) cls.volume7 = Volume.create( cls.apiclient, cls.testdata[TestData.volume_7], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id ) cls.virtual_machine.stop(cls.apiclient, forced=True) cls.volume_on_sp_1 = cls.virtual_machine.attach_volume(cls.apiclient, cls.volume1) vol = list_volumes(cls.apiclient, id = cls.volume3.id) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume3) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume3) vol = list_volumes(cls.apiclient, id = cls.volume3.id) cls.volume_on_sp_3 = vol[0] cls.virtual_machine.attach_volume(cls.apiclient, cls.volume2) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume2) cls.virtual_machine3.attach_volume(cls.apiclient, cls.volume4) cls.virtual_machine3.detach_volume(cls.apiclient, cls.volume4) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume5) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume5) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume6) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume6) cls.virtual_machine.attach_volume(cls.apiclient, cls.volume7) cls.virtual_machine.detach_volume(cls.apiclient, cls.volume7) cls.virtual_machine.start(cls.apiclient) list_root = list_volumes(cls.apiclient, virtualmachineid = cls.virtual_machine5.id, type = "ROOT") cls.snapshot_uuid1 = Snapshot.create(cls.apiclient, volume_id = list_root[0].id) cls._cleanup.append(cls.snapshot_uuid1) cls.snapshot_uuid2 = Snapshot.create(cls.apiclient, volume_id = list_root[0].id) cls._cleanup.append(cls.snapshot_uuid2) #Snapshot on secondary cls.helper.bypass_secondary(False) cls.snapshot_uuid_on_secondary = Snapshot.create(cls.apiclient, volume_id = list_root[0].id) cls._cleanup.append(cls.snapshot_uuid_on_secondary) cls.snapshot_uuid3 = Snapshot.create(cls.apiclient, volume_id = cls.volume7.id) cls._cleanup.append(cls.snapshot_uuid3) cls.snapshot_uuid4 = Snapshot.create(cls.apiclient, volume_id = cls.volume7.id) cls._cleanup.append(cls.snapshot_uuid4) cls.helper.bypass_secondary(True) cls.snapshot_uuid_bypassed = Snapshot.create(cls.apiclient, volume_id = list_root[0].id) cls._cleanup.append(cls.snapshot_uuid_bypassed) Volume.delete(cls.volume7, cls.apiclient) cls.helper.switch_to_globalid_commit(cls.ARGS.globalid, cls.ARGS) cfg.logger.info("The setup is done, proceeding with the tests")
def test_01_attach_volume_ide(self): """ @desc: Exception when attaching data disk to RHEL VM on vSphere Step1: Confirm that vmware.root.disk.controller = "ide" in Global Settings. Step2: Register RHEl 6.0 template and deploy a VM. Step3: Note that the root disk is attached to IDE. Step4: Create new DATA disk and attempt to attach it 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") cmd = listConfigurations.listConfigurationsCmd() cmd.name = "vmware.root.disk.controller" cmd.listAll = True try: config_descs = self.api_client.listConfigurations(cmd) except Exception as e: raise Exception("Failed to fetch configurations: %s" % e) if not isinstance(config_descs, list): raise Exception("List configs didn't returned a valid data") config_desc = config_descs[0] if str(config_desc.value).lower() != "ide": self.skipTest( "This test is invalid if {} is not set to ide".format( config_desc.name)) """ Register RHEL 6.0 template and deploy vm """ template = Template.register(self.userapiclient, self.services["rhel60template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor) self.assertIsNotNone(template, "Failed to register Rhel6 template") self.debug("Registered a template with format {} and id {}".format( self.services["rhel60template"]["format"], template.id)) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create(self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.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") """ list root disk of the vm created above and make sure that device type is ide """ volume_res = Volume.list(self.userapiclient, virtualmachineid=vm.id, type="root", listAll="true") self.assertEqual( validateList(volume_res)[0], PASS, "list vm response returned invalid list") chaininfo = volume_res[0].chaininfo device_Bus = literal_eval(chaininfo)["diskDeviceBusName"] if "ide" not in device_Bus: self.fail("Root disk is not created with device type IDE") 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 RHEL vm whose root disk type is IDE" ) return
def setUp(self): self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() if self.noSuitableHost or self.unsupportedHypervisor: self.hypervisor = get_hypervisor_type(self.apiclient) if self.hypervisor.lower() not in ["vmware"]: self.skipTest( "Skipping test because suitable hypervisor/host not\ present") self.testdata = self.testClient.getParsedTestDataConfig() self.cleanup = [] # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) # Creating Account self.account = Account.create(self.apiclient, self.testdata["account"], domainid=self.domain.id) if self.hypervisor.lower() in ["xenserver"]: # Before running this test for Xen Server, register a windows template with ostype as # 'Windows 7 (32-bit)' self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) self.cleanup.append(self.template) self.testdata["mode"] = self.zone.networktype if self.template == FAILED: assert False, "get_template() failed to return template with description %s" % self.testdata[ "ostype"] self.testdata["small"]["zoneid"] = self.zone.id self.testdata["small"]["template"] = self.template.id self.testdata["service_offerings"]["vgpu260qwin"][ "serviceofferingdetails"] = [{ 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs' }, { 'vgpuType': 'GRID K120Q' }] # create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["vgpu260qwin"], ) self.cleanup.append(self.service_offering) elif self.hypervisor.lower() in ["vmware"]: self.testdata["isolated_network"]["zoneid"] = self.zone.id self.userapiclient = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]) # Create Shared Network Offering self.isolated_network_offering = NetworkOffering.create( self.apiclient, self.testdata["isolated_network_offering"]) # Enable Isolated Network offering self.isolated_network_offering.update(self.apiclient, state='Enabled') # Register a private template in the account with nic adapter vmxnet3 # Also add required 3D GPU details for enabling it self.template = Template.register( self.userapiclient, self.testdata["configurableData"]["vmxnet3template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, details=[{ "mks.enable3d": "true", "mks.use3dRenderer": "automatic", "svga.autodetect": "false", "svga.vramSize": "131072" }])
def setUpCloudStack(cls): super(TestMigrationFromUuidToGlobalId, 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.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) 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] primarystorage2 = cls.testdata[TestData.primaryStorage2] serviceOffering = cls.testdata[TestData.serviceOffering] serviceOffering2 = cls.testdata[TestData.serviceOfferingssd2] storage_pool = list_storage_pools(cls.apiclient, name=primarystorage.get("name")) storage_pool2 = list_storage_pools(cls.apiclient, name=primarystorage2.get("name")) cls.primary_storage = storage_pool[0] cls.primary_storage2 = storage_pool2[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 service_offering2 = list_service_offering(cls.apiclient, name="ssd2") if service_offering2 is not None: cls.service_offering2 = service_offering2[0] else: cls.service_offering2 = ServiceOffering.create( cls.apiclient, serviceOffering2) assert cls.service_offering2 is not None nfs_service_offerings = { "name": "nfs", "displaytext": "NFS service offerings", "cpunumber": 1, "cpuspeed": 500, "memory": 512, "storagetype": "shared", "customizediops": False, "hypervisorsnapshotreserve": 200, "tags": "nfs" } nfs_storage_pool = list_storage_pools(cls.apiclient, name='primary') nfs_service_offering = list_service_offering(cls.apiclient, name='nfs') if nfs_service_offering is None: nfs_service_offering = ServiceOffering.create( cls.apiclient, nfs_service_offerings) else: nfs_service_offering = nfs_service_offering[0] cls.nfs_service_offering = nfs_service_offering cls.nfs_storage_pool = nfs_storage_pool[0] cls.nfs_storage_pool = StoragePool.cancelMaintenance( cls.apiclient, cls.nfs_storage_pool.id) 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.nfs_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.nfs_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_offering2.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.primary_storage = StoragePool.update(cls.apiclient, id=cls.primary_storage.id, tags=["ssd, nfs, ssd2"]) cls.primary_storage2 = StoragePool.update(cls.apiclient, id=cls.primary_storage2.id, tags=["ssd, ssd2"]) #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") cls.primary_storage = list_storage_pools( cls.apiclient, name=primarystorage.get("name"))[0] cls.primary_storage2 = list_storage_pools( cls.apiclient, name=primarystorage2.get("name"))[0]
def setUpClass(cls): # Set up API client testclient = super(TestVolumes, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.dbConnection = testclient.getDbConnection() cls.services = testclient.getParsedTestDataConfig() # Setup test data td = TestData() cls.testdata = td.testdata # Get Resources from Cloud Infrastructure cls.domain = get_domain(cls.apiClient) cls.zone = get_zone(cls.apiClient, testclient.getZoneForTests()) cls.cluster = list_clusters(cls.apiClient)[0] cls.hypervisor = get_hypervisor_type(cls.apiClient) cls.template = get_template( cls.apiClient, cls.zone.id, account = "system" ) primarystorage = cls.testdata[TestData.primaryStorage] primarystorage2 = cls.testdata[TestData.primaryStorage2] serviceOffering = cls.testdata[TestData.serviceOffering] serviceOfferingOnly = cls.testdata[TestData.serviceOfferingOnly] storage_pool = list_storage_pools( cls.apiClient, name = primarystorage.get("name") ) cls.primary_storage = storage_pool[0] storage_pool = list_storage_pools( cls.apiClient, name = primarystorage2.get("name") ) cls.primary_storage2 = 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="cloud-test-dev-1" ) if service_offering is not None: cls.service_offering = service_offering[0] else: cls.service_offering = ServiceOffering.create( cls.apiClient, serviceOffering) service_offering_only = list_service_offering( cls.apiClient, name="cloud-test-dev-2" ) if service_offering_only is not None: cls.service_offering_only = service_offering_only[0] else: cls.service_offering_only = ServiceOffering.create( cls.apiClient, serviceOfferingOnly) assert cls.service_offering_only is not None cls.disk_offering = disk_offering[0] account = list_accounts( cls.apiClient, name="admin" ) cls.account = account[0] # Create 1 data volume_1 cls.volume = Volume.create( cls.apiClient, cls.testdata[TestData.volume_1], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id ) cls.virtual_machine = VirtualMachine.create( cls.apiClient, {"name":"StorPool-%d" % random.randint(0, 100)}, zoneid=cls.zone.id, templateid=cls.template.id, serviceofferingid=cls.service_offering_only.id, hypervisor=cls.hypervisor, rootdisksize=10 ) # Resources that are to be destroyed cls._cleanup = [ cls.virtual_machine, cls.volume ]
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.testClient = super(TestNetworkMigration, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.test_data = cls.testClient.getParsedTestDataConfig() cls.services = Services().services hypervisor = get_hypervisor_type(cls.api_client) if hypervisor.lower() not in ["vmware", "kvm"]: raise unittest.SkipTest("This feature is supported " "only on Vmware and KVM") # Get Domain, Zone, Template 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.test_data["ostype"] ) cls.services["virtual_machine"]["template"] = cls.template.id if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.test_data["service_offerings"][ "tiny"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.test_data["service_offerings"][ "tiny"]["storagetype"] = 'shared' cls.service_offering = ServiceOffering.create( cls.api_client, cls.test_data["service_offerings"]["tiny"] ) # Create Network offering without userdata cls.network_offering_nouserdata = NetworkOffering.create( cls.api_client, cls.test_data["network_offering"] ) # Enable Network offering cls.network_offering_nouserdata.update(cls.api_client, state='Enabled') # Create Network Offering with all the serices cls.network_offering_all = NetworkOffering.create( cls.api_client, cls.test_data["isolated_network_offering"] ) # Enable Network offering cls.network_offering_all.update(cls.api_client, state='Enabled') cls.native_vpc_network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nw_offering_isolated_vpc"], conservemode=False) cls.native_vpc_network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering_nouserdata, cls.network_offering_all, cls.native_vpc_network_offering ]
def test3_attach_ISO_in_RHEL7OSVM(self): """ @desc:Incorrect guest os mapping in vmware for Rhel7. Add a valid RHEL7 URL to execute this test case Step1 :Register an RHEL 7 template Step2 :Launch a VM Step3: Try to attach VMware Tools ISO Step4: Verify VMware tools ISO attached correctly """ 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.services["Rhel7template"]["url"]="http://10.147.28.7/templates/rhel71.ova", template = Template.register( self.userapiclient, self.services["Rhel7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor ) self.debug( "Registered a template with format {} and id {}".format( self.services["Rhel7template"]["format"],template.id) ) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create( self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=template.id, zoneid=self.zone.id ) 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") list_default_iso_response = list_isos( self.api_client, name="vmware-tools.iso", account="system", isready="true" ) status = validateList(list_default_iso_response) self.assertEquals( PASS, status[0], "ISO list is empty") self.debug( "Registered a ISO with name {}".format(list_default_iso_response[0].name)) try: vm.attach_iso(self.userapiclient,list_default_iso_response[0]) except CloudstackAPIException as e: self.fail("Attached ISO failed : %s" % e) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS,"list vm response returned invalid list") attachedIsoName=response[0].isoname; self.assertEqual(attachedIsoName, "vmware-tools.iso", "vmware-tools.iso not attached") return
def setUpCloudStack(cls): super(MigrationUuidToGlobalIdLiveMigration, 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] disk_offering_20 = list_disk_offering(cls.apiclient, name="Medium") cls.disk_offering_20 = disk_offering_20[0] account = list_accounts(cls.apiclient, name="admin") cls.account = account[0] cls.local_cluster = cls.helper.get_local_cluster() cls.host = cls.helper.list_hosts_by_cluster_id(cls.local_cluster.id) assert len(cls.host) > 1, "Hosts list is less than 1" cls.host_on_local_1 = cls.host[0] cls.host_on_local_2 = cls.host[1] cls.remote_cluster = cls.helper.get_remote_cluster() cls.host_remote = cls.helper.list_hosts_by_cluster_id( cls.remote_cluster.id) assert len(cls.host_remote) > 1, "Hosts list is less than 1" cls.host_on_remote1 = cls.host_remote[0] cls.host_on_remote2 = cls.host_remote[1] cls.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, hostid=cls.host_on_local_1.id, rootdisksize=10) cls._cleanup.append(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) cls._cleanup.append(cls.volume) #vm and volume on remote cls.virtual_machine_remote = 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, hostid=cls.host_on_remote1.id, rootdisksize=10) cls._cleanup.append(cls.virtual_machine_remote) cls.volume_remote = 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_remote) #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 setUpCloudStack(cls): testClient = super(TestVmSnapshot, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False # Setup test data td = TestData() cls.testdata = td.testdata cls.helper = StorPoolHelper() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = None zones = list_zones(cls.apiclient) for z in zones: if z.name == cls.getClsConfig().mgtSvr[0].zone: cls.zone = z assert cls.zone is not None cls.cluster = list_clusters(cls.apiclient)[0] cls.hypervisor = get_hypervisor_type(cls.apiclient) #The version of CentOS has to be supported template = get_template( cls.apiclient, cls.zone.id, account = "system" ) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] cls.template = template cls.account = cls.helper.create_account( cls.apiclient, cls.services["account"], accounttype = 1, domainid=cls.domain.id, roleid = 1 ) cls._cleanup.append(cls.account) securitygroup = SecurityGroup.list(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid)[0] cls.helper.set_securityGroups(cls.apiclient, account = cls.account.name, domainid= cls.account.domainid, id = securitygroup.id) primarystorage = cls.testdata[TestData.primaryStorage] serviceOffering = cls.testdata[TestData.serviceOffering] storage_pool = list_storage_pools( cls.apiclient, name = primarystorage.get("name") ) cls.primary_storage = storage_pool[0] disk_offering = list_disk_offering( cls.apiclient, name="ssd" ) assert disk_offering is not None service_offering_only = list_service_offering( cls.apiclient, name="ssd" ) if service_offering_only is not None: cls.service_offering_only = service_offering_only[0] else: cls.service_offering_only = ServiceOffering.create( cls.apiclient, serviceOffering) assert cls.service_offering_only is not None cls.disk_offering = disk_offering[0] # Create 1 data volume_1 cls.volume = Volume.create( cls.apiclient, cls.testdata[TestData.volume_1], account=cls.account.name, domainid=cls.domain.id, zoneid=cls.zone.id, diskofferingid=cls.disk_offering.id, size=10 ) cls.virtual_machine = VirtualMachine.create( cls.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=cls.zone.id, templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_only.id, hypervisor=cls.hypervisor, rootdisksize=10 ) cls.random_data_0 = random_gen(size=100) cls.test_dir = "/tmp" cls.random_data = "random.data" return
def setUp(self): self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() if self.noSuitableHost or self.unsupportedHypervisor: self.hypervisor = get_hypervisor_type(self.apiclient) if self.hypervisor.lower() not in ["vmware"]: self.skipTest( "Skipping test because suitable hypervisor/host not\ present") 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()) # Before running this test for Xen Server, register a windows template with ostype as # 'Windows 7 (32-bit)' 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) self.cleanup = [] if self.hypervisor.lower() in ["xenserver"]: self.testdata["mode"] = self.zone.networktype if self.template == FAILED: assert False, "get_template() failed to return template with description %s" % self.testdata[ "ostype"] self.testdata["small"]["zoneid"] = self.zone.id self.testdata["small"]["template"] = self.template.id self.testdata["service_offerings"]["vgpu260qwin"][ "serviceofferingdetails"] = [{ 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs' }, { 'vgpuType': 'GRID K120Q' }] # create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["vgpu260qwin"], ) # build cleanup list self.cleanup = [self.service_offering, self.account] elif self.hypervisor.lower() in ["vmware"]: self.testdata["isolated_network"]["zoneid"] = self.zone.id self.userapiclient = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]) self.cleanup.append(self.service_offering) # Create Shared Network Offering self.isolated_network_offering = NetworkOffering.create( self.apiclient, self.testdata["isolated_network_offering"]) self.cleanup.append(self.isolated_network_offering) # Enable Isolated Network offering self.isolated_network_offering.update(self.apiclient, state='Enabled')
def test1_attach_volume_ide(self): """ @desc: Exception when attaching data disk to RHEL VM on vSphere Step1: Confirm that vmware.root.disk.controller = "ide" in Global Settings. Step2: Register RHEl 6.0 template and deploy a VM. Step3: Note that the root disk is attached to IDE. Step4: Create new DATA disk and attempt to attach it 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") cmd = listConfigurations.listConfigurationsCmd() cmd.name = "vmware.root.disk.controller" cmd.listAll = True try: config_descs = self.api_client.listConfigurations(cmd) except Exception as e: raise Exception("Failed to fetch configurations: %s" % e) if not isinstance(config_descs, list): raise Exception("List configs didn't returned a valid data") config_desc = config_descs[0] if str(config_desc.value).lower() != "ide": self.skipTest("This test is invalid if {} is not set to ide".format(config_desc.name)) """ Register RHEL 6.0 template and deploy vm """ template = Template.register( self.userapiclient, self.services["rhel60template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor ) self.assertIsNotNone(template,"Failed to register Rhel6 template") self.debug( "Registered a template with format {} and id {}".format( self.services["rhel60template"]["format"],template.id) ) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create( self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.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") """ list root disk of the vm created above and make sure that device type is ide """ volume_res = Volume.list( self.userapiclient, virtualmachineid=vm.id, type="root", listAll="true" ) self.assertEqual(validateList(volume_res)[0],PASS,"list vm response returned invalid list") chaininfo = volume_res[0].chaininfo device_Bus = literal_eval(chaininfo)["diskDeviceBusName"] if "ide" not in device_Bus: self.fail("Root disk is not created with device type IDE") 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 RHEL vm whose root disk type is IDE") return
def test_08_migrate_vm(self): """Test migrate VM """ # Validate the following # 1. Environment has enough hosts for migration # 2. DeployVM on suitable host (with another host in the cluster) # 3. Migrate the VM and assert migration successful suitable_hosts = None hosts = Host.list(self.apiclient, zoneid=self.zone.id, type='Routing') self.assertEqual( validateList(hosts)[0], PASS, "hosts list validation failed") if len(hosts) < 2: self.skipTest( "At least two hosts should be present in the zone for migration" ) hypervisor = str(get_hypervisor_type(self.apiclient)).lower() # For KVM, two hosts used for migration should be present in same cluster # For XenServer and VMware, migration is possible between hosts belonging to different clusters # with the help of XenMotion and Vmotion respectively. if hypervisor.lower() in ["kvm", "simulator"]: #identify suitable host clusters = [h.clusterid for h in hosts] #find hosts withe same clusterid clusters = [ cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1 ] if len(clusters) <= 1: self.skipTest( "In " + hypervisor.lower() + " Live Migration needs two hosts within same cluster") suitable_hosts = [ host for host in hosts if host.clusterid == clusters[0] ] else: suitable_hosts = hosts target_host = suitable_hosts[0] migrate_host = suitable_hosts[1] #deploy VM on target host self.vm_to_migrate = VirtualMachine.create( self.apiclient, self.services["small"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.small_offering.id, mode=self.services["mode"], hostid=target_host.id) self.debug("Migrating VM-ID: %s to Host: %s" % (self.vm_to_migrate.id, migrate_host.id)) self.vm_to_migrate.migrate(self.apiclient, migrate_host.id) retries_cnt = 3 while retries_cnt >= 0: list_vm_response = VirtualMachine.list(self.apiclient, id=self.vm_to_migrate.id) self.assertNotEqual(list_vm_response, None, "Check virtual machine is listed") vm_response = list_vm_response[0] self.assertEqual(vm_response.id, self.vm_to_migrate.id, "Check virtual machine ID of migrated VM") self.assertEqual(vm_response.hostid, migrate_host.id, "Check destination hostID of migrated VM") retries_cnt = retries_cnt - 1 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