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(TestSnapshotOnRootVolume, 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.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("snapshots are not supported on %s" % cls.hypervisor.lower()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) 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.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [ cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2 ]
def setUpClass(cls): testClient = super(TestCreateVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls.sparse_disk_offering = DiskOffering.create(cls.apiclient, cls.services["sparse_disk_offering"]) cls.custom_disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"], custom=True) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id cls.services["diskname"] = cls.services["volume"]["diskname"] # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offerings"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) cls._cleanup = [cls.service_offering, cls.disk_offering, cls.custom_disk_offering, cls.account]
def setUpClass(cls): cls.testClient = super(TestSnapshotOnRootVolume, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # pdb.set_trace() cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [ cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2 ]
def setUpClass(cls): testClient = super(TestVolumes, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = testClient.getHypervisorInfo() cls.invalidStoragePoolType = False cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls.resized_disk_offering = DiskOffering.create( cls.apiclient, cls.services["resized_disk_offering"]) cls.custom_resized_disk_offering = DiskOffering.create( cls.apiclient, cls.services["resized_disk_offering"], custom=True) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = cls.disk_offering.id cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id cls.services[ 'customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id # Create VMs, VMs etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"]) pools = StoragePool.list(cls.apiclient) # cls.assertEqual( # validateList(pools)[0], # PASS, # "storage pool list validation failed") cls.volume = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup = [ cls.resized_disk_offering, cls.custom_resized_disk_offering, cls.service_offering, cls.disk_offering, cls.volume, cls.account ]
def setUpClass(cls): testClient = super(TestCreateVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"] ) cls.sparse_disk_offering = DiskOffering.create( cls.apiclient, cls.services["sparse_disk_offering"] ) cls.custom_disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"], custom=True ) template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id cls.services["diskname"] = cls.services["volume"]["diskname"] # Create VMs, NAT Rules etc cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) cls._cleanup = [ cls.service_offering, cls.disk_offering, cls.custom_disk_offering, cls.account ]
def setUpClass(cls): testClient = super(TestCreateVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls._cleanup = [] cls.hypervisor = testClient.getHypervisorInfo() cls.services['mode'] = cls.zone.networktype cls.invalidStoragePoolType = False # for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test if cls.hypervisor.lower() == 'lxc': if not find_storage_pool_type(cls.apiclient, storagetype='rbd'): # RBD storage type is required for data volumes for LXC cls.invalidStoragePoolType = True return cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) cls.sparse_disk_offering = DiskOffering.create( cls.apiclient, cls.services["sparse_disk_offering"]) cls._cleanup.append(cls.sparse_disk_offering) cls.custom_disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"], custom=True) cls._cleanup.append(cls.custom_disk_offering) template = get_suitable_test_template(cls.apiclient, cls.zone.id, cls.services["ostype"], cls.hypervisor) if template == FAILED: assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services[ "ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id cls.services["diskname"] = cls.services["volume"]["diskname"] # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"]) cls._cleanup.append(cls.virtual_machine)
def setUpClass(cls): testClient = super(TestVolumes, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.hypervisor = testClient.getHypervisorInfo() cls.invalidStoragePoolType = False cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls.resized_disk_offering = DiskOffering.create(cls.apiclient, cls.services["resized_disk_offering"]) cls.custom_resized_disk_offering = DiskOffering.create( cls.apiclient, cls.services["resized_disk_offering"], custom=True ) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = cls.disk_offering.id cls.services["resizeddiskofferingid"] = cls.resized_disk_offering.id cls.services["customresizeddiskofferingid"] = cls.custom_resized_disk_offering.id # Create VMs, VMs etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offerings"]["tiny"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) pools = StoragePool.list(cls.apiclient) # cls.assertEqual( # validateList(pools)[0], # PASS, # "storage pool list validation failed") cls.volume = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup = [ cls.resized_disk_offering, cls.custom_resized_disk_offering, cls.service_offering, cls.disk_offering, cls.volume, cls.account, ]
def setUpClass(cls): 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): cls.testClient = super(TestDeployVMFromISO, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.testdata["ostype"] ) # Create service, disk offerings etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering"] ) cls.disk_offering = DiskOffering.create( cls.api_client, cls.testdata["disk_offering"] ) cls._cleanup = [ cls.service_offering, cls.disk_offering ] return
def setUpClass(cls): testClient = super(TestDomainsDiskOfferings, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Create domains cls.domain_1 = Domain.create(cls.apiclient, cls.services["acl"]["domain1"]) cls.domain_11 = Domain.create(cls.apiclient, cls.services["acl"]["domain11"], parentdomainid=cls.domain_1.id) cls.domain_2 = Domain.create(cls.apiclient, cls.services["acl"]["domain2"]) cls.domain_3 = Domain.create(cls.apiclient, cls.services["acl"]["domain12"]) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"], domainid=cls.domain_1.id) cls._cleanup = [ cls.disk_offering, cls.domain_11, cls.domain_1, cls.domain_2, cls.domain_3 ] return
def setUpClass(cls): cls.testClient = super(TestVolumes, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() == 'lxc': if not find_storage_pool_type(cls.api_client, storagetype='rbd'): raise unittest.SkipTest("RBD storage type is required for data volumes for LXC") cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id cls.services["virtual_machine"][ "diskofferingid"] = cls.disk_offering.id # Create VMs, VMs 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.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls.volume = Volume.create( cls.api_client, cls.services["volume"], zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid, diskofferingid=cls.disk_offering.id ) cls._cleanup = [ cls.service_offering, cls.disk_offering, cls.account ]
def setUpClass(cls): cls.testClient = super(TestDeployVmWithCustomDisk, 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"], custom=True) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.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.disk_offering, cls.account]
def setUpClass(cls): cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["server"]["zoneid"] = cls.zone.id # Create Domains, Account etc cls.domain = Domain.create(cls.api_client, cls.services["domain"]) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain) # Create project as a domain admin cls.project = Project.create( cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid ) cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup = [cls.project, cls.service_offering, cls.disk_offering, cls.account, cls.domain] return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestSnapshots, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ("lxc", "hyperv"): cls.unsupportedHypervisor = True return # 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.services["ostype"]) if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.services["service_offerings"]["tiny"][ "storagetype"] = 'local' cls.services["disk_offering"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.services["service_offerings"]["tiny"][ "storagetype"] = 'shared' cls.services["disk_offering"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["custom_volume"]["zoneid"] = cls.zone.id # Creating Disk offering, Service Offering and Account cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["tiny"]) cls._cleanup.append(cls.service_offering) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # Getting authentication for user in newly created Account cls.user = cls.account.user[0] cls.userapiclient = cls.testClient.getUserApiClient( cls.user.username, cls.domain.name) cls._cleanup.append(cls.account) # Creating Virtual Machine cls.virtual_machine = VirtualMachine.create( cls.userapiclient, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) 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(TestAttachDataDiskOnCWPS, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls._cleanup = [] cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls.skiptest = False try: cls.pools = StoragePool.list( cls.apiclient, zoneid=cls.zone.id, scope="CLUSTER") except Exception as e: cls.skiptest = True return try: # Create an account cls.account = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) # Create Disk offering cls.disk_offering = DiskOffering.create( cls.apiclient, cls.testdata["disk_offering"], custom=True, tags=CLUSTERTAG1, ) cls._cleanup.append(cls.disk_offering) except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): cls.testClient = super(TestRecurringSnapshots, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["domainid"] = cls.domain.id 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"] = 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._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_with_disk = \ VirtualMachine.create( cls.api_client, cls.services["server_with_disk"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.virtual_machine_without_disk = \ VirtualMachine.create( cls.api_client, cls.services["server_without_disk"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) 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() 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"]) cls._cleanup = [cls.service_offering, cls.disk_offering] return
def setUpClass(cls): cloudstacktestclient = super(TestPrimaryResourceLimitsVolume, 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 cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls.services["disk_offering"]["disksize"] = 2 cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.disk_offering) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def test_01_create_disk_offering(self): """Test to create disk offering # Validate the following: # 1. createDiskOfferings should return valid info for new offering # 2. The Cloud Database contains the valid information """ offering_data_domainid = "{0},{1}".format(self.domain_11.id, self.domain_2.id) disk_offering = DiskOffering.create(self.apiclient, self.services["disk_offering"], domainid=offering_data_domainid) self.cleanup.append(disk_offering) self.debug("Created Disk offering with ID: %s" % disk_offering.id) list_disk_response = list_disk_offering(self.apiclient, id=disk_offering.id) self.assertEqual(isinstance(list_disk_response, list), True, "Check list response returns a valid list") self.assertNotEqual(len(list_disk_response), 0, "Check Disk offering is created") disk_response = list_disk_response[0] self.assertEqual(disk_response.displaytext, self.services["disk_offering"]["displaytext"], "Check server displaytext in createDiskOffering") self.assertEqual(disk_response.name, self.services["disk_offering"]["name"], "Check name in createDiskOffering") self.assertItemsEqual(disk_response.domainid.split(","), offering_data_domainid.split(","), "Check domainid in createDiskOffering") return
def test_02_list_all_diskofferings_with_noparams(self): """ Test List Disk Offerings with No Parameters """ diskofferingvailable=0 listdiskofferings=DiskOffering.list(self.user_api_client) self.assertEqual( isinstance(listdiskofferings, list), True, "Check list Disk Offerings response returns a valid list" ) for diskoffering1 in listdiskofferings: if diskoffering1.name=="Small": diskofferingvailable=diskofferingvailable+1 elif diskoffering1.name=="Medium": diskofferingvailable=diskofferingvailable+1 elif diskoffering1.name=="Large": diskofferingvailable=diskofferingvailable+1 elif diskoffering1.name=="Custom": diskofferingvailable=diskofferingvailable+1 if diskofferingvailable<4: self.fail("All the default disk offerings are not listed")
def setUpClass(cls): cls.testClient = super(TestAsyncJob, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() cls.template = get_test_template( cls.api_client, cls.zone.id, cls.hypervisor ) cls._cleanup = [] # Create service, disk offerings etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering"] ) cls._cleanup.append(cls.service_offering) cls.disk_offering = DiskOffering.create( cls.api_client, cls.testdata["disk_offering"] ) cls._cleanup.append(cls.disk_offering)
def setUpClass(cls): cls.testClient = super(TestDeployVmWithCustomDisk, 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.unsupportedStorageType = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() == "lxc": if not find_storage_pool_type(cls.api_client, storagetype="rbd"): cls.unsupportedStorageType = True return cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"], custom=True) cls._cleanup.append(cls.disk_offering) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["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.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering)
def setUpClass(cls): cloudstacktestclient = super(TestPrimaryResourceLimitsVolume, 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 cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id try: cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.services["disk_offering"]["disksize"] = 2 cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.disk_offering) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def setUpClass(cls): cls.testClient = super(TestMigrateVolume, 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"]) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id cls.services["virtual_machine"][ "diskofferingid"] = cls.disk_offering.id # Create VMs, VMs etc cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.small_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls._cleanup = [cls.small_offering, cls.account] return
def setUpClass(cls): testClient = super(TestMultipleVolumeSnapshots, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.skiptest = False clus_list = list_clusters(cls.apiclient) if cls.hypervisor.lower() not in ['vmware'] or len(clus_list) < 2: cls.skiptest = True return try: # Create an account cls.account = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) # Create Service offering cls.service_offering_zwps = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], tags=ZONETAG1 ) cls.disk_offering_zwps = DiskOffering.create( cls.apiclient, cls.testdata["disk_offering"], tags=ZONETAG1 ) cls._cleanup = [ cls.account, cls.service_offering_zwps, cls.disk_offering_zwps, ] except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): testClient = super(TestStorageSnapshotsLimits, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.snapshotSupported = True if cls.hypervisor.lower() in ["hyperv", "lxc"]: cls.snapshotSupported = False return try: # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) cls.disk_offering = DiskOffering.create( cls.apiclient, cls.testdata["disk_offering"], ) cls._cleanup.append(cls.disk_offering) cls.vm = VirtualMachine.create( cls.userapiclient, cls.testdata["small"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, zoneid=cls.zone.id, ) except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls._cleanup = [] try: cls.disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] cls.services["template"]["ostypeid"] = template.ostypeid cls.services["template_2"]["ostypeid"] = template.ostypeid cls.services["ostypeid"] = template.ostypeid cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["diskoffering"] = cls.disk_offering.id cls.services["volume"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]) cls._cleanup.append(cls.service_offering) #create virtual machine cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"]) #Stop virtual machine cls.virtual_machine.stop(cls.apiclient) list_volume = Volume.list(cls.apiclient, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True) cls.volume = list_volume[0] except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def setUpClass(cls): cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod(cls.api_client, cls.zone.id) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() == 'lxc': if not find_storage_pool_type(cls.api_client, storagetype='rbd'): raise unittest.SkipTest( "RBD storage type is required for data volumes for LXC") cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id # get max data volumes limit based on the hypervisor type and version listHost = Host.list( cls.api_client, type='Routing', zoneid=cls.zone.id, podid=cls.pod.id, ) ver = listHost[0].hypervisorversion hv = listHost[0].hypervisor cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() cmd.hypervisor = hv res = cls.api_client.listHypervisorCapabilities(cmd) cls.debug('Hypervisor Capabilities: {}'.format(res)) for i in range(len(res)): if res[i].hypervisorversion == ver: break cls.max_data_volumes = int(res[i].maxdatavolumeslimit) cls.debug('max data volumes:{}'.format(cls.max_data_volumes)) cls.services["volume"]["max"] = cls.max_data_volumes # 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.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [cls.service_offering, cls.disk_offering, cls.account]
def setUpClass(cls): cls.testClient = super(TestVolumes, 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.unsupportedStorageType = False cls.hypervisor = cls.testClient.getHypervisorInfo() cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls._cleanup.append(cls.disk_offering) template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id cls.services["virtual_machine"][ "diskofferingid"] = cls.disk_offering.id # Create VMs, VMs etc cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) 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["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls.volume = Volume.create( cls.api_client, cls.services["volume"], zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid, diskofferingid=cls.disk_offering.id )
def setUpClass(cls): cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id # Create Domains, Account etc cls.domain = Domain.create( cls.api_client, cls.services["domain"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.userapiclient = cls.testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) # Create project as a domain admin cls.project = Project.create( cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid ) cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls._cleanup = [ cls.project, cls.service_offering, cls.disk_offering, cls.account, cls.domain ] return
def setUpClass(cls): testClient = super(TestSnapshotRootDisk, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.pod = get_pod(cls.apiclient, cls.zone.id) cls.services['mode'] = cls.zone.networktype cls.hypervisorNotSupported = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv', 'lxc'] or 'kvm-centos6' in cls.testClient.getZoneForTests(): cls.hypervisorNotSupported = True cls._cleanup = [] if not cls.hypervisorNotSupported: cls.template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) if cls.template == FAILED: assert False, "get_test_template() failed to return template" 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 # Create VMs, NAT Rules etc cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) cls.disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"] ) cls.virtual_machine = cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.apiclient, cls.services["small"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.account) cls._cleanup.append(cls.disk_offering) return
def setUpClass(cls): testClient = super(TestSnapshotRootDisk, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.pod = get_pod(cls.apiclient, cls.zone.id) cls.services['mode'] = cls.zone.networktype cls.hypervisorNotSupported = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv', 'lxc'] or 'kvm-centos6' in cls.testClient.getZoneForTests(): cls.hypervisorNotSupported = True cls._cleanup = [] if not cls.hypervisorNotSupported: cls.template = get_template(cls.apiclient, template_type='BUILTIN') 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 # Create VMs, NAT Rules etc cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) cls.disk_offering = DiskOffering.create( cls.apiclient, cls.services["disk_offering"] ) cls.virtual_machine = cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.apiclient, cls.services["small"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.account) # cls._cleanup.append(cls.template) cls._cleanup.append(cls.disk_offering) return
def setUpClass(cls): cls.testClient = super(TestAttachDetachVolume, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod(cls.api_client, cls.zone.id) cls.services['mode'] = cls.zone.networktype cls._cleanup = [] cls.unsupportedStorageType = False cls.hypervisor = cls.testClient.getHypervisorInfo() cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id # get max data volumes limit based on the hypervisor type and version listHost = Host.list( cls.api_client, type='Routing', zoneid=cls.zone.id, podid=cls.pod.id, ) ver = listHost[0].hypervisorversion hv = listHost[0].hypervisor cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() cmd.hypervisor = hv # cls.services["virtual_machine"]["hypervisor"] res = cls.api_client.listHypervisorCapabilities(cmd) cls.debug('Hypervisor Capabilities: {}'.format(res)) for i in range(len(res)): if res[i].hypervisorversion == ver: break cls.max_data_volumes = int(res[i].maxdatavolumeslimit) cls.debug('max data volumes:{}'.format(cls.max_data_volumes)) cls.services["volume"]["max"] = cls.max_data_volumes # 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.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["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, )
def setUpClass(cls): testClient = super(TestAttachDataDisk, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls._cleanup = [] cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls.skiptest = False try: cls.pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id) except Exception as e: cls.skiptest = True return try: # Create an account cls.account = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) # Create Service offering cls.service_offering_zone1 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], tags=ZONETAG1 ) cls._cleanup.append(cls.service_offering_zone1) # Create Disk offering cls.disk_offering = DiskOffering.create( cls.apiclient, cls.testdata["disk_offering"] ) cls._cleanup.append(cls.disk_offering) except Exception as e: cls.tearDownClass() raise e return
def create_volume(self): small_disk_offering = DiskOffering.list(self.apiclient, name='Small')[0] return Volume.create(self.apiclient, self.services, account=self.account.name, diskofferingid=small_disk_offering.id, domainid=self.account.domainid, zoneid=self.zone.id)
def test_03_deploy_vm_project_limit_reached(self): """Test TTry to deploy VM with admin account where account has not used the resources but @ project they are not available # Validate the following # 1. Try to deploy VM with admin account where account has not used the # resources but @ project they are not available # 2. Deploy VM should error out saying ResourceAllocationException # with "resource limit exceeds""" self.virtualMachine = VirtualMachine.create( self.api_client, self.services["virtual_machine"], projectid=self.project.id, serviceofferingid=self.service_offering.id) try: projects = Project.list(self.apiclient, id=self.project.id, listall=True) except Exception as e: self.fail("failed to get projects list: %s" % e) self.assertEqual( validateList(projects)[0], PASS, "projects list validation failed") self.initialResourceCount = int(projects[0].primarystoragetotal) projectLimit = self.initialResourceCount + 3 self.debug("Setting up account and domain hierarchy") response = self.updatePrimaryStorageLimits(projectLimit=projectLimit) self.assertEqual(response[0], PASS, response[1]) self.services["volume"]["size"] = self.services["disk_offering"][ "disksize"] = 2 try: disk_offering = DiskOffering.create( self.apiclient, services=self.services["disk_offering"]) self.cleanup.append(disk_offering) Volume.create(self.apiclient, self.services["volume"], zoneid=self.zone.id, projectid=self.project.id, diskofferingid=disk_offering.id) except Exception as e: self.fail("Exception occurred: %s" % e) with self.assertRaises(Exception): Volume.create(self.apiclient, self.services["volume"], zoneid=self.zone.id, projectid=self.project.id, diskofferingid=disk_offering.id) return
def setUpClass(cls): # Set up API client testclient = super(TestPrimaryStorage, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.dbConnection = testclient.getDbConnection() cls.services = testclient.getParsedTestDataConfig() cls.testdata = TestData().testdata cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId]) for cluster in list_clusters(cls.apiClient): if cluster.name == cls.testdata[TestData.clusterName]: cls.cluster = cluster list_template_response = list_templates(cls.apiClient, zoneid=cls.zone.id, templatefilter='all') for templates in list_template_response: if templates.name == cls.testdata[TestData.osName]: cls.template = templates cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId]) cls.xs_pool_master_ip = list_hosts(cls.apiClient, clusterid=cls.cluster.id) for host in cls.xs_pool_master_ip: if host.name == cls.testdata[TestData.hostName]: cls.xs_pool_master_ip = host.ipaddress host_ip = "https://" + cls.xs_pool_master_ip cls.xen_session = XenAPI.Session(host_ip) xenserver = cls.testdata[TestData.xenServer] cls.xen_session.xenapi.login_with_password( xenserver[TestData.username], xenserver[TestData.password]) datera = cls.testdata[TestData.Datera] cls.datera_api = DateraApi(username=datera[TestData.login], password=datera[TestData.password], hostname=datera[TestData.mvip]) # Create test account cls.account = Account.create(cls.apiClient, cls.testdata[TestData.account], admin=1) # Set up connection to make customized API calls user = User.create(cls.apiClient, cls.testdata[TestData.user], account=cls.account.name, domainid=cls.domain.id) cls.compute_offering = ServiceOffering.create( cls.apiClient, cls.testdata[TestData.computeOffering]) cls.disk_offering = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOffering]) cls._cleanup = [ cls.compute_offering, cls.disk_offering, user, cls.account ]
def setUpClass(cls): cls.testClient = super(TestSnapshotOnRootVolume, 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.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() 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.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.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2]
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestInstance, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # 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.services["ostype"] ) if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' cls.services["disk_offering"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared' cls.services["disk_offering"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"]["hypervisor"] = cls.testClient.getHypervisorInfo() cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["custom_volume"]["zoneid"] = cls.zone.id # Creating Disk offering, Service Offering and Account cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] ) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["small"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) # Getting authentication for user in newly created Account cls.user = cls.account.user[0] cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name) cls._cleanup.append(cls.disk_offering) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.account) cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def setUpClass(cls): testClient = super(TestMultipleVolumeAttach, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.hypervisor = testClient.getHypervisorInfo() cls.invalidStoragePoolType = False cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = cls.disk_offering.id # Create VMs, VMs etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offering"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) # Create volumes (data disks) cls.volume1 = Volume.create( cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid ) cls.volume2 = Volume.create( cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid ) cls.volume3 = Volume.create( cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid ) cls.volume4 = Volume.create( cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid ) cls._cleanup = [cls.service_offering, cls.disk_offering, cls.account]
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] try: self.services["disk_offering"]["disksize"] = 2 self.disk_offering = DiskOffering.create(self.apiclient, self.services["disk_offering"]) self.assertNotEqual(self.disk_offering, None, "Disk offering is None") self.cleanup.append(self.disk_offering) except Exception as e: self.tearDown() self.skipTest("Failure in setup: %s" % e) return
def test_06_attachvolume_to_a_stopped_vm(self): """ Test Attach Volume To A Stopped VM """ list_vm_response = VirtualMachine.list(self.user_api_client, id=self.virtual_machine.id) self.assertEqual(list_vm_response[0].state, 'Stopped', msg="Check if VM is in Stopped state") custom_disk_offering = DiskOffering.list(self.user_api_client, name="custom") self.__class__.volume = Volume.create( self.user_api_client, self.services["volume"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, diskofferingid=custom_disk_offering[0].id, size=1) # Check List Volume response for newly created volume list_volume_response = Volume.list(self.user_api_client, id=self.volume.id) self.assertNotEqual(list_volume_response, None, "Check if volume exists in ListVolumes") # Attach volume to VM cmd = attachVolume.attachVolumeCmd() cmd.id = self.volume.id cmd.virtualmachineid = self.virtual_machine.id cmd.deviceid = 1 vol1 = self.user_api_client.attachVolume(cmd) # Check all volumes attached to same VM list_volume_response = Volume.list( self.user_api_client, virtualmachineid=self.virtual_machine.id, type='DATADISK', listall=True) self.assertNotEqual(list_volume_response, None, "Check if volume exists in ListVolumes") self.assertEqual(isinstance(list_volume_response, list), True, "Check list volumes response for valid list") self.assertEqual(list_volume_response[0].deviceid, 1, "Check listed volume device id is 1") return
def setUpClass(cls): cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod(cls.api_client, cls.zone.id) cls.services["mode"] = cls.zone.networktype cls._cleanup = [] cls.unsupportedStorageType = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() == "lxc": if not find_storage_pool_type(cls.api_client, storagetype="rbd"): cls.unsupportedStorageType = True return cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup.append(cls.disk_offering) template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id # get max data volumes limit based on the hypervisor type and version listHost = Host.list(cls.api_client, type="Routing", zoneid=cls.zone.id, podid=cls.pod.id) ver = listHost[0].hypervisorversion hv = listHost[0].hypervisor cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() cmd.hypervisor = hv res = cls.api_client.listHypervisorCapabilities(cmd) cls.debug("Hypervisor Capabilities: {}".format(res)) for i in range(len(res)): if res[i].hypervisorversion == ver: break cls.max_data_volumes = int(res[i].maxdatavolumeslimit) cls.debug("max data volumes:{}".format(cls.max_data_volumes)) cls.services["volume"]["max"] = cls.max_data_volumes # 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.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["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, )
def test_create_volume_under_domain(self): """Create a volume under a non-root domain as non-root-domain user 1. Create a domain under ROOT 2. Create a user within this domain 3. As user in step 2. create a volume with standard disk offering 4. Ensure the volume is created in the domain and available to the user in his listVolumes call """ dom = Domain.create(self.apiclient, services={}, name="NROOT", parentdomainid=self.domain.id) self.cleanup.append(dom) self.assertTrue(dom is not None, msg="Domain creation failed") domuser = Account.create(apiclient=self.apiclient, services=self.services["account"], admin=False, domainid=dom.id) self.cleanup.insert(-2, domuser) self.assertTrue(domuser is not None) domapiclient = self.testClient.getUserApiClient(UserName=domuser.name, DomainName=dom.name) diskoffering = DiskOffering.list(self.apiclient) self.assertTrue(isinstance(diskoffering, list), msg="DiskOffering list is not a list?") self.assertTrue( len(diskoffering) > 0, "no disk offerings in the deployment") vol = Volume.create(domapiclient, services=self.services["volume"], zoneid=self.zone.id, account=domuser.name, domainid=dom.id, diskofferingid=diskoffering[0].id) self.assertTrue( vol is not None, "volume creation fails in domain %s as user %s" % (dom.name, domuser.name)) listed_vol = Volume.list(domapiclient, id=vol.id) self.assertTrue( listed_vol is not None and isinstance(listed_vol, list), "invalid response from listVolumes for volume %s" % vol.id) self.assertTrue( listed_vol[0].id == vol.id, "Volume returned by list volumes %s not matching with queried\ volume %s in domain %s" % (listed_vol[0].id, vol.id, dom.name))
def test_03_deploy_vm_project_limit_reached(self): """Test TTry to deploy VM with admin account where account has not used the resources but @ project they are not available # Validate the following # 1. Try to deploy VM with admin account where account has not used the # resources but @ project they are not available # 2. Deploy VM should error out saying ResourceAllocationException # with "resource limit exceeds""" self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"], projectid=self.project.id, diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id) try: projects = Project.list(self.apiclient, id=self.project.id, listall=True) except Exception as e: self.fail("failed to get projects list: %s" % e) self.assertEqual(validateList(projects)[0], PASS, "projects list validation failed") self.initialResourceCount = int(projects[0].primarystoragetotal) projectLimit = self.initialResourceCount + 3 self.debug("Setting up account and domain hierarchy") response = self.updatePrimaryStorageLimits(projectLimit=projectLimit) self.assertEqual(response[0], PASS, response[1]) self.services["volume"]["size"] = self.services["disk_offering"]["disksize"] = 2 try: disk_offering = DiskOffering.create(self.apiclient, services=self.services["disk_offering"]) self.cleanup.append(disk_offering) Volume.create(self.apiclient, self.services["volume"], zoneid=self.zone.id, projectid=self.project.id, diskofferingid=disk_offering.id) except Exception as e: self.fail("Exception occured: %s" % e) with self.assertRaises(Exception): Volume.create(self.apiclient, self.services["volume"], zoneid=self.zone.id, projectid=self.project.id, diskofferingid=disk_offering.id) return
def setUpClass(cls): testClient = super(TestStorageSnapshotsLimits, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.snapshotSupported = True if cls.hypervisor.lower() in ["hyperv", "lxc"]: cls.snapshotSupported = False return try: # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain) # Create Service offering cls.service_offering = ServiceOffering.create(cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering) cls.disk_offering = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"]) cls._cleanup.append(cls.disk_offering) cls.vm = VirtualMachine.create( cls.userapiclient, cls.testdata["small"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, zoneid=cls.zone.id, ) except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): cls.testClient = super(TestSnapshotOnRootVolume, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"]) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # pdb.set_trace() cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2]
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] try: response = self.setupAccounts() if response[0] == FAIL: self.skipTest("Failure while setting up accounts: %s" % response[1]) self.services["disk_offering"]["disksize"] = 2 self.disk_offering = DiskOffering.create(self.apiclient, self.services["disk_offering"]) self.cleanup.append(self.disk_offering) except Exception as e: self.tearDown() self.skipTest("Failure in setup: %s" % e) return
def setUpClass(cls): testClient = super(TestDisableEnableZone, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] try: cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) cls.disk_offering = DiskOffering.create( cls.apiclient, cls.testdata["disk_offering"], ) cls._cleanup.append(cls.disk_offering) # Create an account cls.account = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): cls.testClient = super(TestDeployVMFromTemplate, 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()) # Create service, disk offerings etc cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"], offerha=True) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) # Cleanup cls._cleanup = [cls.service_offering, cls.disk_offering] return
def setUpClass(cls): cls.testClient = super(TestProjectLimits, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype # Create domains, account etc. cls.domain = Domain.create(cls.api_client, cls.services["domain"]) cls.admin = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.user = Account.create(cls.api_client, cls.services["user"], domainid=cls.domain.id) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) cls._cleanup = [cls.admin, cls.user, cls.domain, cls.disk_offering] return
def setUpClass(cls): cls.testClient = super(TestMigrateVolume, 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"] ) template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id cls.services["virtual_machine"][ "diskofferingid"] = cls.disk_offering.id # Create VMs, VMs etc cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.small_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) cls._cleanup = [ cls.small_offering, cls.account ] return
def setUpClass(cls): testClient = super(TestDisableEnableHost, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.snapshotSupported = True # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.pod = get_pod(cls.apiclient, zone_id=cls.zone.id) hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing") clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid) cls.host = Host(hostList[0].__dict__) cls.cluster = Cluster(clusterList[0].__dict__) cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.disabledHosts = [] try: cls.service_offering = ServiceOffering.create(cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering) cls.disk_offering = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"]) cls._cleanup.append(cls.disk_offering) # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Create root admin account cls.admin_account = Account.create(cls.apiclient, cls.testdata["account2"], admin=True) cls._cleanup.append(cls.admin_account) # Create user api client of the account cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain) except Exception as e: cls.tearDownClass() raise e return
def test_create_volume_under_domain(self): """Create a volume under a non-root domain as non-root-domain user 1. Create a domain under ROOT 2. Create a user within this domain 3. As user in step 2. create a volume with standard disk offering 4. Ensure the volume is created in the domain and available to the user in his listVolumes call """ dom = Domain.create(self.apiclient, services={}, name="NROOT", parentdomainid=self.domain.id) self.cleanup.append(dom) self.assertTrue(dom is not None, msg="Domain creation failed") domuser = Account.create( apiclient=self.apiclient, services=self.services["account"], admin=False, domainid=dom.id ) self.cleanup.insert(-2, domuser) self.assertTrue(domuser is not None) domapiclient = self.testClient.getUserApiClient(UserName=domuser.name, DomainName=dom.name) diskoffering = DiskOffering.list(self.apiclient) self.assertTrue(isinstance(diskoffering, list), msg="DiskOffering list is not a list?") self.assertTrue(len(diskoffering) > 0, "no disk offerings in the deployment") vol = Volume.create( domapiclient, services=self.services["volume"], zoneid=self.zone.id, account=domuser.name, domainid=dom.id, diskofferingid=diskoffering[0].id, ) self.assertTrue(vol is not None, "volume creation fails in domain %s as user %s" % (dom.name, domuser.name)) listed_vol = Volume.list(domapiclient, id=vol.id) self.assertTrue( listed_vol is not None and isinstance(listed_vol, list), "invalid response from listVolumes for volume %s" % vol.id, ) self.assertTrue( listed_vol[0].id == vol.id, "Volume returned by list volumes %s not matching with queried\ volume %s in domain %s" % (listed_vol[0].id, vol.id, dom.name), )
def setUpClass(cls): cls.testClient = super(TestRouterStateAfterDeploy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) # Create service offerings, disk offerings etc cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"]) # Cleanup cls._cleanup = [cls.service_offering, cls.disk_offering] return