def setUpClass(cls): testClient = super(TestConcurrentSnapshotLimit, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.supportedHypervisor = True if cls.hypervisor.lower() in [ "hyperv", "lxc"]: cls.supportedHypervisor = False return # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup.append(cls.service_offering) return
def setUpClass(cls): cloudstackTestClient = super(TestSecondaryStorageLimits, cls).getClsTestClient() cls.api_client = cloudstackTestClient.getApiClient() cls.hypervisor = cloudstackTestClient.getHypervisorInfo() # Fill services from the external config file cls.services = cloudstackTestClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.hypervisor = cloudstackTestClient.getHypervisorInfo() cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id cls._cleanup = [] try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) if cls.service_offering == FAILED: raise Exception("Creating service offering failed") except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setup class: %s" % e) return
def setUpClass(cls): cloudstackTestClient = super(TestProjectsVolumeLimits, cls).getClsTestClient() cls.api_client = cloudstackTestClient.getApiClient() # 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.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["zoneid"] = cls.zone.id cls._cleanup = [] try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("Template creation from root volume is not supported in LXC") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering ] return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestIsos, 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"] ) cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services['mode'] = cls.zone.networktype 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) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def setUpClass(cls): cls.testClient = super(TestVPC, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.unsupportedHypervisor = False if cls.hypervisor.lower() == 'hyperv': cls._cleanup = [] cls.unsupportedHypervisor = True return cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestMemoryLimits, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering ] return
def setUpClass(cls): cls.testClient = super(TestAffinityRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup = [cls.account] return
def setUpClass(cls): testClient = super(TestCreateVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) cls.sparse_disk_offering = DiskOffering.create(cls.apiclient, cls.services["sparse_disk_offering"]) cls.custom_disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"], custom=True) template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id cls.services["diskname"] = cls.services["volume"]["diskname"] # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offerings"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"], ) cls._cleanup = [cls.service_offering, cls.disk_offering, cls.custom_disk_offering, cls.account]
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: assert False, "get_template() failed to return template " # for testing with specific template # self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"], templatetype='USER', services = {"template":'31f52a4d-5681-43f7-8651-ad4aaf823618'}) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUp(self): self.services = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() # Get Zone, Domain and templates self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.services['mode'] = self.zone.networktype self.services["domainid"] = self.domain.id self.services["iso2"]["zoneid"] = self.zone.id self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) # Finding the OsTypeId from Ostype ostypes = list_os_types( self.apiclient, description=self.services["ostype"] ) if not isinstance(ostypes, list): raise unittest.SkipTest("OSTypeId for given description not found") self.services["iso1"]["ostypeid"] = ostypes[0].id self.services["iso2"]["ostypeid"] = ostypes[0].id self.services["ostypeid"] = ostypes[0].id self.cleanup = [self.account] return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestTemplates, 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"] ) cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services['mode'] = cls.zone.networktype builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id) cls.services["privatetemplate"]["url"] = builtin_info[0] cls.services["privatetemplate"]["hypervisor"] = builtin_info[1] cls.services["privatetemplate"]["format"] = builtin_info[2] except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def setUpClass(cls): cls.testClient = super(TestHighAvailability, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod( cls.api_client, zone_id=cls.zone.id ) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("Template creation from root volume is not supported in LXC") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls._cleanup = [ cls.service_offering, ] return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.testdata = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: cls.unsupportedHypervisor = True return cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup.append(cls.service_offering) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name return
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCRedundancy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [cls.service_offering] cls.logger = logging.getLogger('TestVPCRedundancy') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] self.services = Services().services # Get Zone, Domain and templates self.domain = get_domain(self.apiclient) self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.newdomain = Domain.create( self.apiclient, self.services["testdomain"], parentdomainid=self.domain.id ) self.newdomain_account = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.newdomain.id ) self.cleanup = [ self.account, self.newdomain_account, self.newdomain, ]
def setUpClass(cls): cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv', 'lxc']: raise unittest.SkipTest("Snapshots feature is not supported on %s" % cls.hypervisor.lower()) cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestRedundantRouterNetworkCleanups, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True ) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering, ] return
def setUpClass(cls): cls.testClient = super(TestMaxProjectNetworks, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.domain = get_domain(cls.api_client) cls.services['mode'] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True ) # Enable Network offering cls.network_offering.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.network_offering ] return
def setUpClass(cls): cls.testClient = super(TestMultipleChildDomains, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() #cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.testdata["mode"] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.testdata["ostype"] ) # Create service, disk offerings etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering_multiple_cores"] ) cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering_multiple_cores"] ) cls._cleanup = [] return
def setUpClass(cls): cls.testClient = super(TestAffinityRules, cls).getClsTestClient() if cls.testClient.getHypervisorInfo().lower() != "vmware": raise unittest.SkipTest("VMWare tests only valid on VMWare hypervisor") cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup = [cls.account] return
def setUpClass(cls): cls.testClient = super(TestTemplates, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.domain = get_domain(cls.api_client) cls.services['mode'] = cls.zone.networktype template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id 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"], ) # create virtual machine cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine cls.virtual_machine.stop(cls.api_client) #Wait before server has be successfully stopped time.sleep(30) list_volume = Volume.list( cls.api_client, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True ) try: if isinstance(list_volume, list): cls.volume = list_volume[0] except Exception as e: raise Exception("Warning: Exception during setup : %s" % e) cls._cleanup = [ cls.service_offering, cls.account, ]
def setUpClass(cls): cls.testClient = super(TestHAProxyStickyness, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["service_offering"]["name"] = "Medium Instance" cls.services["service_offering"]["cpuspeed"] = "1024" cls.services["service_offering"]["memory"] = "1024" cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [cls.service_offering, ] return
def setUpClass(cls): testClient = super(TestIsolatedNetworkInvalidGw, 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 # Create Accounts cls.account = Account.create( cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.services["network"]["zoneid"] = cls.zone.id cls.network_offering = NetworkOffering.create( cls.apiclient, cls.services["network_offering"], ) # Enable Network offering cls.network_offering.update(cls.apiclient, state='Enabled') cls.services["network"]["networkoffering"] = cls.network_offering.id cls._cleanup = [ cls.account, cls.network_offering ] return
def setUpClass(cls): cloudstackTestClient = super(TestVolumeLimits, cls).getClsTestClient() cls.api_client = cloudstackTestClient.getApiClient() cls.hypervisor = cloudstackTestClient.getHypervisorInfo() # Fill services from the external config file cls.services = cloudstackTestClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls._cleanup = [] cls.unsupportedStorageType = False if cls.hypervisor.lower() == 'lxc': if not find_storage_pool_type(cls.api_client, storagetype='rbd'): cls.unsupportedStorageType = True return cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["volume"]["zoneid"] = cls.zone.id try: cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) return
def setUpClass(cls): testClient = super(TestSameVMName, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls._cleanup = [] cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ try: cls.skiptest = False if cls.hypervisor.lower() not in ['vmware']: cls.skiptest = True # Create an account cls.account_1 = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls.account_2 = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) # Create user api client of the account cls.userapiclient_1 = testClient.getUserApiClient( UserName=cls.account_1.name, DomainName=cls.account_1.domain ) cls.userapiclient_2 = testClient.getUserApiClient( UserName=cls.account_2.name, DomainName=cls.account_2.domain ) # Create Service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup = [ cls.account_1, cls.account_2, cls.service_offering, ] except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCNetworkPFRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup = [cls.service_offering] return
def setUp(self): if self.testClient.getHypervisorInfo().lower() != "vmware": raise unittest.SkipTest( "VMWare tests only valid on VMWare hypervisor") self.services = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.domain = get_domain(self.apiclient) self.services['mode'] = self.zone.networktype self.hypervisor = self.hypervisor = self.testClient.getHypervisorInfo() template = get_suitable_test_template(self.apiclient, self.zone.id, self.services["ostype"], self.hypervisor) if template == FAILED: assert False, "get_suitable_test_template() failed to return template with description %s" % self.services[ "ostype"] self.account = Account.create(self.apiclient, self.services["account"], domainid=self.domain.id) self.services["small"]["zoneid"] = self.zone.id self.services["small"]["template"] = template.id self.services["iso1"]["zoneid"] = self.zone.id iso = Iso.create(self.apiclient, self.services["iso1"], account=self.account.name, domainid=self.account.domainid) self.cleanup = [self.account]
def setUpClass(cls): testClient = super(TestMigrateVMwithVolume, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() cls._cleanup = [] # Get Zone, Domain and templates domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][ 0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.management_ip = cls.config.__dict__["mgtSvr"][0].__dict__[ "mgtSvrIp"] template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id cls.services["iso1"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) cls.small_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"]) cls._cleanup = [cls.small_offering, cls.account]
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestRouterIpTablesPolicies, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.account = Account.create(cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offering"]) cls.logger = logging.getLogger('TestRouterIpTablesPolicies') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.entity_manager = EntityManager(cls.apiclient, cls.services, cls.service_offering, cls.account, cls.zone, cls.logger) cls._cleanup = [cls.service_offering, cls.account] return
def setUpClass(cls): cls.logger = logging.getLogger('TestInternalLb') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) testClient = super(TestInternalLb, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls._cleanup = [] cls.logger.debug("Creating compute offering: %s" % cls.services["compute_offering"]["name"]) cls.compute_offering = ServiceOffering.create( cls.apiclient, cls.services["compute_offering"]) cls._cleanup.append(cls.compute_offering) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls._cleanup.append(cls.account) cls.hypervisor = testClient.getHypervisorInfo() 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.logger.debug("Successfully created account: %s, id: \ %s" % (cls.account.name, cls.account.id)) return
def setUpClass(cls): cls.testClient = super(TestRouterServices, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create an account, network, VM and IP addresses cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls._cleanup = [cls.account, cls.service_offering] return
def setUpClass(cls): testClient = super(TestRouterServices, 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.hypervisor = testClient.getHypervisorInfo() cls.services['mode'] = cls.zone.networktype template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) if template == FAILED: cls.fail("get_test_template() failed to return template") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls._cleanup = [] # Create an account, network, VM and IP addresses 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._cleanup.append(cls.service_offering) cls.vm_1 = VirtualMachine.create( cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls._cleanup.append(cls.vm_1) return
def setUp(self): self.services = Services().services self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.services["mode"] = self.zone.networktype # Before running this test, register a windows template with ostype as 'Windows 7 (32-bit)' self.services["ostype"] = 'Windows 7 (32-bit)' self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"]) if self.template == FAILED: assert False, "get_template() failed to return template with description %s" % self.services["ostype"] #create a user account self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.services["vgpu260q"]["zoneid"] = self.zone.id self.services["vgpu260q"]["template"] = self.template.id self.services["vgpu140q"]["zoneid"] = self.zone.id self.services["vgpu140q"]["template"] = self.template.id #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offerings"]["vgpu260qwin"], serviceofferingdetails={'pciDevice': 'VGPU'} ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCRedundancy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() cls.template = Template.register( cls.api_client, cls.services["template"][cls.hypervisor.lower()], cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) cls.template.download(cls.api_client) if cls.template == FAILED: assert False, "get_template() failed to return template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [cls.service_offering, cls.template] cls.logger = logging.getLogger('TestVPCRedundancy') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) return
def setUpClass(cls): cls.testClient = super(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._cleanup = [] cls.unsupportedStorageType = False cls.hypervisor = cls.testClient.getHypervisorInfo() 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): 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): cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv']: raise unittest.SkipTest( "Snapshots feature is not supported on Hyper-V") cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestVMPlacement, cls).getClsTestClient() if cls.testClient.getHypervisorInfo().lower() != "vmware": raise unittest.SkipTest( "VMWare tests only valid on VMWare hypervisor") cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod(cls.api_client, zone_id=cls.zone.id) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"], offerha=True) cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc 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( TestCreateVMSnapshotTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype 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, redundant=False): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() test_client = super(TestVpcVpn, cls).getClsTestClient() cls.apiclient = test_client.getApiClient() cls.services = test_client.getParsedTestDataConfig() cls.zone = get_zone(cls.apiclient, test_client.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.vpc_offering = get_default_redundant_vpc_offering( cls.apiclient) if redundant else get_default_vpc_offering( cls.apiclient) cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name) cls.network_offering = get_default_network_offering(cls.apiclient) cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name) cls.virtual_machine_offering = get_default_virtual_machine_offering( cls.apiclient) cls.logger.debug("Virtual Machine Offering '%s' selected", cls.virtual_machine_offering.name) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls.logger.debug("Successfully created account: %s, id: %s" % (cls.account.name, cls.account.id)) cls.hypervisor = test_client.getHypervisorInfo() cls._cleanup = [cls.account] cls.template = get_template(cls.apiclient, cls.zone.id) return
def setUpClass(cls): cls.testClient = super( TestMultiplePublicIpSubnets, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.zone = Zone(zone.__dict__) cls.template = get_template(cls.apiclient, cls.zone.id) cls._cleanup = [] cls.skip = False if str(cls.zone.securitygroupsenabled) == "True": cls.skip = True return cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() not in ['kvm']: cls.skip = True return cls.logger = logging.getLogger("TestMultiplePublicIpSubnets") cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) # Create small service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"] ) cls._cleanup.append(cls.service_offering)
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): cls.testClient = super(TestVMWareStoragePolicies, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls._cleanup = [] cls.hypervisor = cls.testClient.getHypervisorInfo() cls.network_offering = NetworkOffering.create( cls.apiclient, cls.testdata["l2-network_offering"], ) cls.network_offering.update(cls.apiclient, state='Enabled') cls.template = get_test_template( cls.apiclient, cls.zone.id, cls.hypervisor, deploy_as_is=cls.hypervisor.lower() == "vmware") cls._cleanup.append(cls.network_offering) 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.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 setUp(self): self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] self.services = Services().services # Get Zone, Domain and templates self.domain = get_domain(self.apiclient) self.account = Account.create(self.apiclient, self.services["account"], domainid=self.domain.id) self.newdomain = Domain.create(self.apiclient, self.services["testdomain"], parentdomainid=self.domain.id) self.newdomain_account = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.newdomain.id) self.cleanup = [ self.account, self.newdomain_account, self.newdomain, ]
def setUpClass(cls): cls.testClient = super(TestProjectsMemoryLimits, 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() cls.services["mode"] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup = [ cls.service_offering, ] return
def setUpClass(cls): cls.testClient = super(TestProjectsCPULimits, 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.testdata["mode"] = cls.zone.networktype cls.template = get_template( cls.api_client, cls.zone.id, cls.testdata["ostype"] ) cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.testdata["service_offering_multiple_cores"] ) cls._cleanup = [cls.service_offering, ] return
def setUpClass(cls): # Set up API client testclient = super(TestVMSnapshots, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.testdata = TestData().testdata # Set up XenAPI connection host_ip = "https://" + \ list_hosts(cls.apiClient, clusterid=cls.testdata[TestData.clusterId], name="XenServer-6.5-1")[0].ipaddress cls.xen_session = XenAPI.Session(host_ip) xenserver = cls.testdata[TestData.xenServer] cls.xen_session.xenapi.login_with_password( xenserver[TestData.username], xenserver[TestData.password]) # Set up SolidFire connection cls.sf_client = sf_api.SolidFireAPI( endpoint_dict=cls.testdata[TestData.solidFire]) # Get Resources from Cloud Infrastructure cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId]) template = get_template( cls.apiClient, cls.zone.id, template_name=cls.testdata[TestData.templateName]) cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId]) # Create test account cls.account = Account.create(cls.apiClient, cls.testdata[TestData.account], admin=1) # Set up connection to make customized API calls user = User.create(cls.apiClient, cls.testdata[TestData.user], account=cls.account.name, domainid=cls.domain.id) url = cls.testdata[TestData.url] api_url = "http://" + url + ":8080/client/api" userkeys = User.registerUserKeys(cls.apiClient, user.id) cls.cs_api = SignedAPICall.CloudStack(api_url, userkeys.apikey, userkeys.secretkey) primarystorage = cls.testdata[TestData.primaryStorage] cls.primary_storage = StoragePool.create( cls.apiClient, primarystorage, scope=primarystorage[TestData.scope], zoneid=cls.zone.id, provider=primarystorage[TestData.provider], tags=primarystorage[TestData.tags], capacityiops=primarystorage[TestData.capacityIops], capacitybytes=primarystorage[TestData.capacityBytes], hypervisor=primarystorage[TestData.hypervisor]) compute_offering = ServiceOffering.create( cls.apiClient, cls.testdata[TestData.computeOffering]) cls.disk_offering = DiskOffering.create( cls.apiClient, cls.testdata[TestData.diskOffering]) # Create VM and volume for tests cls.virtual_machine = VirtualMachine.create( cls.apiClient, cls.testdata[TestData.virtualMachine], accountid=cls.account.name, zoneid=cls.zone.id, serviceofferingid=compute_offering.id, templateid=template.id, domainid=cls.domain.id, startvm=True) cls._cleanup = [ cls.virtual_machine, compute_offering, cls.disk_offering, user, cls.account ]
def setUpClass(cls): cls.testClient = super(TestMulipleNicSupport, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.testdata = cls.testClient.getParsedTestDataConfig() cls.services = cls.testClient.getParsedTestDataConfig() zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.zone = Zone(zone.__dict__) cls._cleanup = [] cls.skip = False if str(cls.zone.securitygroupsenabled) != "True": cls.skip = True return cls.logger = logging.getLogger("TestMulipleNicSupport") cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) # Get Domain and templates cls.domain = get_domain(cls.apiclient) cls.services['mode'] = cls.zone.networktype cls.template = get_template(cls.apiclient, cls.zone.id, hypervisor="KVM") if cls.template == FAILED: cls.skip = True return # Create new domain, account, network and VM cls.user_domain = Domain.create( cls.apiclient, services=cls.testdata["acl"]["domain2"], parentdomainid=cls.domain.id) # Create account cls.account1 = Account.create(cls.apiclient, cls.testdata["acl"]["accountD2"], admin=True, domainid=cls.user_domain.id) # Create small service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offerings"]["small"]) cls._cleanup.append(cls.service_offering) cls.services["network"]["zoneid"] = cls.zone.id cls.network_offering = NetworkOffering.create( cls.apiclient, cls.services["network_offering"], ) # Enable Network offering cls.network_offering.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.network_offering) cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id cls.testdata["virtual_machine"]["template"] = cls.template.id if cls.zone.securitygroupsenabled: # Enable networking for reaching to VM thorugh SSH security_group = SecurityGroup.create( cls.apiclient, cls.testdata["security_group"], account=cls.account1.name, domainid=cls.account1.domainid) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( cls.apiclient, cls.testdata["ingress_rule"], account=cls.account1.name, domainid=cls.account1.domainid) # Authorize Security group to SSH to VM ingress_rule2 = security_group.authorize( cls.apiclient, cls.testdata["ingress_rule_ICMP"], account=cls.account1.name, domainid=cls.account1.domainid) cls.testdata["shared_network_offering_sg"]["specifyVlan"] = 'True' cls.testdata["shared_network_offering_sg"]["specifyIpRanges"] = 'True' cls.shared_network_offering = NetworkOffering.create( cls.apiclient, cls.testdata["shared_network_offering_sg"], conservemode=False) NetworkOffering.update(cls.shared_network_offering, cls.apiclient, id=cls.shared_network_offering.id, state="enabled") physical_network, vlan = get_free_vlan(cls.apiclient, cls.zone.id) cls.testdata["shared_network_sg"][ "physicalnetworkid"] = physical_network.id random_subnet_number = random.randrange(90, 99) cls.testdata["shared_network_sg"][ "name"] = "Shared-Network-SG-Test-vlan" + str(random_subnet_number) cls.testdata["shared_network_sg"][ "displaytext"] = "Shared-Network-SG-Test-vlan" + str( random_subnet_number) cls.testdata["shared_network_sg"]["vlan"] = "vlan://" + str( random_subnet_number) cls.testdata["shared_network_sg"]["startip"] = "192.168." + str( random_subnet_number) + ".240" cls.testdata["shared_network_sg"]["endip"] = "192.168." + str( random_subnet_number) + ".250" cls.testdata["shared_network_sg"]["gateway"] = "192.168." + str( random_subnet_number) + ".254" cls.network1 = Network.create( cls.apiclient, cls.testdata["shared_network_sg"], networkofferingid=cls.shared_network_offering.id, zoneid=cls.zone.id, accountid=cls.account1.name, domainid=cls.account1.domainid) random_subnet_number = random.randrange(100, 110) cls.testdata["shared_network_sg"][ "name"] = "Shared-Network-SG-Test-vlan" + str(random_subnet_number) cls.testdata["shared_network_sg"][ "displaytext"] = "Shared-Network-SG-Test-vlan" + str( random_subnet_number) cls.testdata["shared_network_sg"]["vlan"] = "vlan://" + str( random_subnet_number) cls.testdata["shared_network_sg"]["startip"] = "192.168." + str( random_subnet_number) + ".240" cls.testdata["shared_network_sg"]["endip"] = "192.168." + str( random_subnet_number) + ".250" cls.testdata["shared_network_sg"]["gateway"] = "192.168." + str( random_subnet_number) + ".254" cls.network2 = Network.create( cls.apiclient, cls.testdata["shared_network_sg"], networkofferingid=cls.shared_network_offering.id, zoneid=cls.zone.id, accountid=cls.account1.name, domainid=cls.account1.domainid) random_subnet_number = random.randrange(111, 120) cls.testdata["shared_network_sg"][ "name"] = "Shared-Network-SG-Test-vlan" + str(random_subnet_number) cls.testdata["shared_network_sg"][ "displaytext"] = "Shared-Network-SG-Test-vlan" + str( random_subnet_number) cls.testdata["shared_network_sg"]["vlan"] = "vlan://" + str( random_subnet_number) cls.testdata["shared_network_sg"]["startip"] = "192.168." + str( random_subnet_number) + ".240" cls.testdata["shared_network_sg"]["endip"] = "192.168." + str( random_subnet_number) + ".250" cls.testdata["shared_network_sg"]["gateway"] = "192.168." + str( random_subnet_number) + ".254" cls.network3 = Network.create( cls.apiclient, cls.testdata["shared_network_sg"], networkofferingid=cls.shared_network_offering.id, zoneid=cls.zone.id, accountid=cls.account1.name, domainid=cls.account1.domainid) try: cls.virtual_machine1 = VirtualMachine.create( cls.apiclient, cls.testdata["virtual_machine"], accountid=cls.account1.name, domainid=cls.account1.domainid, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, securitygroupids=[security_group.id], networkids=cls.network1.id) for nic in cls.virtual_machine1.nic: if nic.isdefault: cls.virtual_machine1.ssh_ip = nic.ipaddress cls.virtual_machine1.default_network_id = nic.networkid break except Exception as e: cls.fail("Exception while deploying virtual machine: %s" % e) try: cls.virtual_machine2 = VirtualMachine.create( cls.apiclient, cls.testdata["virtual_machine"], accountid=cls.account1.name, domainid=cls.account1.domainid, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, securitygroupids=[security_group.id], networkids=[str(cls.network1.id), str(cls.network2.id)]) for nic in cls.virtual_machine2.nic: if nic.isdefault: cls.virtual_machine2.ssh_ip = nic.ipaddress cls.virtual_machine2.default_network_id = nic.networkid break except Exception as e: cls.fail("Exception while deploying virtual machine: %s" % e) cls._cleanup.append(cls.virtual_machine1) cls._cleanup.append(cls.virtual_machine2) cls._cleanup.append(cls.network1) cls._cleanup.append(cls.network2) cls._cleanup.append(cls.network3) cls._cleanup.append(cls.shared_network_offering) if cls.zone.securitygroupsenabled: cls._cleanup.append(security_group) cls._cleanup.append(cls.account1) cls._cleanup.append(cls.user_domain)
def setUpClass(cls): testClient = super(TestVMLifeCycle, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #if local storage is enabled, alter the offerings to use localstorage #this step is needed for devcloud if cls.zone.localstorageenabled == True: cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' cls.services["service_offerings"]["small"]["storagetype"] = 'local' cls.services["service_offerings"]["medium"][ "storagetype"] = 'local' template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id cls.services["medium"]["zoneid"] = cls.zone.id cls.services["medium"]["template"] = template.id cls.services["iso1"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) cls.small_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"]) cls.medium_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["medium"]) #create small and large virtual machines cls.small_virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls.medium_virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["medium"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.medium_offering.id, mode=cls.services["mode"]) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls._cleanup = [cls.small_offering, cls.medium_offering, cls.account]
def setUpClass(cls): # Set up API client testclient = super(TestManagedClusteredFilesystems, cls).getClsTestClient() cls.apiClient = testclient.getApiClient() cls.configData = testclient.getParsedTestDataConfig() cls.dbConnection = testclient.getDbConnection() cls.testdata = TestData().testdata sf_util.set_supports_resign(True, cls.dbConnection) cls._connect_to_hypervisor() # Set up SolidFire connection solidfire = cls.testdata[TestData.solidFire] cls.sfe = ElementFactory.create(solidfire[TestData.mvip], solidfire[TestData.username], solidfire[TestData.password]) # Get Resources from Cloud Infrastructure cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId]) cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor=TestData.hypervisor_type) cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId]) # Create test account cls.account = Account.create(cls.apiClient, cls.testdata["account"], admin=1) # Set up connection to make customized API calls cls.user = User.create(cls.apiClient, cls.testdata["user"], account=cls.account.name, domainid=cls.domain.id) url = cls.testdata[TestData.url] api_url = "http://" + url + ":8080/client/api" userkeys = User.registerUserKeys(cls.apiClient, cls.user.id) cls.cs_api = SignedAPICall.CloudStack(api_url, userkeys.apikey, userkeys.secretkey) primarystorage = cls.testdata[TestData.primaryStorage] cls.primary_storage = StoragePool.create( cls.apiClient, primarystorage, scope=primarystorage[TestData.scope], zoneid=cls.zone.id, provider=primarystorage[TestData.provider], tags=primarystorage[TestData.tags], capacityiops=primarystorage[TestData.capacityIops], capacitybytes=primarystorage[TestData.capacityBytes], hypervisor=primarystorage[TestData.hypervisor]) cls.compute_offering = ServiceOffering.create( cls.apiClient, cls.testdata[TestData.computeOffering]) # Resources that are to be destroyed cls._cleanup = [cls.compute_offering, cls.user, cls.account]
def setUpClass(cls): testClient = super(TestTemplates, 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, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #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.") 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["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["diskoffering"] = cls.disk_offering.id cls.services["volume"]["zoneid"] = cls.zone.id cls.services["template_2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id cls.services["template"]["ostypeid"] = template.ostypeid cls.services["template_2"]["ostypeid"] = template.ostypeid cls.services["ostypeid"] = template.ostypeid print "Before:", cls.services cls.account = Account.create(cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id) print "After:", cls.services cls.user = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]) #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) try: cls.volume = list_volume[0] except Exception as e: raise Exception( "Exception: Unable to find root volume foe VM: %s - %s" % (cls.virtual_machine.id, e)) #Create templates for Edit, Delete & update permissions testcases cls.template_1 = Template.create(cls.apiclient, cls.services["template"], cls.volume.id, account=cls.account.name, domainid=cls.account.domainid) cls.template_2 = Template.create(cls.apiclient, cls.services["template_2"], cls.volume.id, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup = [ cls.service_offering, cls.disk_offering, cls.account, cls.user ]
def setUpClass(cls): testClient = super(TestListIdsParams, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"]) 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"]) template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) if template == FAILED: assert False, "get_test_template() failed to return template" cls.services["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["mode"] = cls.zone.networktype #Create 3 VMs cls.virtual_machine_1 = 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"]) cls.virtual_machine_2 = 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"]) cls.virtual_machine_3 = 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"]) # Take 3 VM1 Snapshots # PLEASE UNCOMMENT ONCE VM SNAPSHOT DELAY BUG AFTER VM CREATION IS FIXED # cls.vmsnapshot_1 = VmSnapshot.create( # cls.apiclient, # cls.virtual_machine_1.id # ) # cls.vmsnapshot_2 = VmSnapshot.create( # cls.apiclient, # cls.virtual_machine_1.id # ) # cls.vmsnapshot_3 = VmSnapshot.create( # cls.apiclient, # cls.virtual_machine_1.id # ) #Stop VMs cls.virtual_machine_1.stop(cls.apiclient) cls.virtual_machine_2.stop(cls.apiclient) cls.virtual_machine_3.stop(cls.apiclient) #Get ROOT volumes of 3 VMs vm1RootVolumeResponse = Volume.list( cls.apiclient, virtualmachineid=cls.virtual_machine_1.id, type='ROOT', listall=True) vm2RootVolumeResponse = Volume.list( cls.apiclient, virtualmachineid=cls.virtual_machine_2.id, type='ROOT', listall=True) vm3RootVolumeResponse = Volume.list( cls.apiclient, virtualmachineid=cls.virtual_machine_3.id, type='ROOT', listall=True) cls.vm1_root_volume = vm1RootVolumeResponse[0] cls.vm2_root_volume = vm2RootVolumeResponse[0] cls.vm3_root_volume = vm3RootVolumeResponse[0] #Take 3 snapshots of VM2's ROOT volume cls.snapshot_1 = Snapshot.create(cls.apiclient, cls.vm2_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) cls.snapshot_2 = Snapshot.create(cls.apiclient, cls.vm2_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) cls.snapshot_3 = Snapshot.create(cls.apiclient, cls.vm2_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) #Create 3 templates cls.template_1 = Template.create(cls.apiclient, cls.services["template"], cls.vm3_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) cls.template_2 = Template.create(cls.apiclient, cls.services["template_2"], cls.vm3_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) cls.template_3 = Template.create(cls.apiclient, cls.services["template_2"], cls.vm3_root_volume.id, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup = [ cls.snapshot_3, cls.snapshot_2, cls.snapshot_1, cls.account, cls.disk_offering, cls.service_offering ]
def setUpClass(cls): testClient = super(TestXDCCPInterop, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype hosts = list_hosts(cls.apiclient, type="Routing") if hosts is None: raise unittest.SkipTest( "There are no hypervisor's available.Check list hosts response" ) for hypervisorhost in hosts: if hypervisorhost.hypervisor == "XenServer": cls.uploadtemplateformat = "VHD" break elif hypervisorhost.hypervisor == "VMware": cls.uploadtemplateformat = "OVA" break elif hypervisorhost.hypervisor == "KVM": cls.uploadtemplateformat = "KVM" break if cls.uploadtemplateformat == "KVM": raise unittest.SkipTest("Interop is not supported on KVM") cls.uploadurl = cls.services["interop"][ cls.uploadtemplateformat]["url"] cls.xtemplate = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if cls.xtemplate == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id, admin=False) cls.debug(cls.account.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["large"]) cls.template = get_windows_template(cls.apiclient, cls.zone.id, ostype_desc="Windows 8 (64-bit)") #cls.template = get_windows_template(cls.apiclient, cls.zone.id ,ostype_desc="Windows Server 2012 (64-bit)") if cls.template == FAILED: if "http://pleaseupdateURL/" in cls.uploadurl: raise unittest.SkipTest( "Check Test Data file if it has the valid template URL") cls.template = Template.register( cls.apiclient, cls.services["interop"][cls.uploadtemplateformat], zoneid=cls.zone.id, domainid=cls.account.domainid, account=cls.account.name) timeout = cls.services["vgpu"]["timeout"] while True: time.sleep(cls.services["vgpu"]["sleep"]) list_template_response = Template.list( cls.apiclient, templatefilter=cls.services["templatefilter"], id=cls.template.id) if (isinstance(list_template_response, list)) is not True: raise unittest.SkipTest( "Check list template api response returns a valid list" ) if len(list_template_response) is None: raise unittest.SkipTest( "Check template registered is in List Templates") template_response = list_template_response[0] if template_response.isready: break if timeout == 0: raise unittest.SkipTest( "Failed to download template(ID: %s). " % template_response.id) timeout = timeout - 1 cls.volume = [] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id user_data = ''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) cls.services["virtual_machine"]["userdata"] = user_data # cls.services["large"]["zoneid"] = cls.zone.id # cls.services["large"]["template"] = cls.template.id cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services['mode'], startvm="false") cls.user_api_client = cls.testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) cls.cleanup = [cls.service_offering, cls.account]
def setUpClass(cls): cls.testClient = super(TestTemplates, 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 #populate second zone id for iso copy cmd = listZones.listZonesCmd() zones = cls.api_client.listZones(cmd) if not isinstance(zones, list): raise Exception("Failed to find zones.") if len(zones) >= 2: cls.services["destzoneid"] = zones[1].id template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls._cleanup = [] try: cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) # create virtual machine cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine cls.virtual_machine.stop(cls.api_client) timeout = cls.services["timeout"] while True: list_volume = Volume.list( cls.api_client, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True) if isinstance(list_volume, list): break elif timeout == 0: raise Exception("List volumes failed.") time.sleep(5) timeout = timeout - 1 cls.volume = list_volume[0] #Create template from volume cls.template = Template.create(cls.api_client, cls.services["template"], cls.volume.id) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Failure in setUpClass: %s" % e)