def test_03_delete_instance(self): """Test Deploy VM with specified GB RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2. List Resource count for the root admin Memory usage # 3. Delete instance, resource count should be 0 after delete operation. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count" ) self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].memorytotal self.assertEqual( resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9) ) # RAM 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 test_02_multiple_core_vm_migrate_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create two domains and set specific resource (cpu) limit for them # 2. Create compute offering with 4 core CPU & deploy vm # 3. Update Resource count for the domains # 4. Migrate instance to new host and check resource count # 5. Resource count should list properly. self.hypervisor = self.testClient.getHypervisorInfo() self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_migrate, "Resource count should be same as before, after migrating the instance") return
def setupAccount(self, accountType): """Setup the account required for the test""" try: if accountType == CHILD_DOMAIN_ADMIN: self.domain = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.account = Account.create(self.apiclient, self.services["account"], domainid=self.domain.id, admin=True) self.cleanup.append(self.account) if accountType == CHILD_DOMAIN_ADMIN: self.cleanup.append(self.domain) self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id) accounts = Account.list(self.apiclient, id=self.account.id) self.assertEqual(validateList(accounts)[0], PASS, "accounts list validation failed") self.initialResourceCount = int(accounts[0].primarystoragetotal) except Exception as e: return [FAIL, e] return [PASS, None]
def test_03_multiplecore_delete_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Destroy VM & verify update resource count of Root Admin Account # 3. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal self.assertEqual(resource_count, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU return
def deploy_account(self, account_data, domain): self.logger.debug('>>> ACCOUNT => Creating "%s"...', account_data['username']) account = None if not self.randomizeNames: account_list = Account.list(api_client=self.api_client, name=account_data['username'], listall=True) if isinstance(account_list, list) and len(account_list) >= 1: if account_list[0].name == account_data['username']: account = account_list[0] self.logger.debug('>>> ACCOUNT => Loaded from (pre) existing account, ID: %s', account.id) return if not account: account = Account.create( api_client=self.api_client, services=account_data, domainid=domain.uuid, randomizeID=self.randomizeNames ) self.resources_to_cleanup.append(account) self.dynamic_names['accounts'][account_data['username']] = account.name self.logger.debug('>>> ACCOUNT => ID: %s => Name: %s => State: %s => Domain: %s', account.id, account.name, account.state, account.domainid) self.deploy_vpcs(account_data['vpcs'], account) self.deploy_isolatednetworks(account_data['isolatednetworks'], account) self.deploy_vms(account_data['virtualmachines'], account) self.deploy_vpcs_publicipaddresses(account_data['vpcs'], account_data['virtualmachines']) self.deploy_isolatednetworks_publicipaddresses(account_data['isolatednetworks'], account_data['virtualmachines']) self.deploy_privatenetworks(account_data['privatenetworks'], account, domain) self.deploy_vpcs_privategateways(account_data['vpcs']) self.enable_vpcs_localvpngateway(account_data['vpcs']) self.deploy_vpcs_remotevpngateways(account_data['vpcs'], account)
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(TestTemplates, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["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.user = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # 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.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.domain.name) cls._cleanup = [cls.project, cls.service_offering, cls.account, cls.user, cls.domain] return
def setupAccounts(self): self.debug("Creating a sub-domain under: %s" % self.domain.name) self.child_domain = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id ) self.child_do_admin = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.child_domain.id ) # Cleanup the resources created at end of test self.cleanup.append(self.child_do_admin) self.cleanup.append(self.child_domain) Resources.updateLimit( self.apiclient, resourcetype=8, max=16, account=self.child_do_admin.name, domainid=self.child_do_admin.domainid, ) self.domain = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) # Cleanup the resources created at end of test self.cleanup.append(self.admin) self.cleanup.append(self.domain) Resources.updateLimit( self.apiclient, resourcetype=8, max=16, account=self.admin.name, domainid=self.admin.domainid ) return
def setUpClass(cls): testClient = super(TestlistTemplatesDomainAdmin, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id) cls.testdata["privatetemplate"]["url"] = builtin_info[0] cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1] cls.testdata["privatetemplate"]["format"] = builtin_info[2] cls.cleanup = [] # Create 2 domain admin accounts cls.domain1 = Domain.create(cls.apiclient, cls.testdata["domain"]) cls.domain2 = Domain.create(cls.apiclient, cls.testdata["domain"]) cls.account1 = Account.create(cls.apiclient, cls.testdata["account"], admin=True, domainid=cls.domain1.id) cls.account2 = Account.create(cls.apiclient, cls.testdata["account2"], admin=True, domainid=cls.domain2.id) cls.debug("Created account %s in domain %s" % (cls.account1.name, cls.domain1.id)) cls.debug("Created account %s in domain %s" % (cls.account2.name, cls.domain2.id)) cls.cleanup.append(cls.account1) cls.cleanup.append(cls.account2) cls.cleanup.append(cls.domain1) cls.cleanup.append(cls.domain2)
def setupAccounts(self): self.debug("Creating a domain under: %s" % self.domain.name) self.child_domain_1 = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.child_do_admin_1 = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.child_domain_1.id ) # Cleanup the resources created at end of test self.cleanup.append(self.child_do_admin_1) self.cleanup.append(self.child_domain_1) self.debug("Creating a domain under: %s" % self.domain.name) self.child_domain_2 = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.child_do_admin_2 = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.child_domain_2.id) # Cleanup the resources created at end of test self.cleanup.append(self.child_do_admin_2) self.cleanup.append(self.child_domain_2) return
def test_02_migrate_vm(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Migrate vm to another host, resource count should list properly. #Resetting memory count in service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].memorytotal self.assertTrue(resource_count_after_migrate == resource_count, "Resource count should be same after migrating the instance") return
def setupAccounts(self): self.debug("Creating a domain under: %s" % self.domain.name) self.parent_domain = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id ) self.parentd_admin = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.domain.id ) self.debug("Updating the Memory resource count for domain: %s" % self.domain.name) Resources.updateLimit( self.apiclient, resourcetype=9, max=4096, account=self.parentd_admin.name, domainid=self.parentd_admin.domainid, ) self.debug("Creating a sub-domain under: %s" % self.parent_domain.name) self.cdomain_1 = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id ) self.debug("Creating a sub-domain under: %s" % self.parent_domain.name) self.cdomain_2 = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id ) self.cadmin_1 = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_1.id) self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_1.name) Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_1.domainid) self.debug("Updating the Memory resource count for account: %s" % self.cadmin_1.name) Resources.updateLimit( self.apiclient, resourcetype=9, max=2048, account=self.cadmin_1.name, domainid=self.cadmin_1.domainid ) self.cadmin_2 = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_2.id) self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_2.name) Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_2.domainid) self.debug("Updating the Memory resource count for domain: %s" % self.cadmin_2.name) Resources.updateLimit( self.apiclient, resourcetype=9, max=2048, account=self.cadmin_2.name, domainid=self.cadmin_2.domainid ) # Cleanup the resources created at end of test self.cleanup.append(self.cadmin_1) self.cleanup.append(self.cadmin_2) self.cleanup.append(self.cdomain_1) self.cleanup.append(self.cdomain_2) self.cleanup.append(self.parentd_admin) self.cleanup.append(self.parent_domain) users = {self.parent_domain: self.parentd_admin, self.cdomain_1: self.cadmin_1, self.cdomain_2: self.cadmin_2} return users
def test_03_delete_vm(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Delete vm, resource count should list as 0 after delete operation. # Resetting the memory count of service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=9))#RAM return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Creating two instances with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering) self.createInstance(service_off=self.service_offering) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_new = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) * 3 #Total 3 VMs self.assertEqual(resource_count_new, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal expected_resource_count -= int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count_after_delete, expected_resource_count, "Resource count should match with the expected resource count") return
def test_02_migrate_instance(self): """Test Deploy VM with specified memory & verify the usage""" # Validate the following # 1. Create compute offering with specified memory in child domains of root domain & Deploy VM # 2. List Resource count # 3. Migrate instance to another host # 4. Resource count should list properly. self.hypervisor = self.testClient.getHypervisorInfo() if self.hypervisor.lower() in ["lxc"]: self.skipTest("vm migrate feature is not supported on %s" % self.hypervisor.lower()) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2} for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should with the expected resource count", ) host = findSuitableHostForMigration(self.apiclient, vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].memorytotal self.assertEqual( resource_count, resource_count_after_migrate, "Resource count should be same after starting the instance", ) return
def test_03_multiple_core_vm_delete_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create two domains and set specific resource (cpu) limit for them # 2. Create compute offering with 4 core CPU & deploy vm # 3. Update Resource count for the domains # 4. delete instance and check resource count # 5. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].cputotal self.assertEqual(resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU return
def test_01_multiplecore_start_stop_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Stop VM & verify the update resource count of Root Admin Account # 3. Start VM & verify the update resource count of Root Admin Account # 4. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def test_03_delete_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM in child domains of root domain & Deploy VM # 2. List Resource count for the Memory usage # 3. Delete instance # 4. Resource count should list as 0 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.getUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal self.assertEqual(resource_count, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) # RAM return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(Test42xBugsMgmtSvr, cls).getClsTestClient() cls.apiClient = cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Domain, Zone, Template cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.pod = get_pod(cls.apiClient, zone_id=cls.zone.id) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"] ) cls.services['mode'] = cls.zone.networktype cls.services["hypervisor"] = cls.testClient.getHypervisorInfo() # Creating Disk offering, Service Offering and Account cls.service_offering = ServiceOffering.create( cls.apiClient, cls.services["service_offerings"]["tiny"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) # Create account cls.account_2 = Account.create( cls.api_client, cls.services["account2"], 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 ) # add objects created in setUpCls to the _cleanup list cls._cleanup = [cls.account, cls.account_2, cls.service_offering] except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def test_01_stop_start_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2 .List Resource count for the root admin Memory usage # 3. Stop and start instance, resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].memorytotal self.assertEqual(resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].memorytotal self.assertEqual(resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def setupAccounts(self): try: self.parent_domain = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.parentd_admin = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.parent_domain.id) # Create sub-domains and their admin accounts self.cdomain_1 = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id) self.cdomain_2 = Domain.create( self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id) self.cadmin_1 = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_1.id) self.cadmin_2 = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_2.id) # Cleanup the resources created at end of test self.cleanup.append(self.cadmin_1) self.cleanup.append(self.cadmin_2) self.cleanup.append(self.cdomain_1) self.cleanup.append(self.cdomain_2) self.cleanup.append(self.parentd_admin) self.cleanup.append(self.parent_domain) users = { self.cdomain_1: self.cadmin_1, self.cdomain_2: self.cadmin_2 } except Exception as e: return [FAIL, e, None] return [PASS, None, users]
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: cls.unsupportedHypervisor = True return cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls._cleanup.append(cls.service_offering) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name return
def setUp(self): self.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): try: self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.cleanup = [ self.account, ] self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.public_ip = PublicIPAddress.create( self.apiclient, accountid=self.virtual_machine.account, zoneid=self.virtual_machine.zoneid, domainid=self.virtual_machine.domainid, services=self.services["virtual_machine"] ) return except CloudstackAPIException as e: self.tearDown() raise e
def setUp(self): self.routers = [] self.networks = [] self.ips = [] self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.account = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.logger.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = '10.1.1.1/16' self.vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.cleanup = [self.vpc, self.vpc_off, self.account] return
def matchResourceCount(apiclient, expectedCount, resourceType, accountid=None, projectid=None): """Match the resource count of account/project with the expected resource count""" try: resourceholderlist = None if accountid: resourceholderlist = Account.list(apiclient, id=accountid) elif projectid: resourceholderlist = Project.list(apiclient, id=projectid, listall=True) validationresult = validateList(resourceholderlist) assert validationresult[0] == PASS, "accounts list validation failed" if resourceType == RESOURCE_PRIMARY_STORAGE: resourceCount = resourceholderlist[0].primarystoragetotal elif resourceType == RESOURCE_SECONDARY_STORAGE: resourceCount = resourceholderlist[0].secondarystoragetotal elif resourceType == RESOURCE_CPU: resourceCount = resourceholderlist[0].cputotal elif resourceType == RESOURCE_MEMORY: resourceCount = resourceholderlist[0].memorytotal assert str(resourceCount) == str( expectedCount ), "Resource count %s should match with the expected resource count %s" % (resourceCount, expectedCount) except Exception as e: return [FAIL, e] return [PASS, None]
def setUpClass(cls): cls.testClient = super(TestCreateTemplate, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: raise unittest.SkipTest("Template creation from root volume is not supported in LXC") cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering ] return
def setUpClass(cls): testClient = super(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.apiclient = self.testClient.getApiClient() self.testdata = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["small"] ) #build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): testClient = super(TestRouting, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = Services().services cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) # cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["zoneid"] = cls.zone.id cls._cleanup = [] 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.account = Account.create( cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls._cleanup.append(cls.account) cls.services["publiciprange"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offering"] ) cls._cleanup.append(cls.service_offering) cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["virtual_machine"], zoneid = cls.services["zoneid"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup.append(cls.virtual_machine)
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 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"]["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 = [ cls.service_offering, cls.disk_offering, cls.custom_disk_offering, cls.account ]
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 setUpClass(cls): testClient = super(TestRouterRules, 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() 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"] # Create an account, network, VM and IP addresses cls.account = Account.create( cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) 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 ) cls.defaultNetworkId = cls.virtual_machine.nic[0].networkid cls._cleanup = [ cls.virtual_machine, cls.account, cls.service_offering ]
def setUpClass(cls): testClient = super(TestServiceOfferings, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.service_offering_1 = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]) cls.service_offering_2 = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]) 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 # 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"]) 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._cleanup = [cls.small_offering, cls.medium_offering, cls.account] return
def setUpClass(cls): testClient = super(TestScaleVm, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'): cls.unsupportedHypervisor = True return # Get Zone, Domain and templates domain = get_domain(cls.apiclient) zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = zone.networktype template = get_template(cls.apiclient, zone.id, cls.services["ostype"]) if template == FAILED: assert False, "get_template() failed to return template\ with description %s" % cls.services["ostype"] # Set Zones and disk offerings ?? cls.services["small"]["zoneid"] = zone.id cls.services["small"]["template"] = template.id # Create account, service offerings, vm. cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) cls.small_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"]) cls.big_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["big"]) # create a virtual machine cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"]) cls._cleanup = [cls.small_offering, cls.account]
def setUpClass(cls): # Setup cls.testClient = super(TestDummyBackupAndRecovery, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] # Check backup configuration values, set them to enable the dummy provider backup_enabled_cfg = Configurations.list(cls.api_client, name='backup.framework.enabled', zoneid=cls.zone.id) backup_provider_cfg = Configurations.list(cls.api_client, name='backup.framework.provider.plugin', zoneid=cls.zone.id) cls.backup_enabled = backup_enabled_cfg[0].value cls.backup_provider = backup_provider_cfg[0].value if cls.backup_enabled == "false": Configurations.update(cls.api_client, 'backup.framework.enabled', value='true', zoneid=cls.zone.id) if cls.backup_provider != "dummy": Configurations.update(cls.api_client, 'backup.framework.provider.plugin', value='dummy', zoneid=cls.zone.id) if cls.hypervisor.lower() != 'simulator': return cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.offering = ServiceOffering.create(cls.api_client,cls.services["service_offerings"]["small"]) cls.vm = VirtualMachine.create(cls.api_client, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.offering.id, mode=cls.services["mode"]) cls._cleanup = [cls.offering, cls.account] # Import a dummy backup offering to use on tests cls.provider_offerings = BackupOffering.listExternal(cls.api_client, cls.zone.id) cls.debug("Importing backup offering %s - %s" % (cls.provider_offerings[0].externalid, cls.provider_offerings[0].name)) cls.offering = BackupOffering.importExisting(cls.api_client, cls.zone.id, cls.provider_offerings[0].externalid, cls.provider_offerings[0].name, cls.provider_offerings[0].description) cls._cleanup.append(cls.offering)
def setupAccounts(self): try: self.parent_domain = Domain.create(self.apiclient, services=self.services[ "domain"], parentdomainid=self.domain.id) self.parentd_admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.parent_domain.id) # Cleanup the resources created at end of test self.cleanup.append(self.parent_domain) self.cleanup.append(self.parentd_admin) except Exception as e: return [FAIL, e] return [PASS, None]
def setUpClass(cls): cls.testClient = super(TestSnapshotLimit, 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() cls._cleanup = [] try: template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["server"]["zoneid"] = cls.zone.id cls.services["template"] = template.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name if cls.zone.localstorageenabled: cls.services["service_offering"]["storagetype"] = "local" cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls._cleanup.append(cls.service_offering) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["server"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls._cleanup.append(cls.virtual_machine) except Exception, e: cls.tearDownClass() unittest.SkipTest("setupClass fails for %s" % cls.__name__) raise e
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.logger.debug("Creating compute offering: %s" % cls.services["compute_offering"]["name"]) cls.compute_offering = ServiceOffering.create( cls.apiclient, cls.services["compute_offering"]) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls.hypervisor = testClient.getHypervisorInfo() cls.logger.debug( "Downloading Template: %s from: %s" % (cls.services["template"][cls.hypervisor.lower()], cls.services["template"][cls.hypervisor.lower()]["url"])) cls.template = Template.register( cls.apiclient, cls.services["template"][cls.hypervisor.lower()], cls.zone.id, hypervisor=cls.hypervisor.lower(), account=cls.account.name, domainid=cls.domain.id) cls.template.download(cls.apiclient) if cls.template == FAILED: assert False, "get_template() failed to return template" cls.logger.debug("Successfully created account: %s, id: \ %s" % (cls.account.name, cls.account.id)) cls._cleanup = [cls.template, cls.account, cls.compute_offering] return
def setUpClass(cls): testClient = super(TestlistTemplates, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"]) cls.hypervisor = cls.testClient.getHypervisorInfo() builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id) cls.testdata["templates"]["url"] = builtin_info[0] cls.testdata["templates"]["hypervisor"] = builtin_info[1] cls.testdata["templates"]["format"] = builtin_info[2] if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local' cls.testdata["disk_offering"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared' cls.testdata["disk_offering"]["storagetype"] = 'shared' cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id cls.testdata["virtual_machine"]["template"] = cls.template.id cls.testdata["custom_volume"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.apiclient, cls.testdata["service_offerings"]["tiny"]) cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.cleanup = [] # Create 1 domain admin account cls.domain = Domain.create(cls.apiclient, cls.testdata["domain"]) cls.account = Account.create(cls.apiclient, cls.testdata["account"], admin=True, domainid=cls.domain.id) cls.debug("Created account %s in domain %s" % (cls.account.name, cls.domain.id)) cls.cleanup.append(cls.account) cls.cleanup.append(cls.domain)
def setUpClass(cls): testClient = super(TestUnableToRevertSnapshot, 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.skiptest = False if cls.hypervisor.lower() not in ['xenserver']: cls.skiptest = True return # 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 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"], ) cls._cleanup = [ cls.account, cls.service_offering, ] except Exception as e: cls.tearDownClass() raise e 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 (KVM.lower(), "hyperv", "lxc", XEN_SERVER.lower()): 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' else: cls.storagetype = 'shared' cls.services["service_offerings"]["tiny"][ "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.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) 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( 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.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"], 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 test_deploy_vm_multiple(self): """Test Multiple Deploy Virtual Machine # Validate the following: # 1. deploy 2 virtual machines # 2. listVirtualMachines using 'ids' parameter returns accurate information """ account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.cleanup.append(account) virtual_machine1 = VirtualMachine.create( self.apiclient, self.services["small"], accountid=account.name, domainid=account.domainid, serviceofferingid=self.service_offering.id ) virtual_machine2 = VirtualMachine.create( self.apiclient, self.services["small"], accountid=account.name, domainid=account.domainid, serviceofferingid=self.service_offering.id ) list_vms = VirtualMachine.list(self.apiclient, ids=[virtual_machine1.id, virtual_machine2.id], listAll=True) self.debug( "Verify listVirtualMachines response for virtual machines: %s, %s" % ( virtual_machine1.id, virtual_machine2.id) ) self.assertEqual( isinstance(list_vms, list), True, "List VM response was not a valid list" ) self.assertEqual( len(list_vms), 2, "List VM response was empty, expected 2 VMs" )
def setUpClass(cls): testClient = super(TestRemoteDiagnostics, 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)
def setUp(self): self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] 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 # Before running this test, register a windows template with ostype as # 'Windows 7 (32-bit)' self.template = get_template( self.apiclient, self.zone.id, self.testdata["ostype"]) if self.template == FAILED: assert False, "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 ) self.testdata["vgpu260q"]["zoneid"] = self.zone.id self.testdata["vgpu260q"]["template"] = self.template.id self.testdata["vgpu140q"]["zoneid"] = self.zone.id self.testdata["vgpu140q"]["template"] = self.template.id self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [ { 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, { 'vgpuType': 'GRID K120Q'}] # create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offerings"]["vgpu260qwin"], ) # build cleanup list self.cleanup = [ self.service_offering, self.account ]
def setUpClass(cls): cls.testClient = super(TestVPCRoutersBasic, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.vpcSupported = True cls._cleanup = [] if cls.hypervisor.lower() == 'hyperv': cls.vpcSupported = False 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.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls._cleanup = [cls.account] cls._cleanup.append(cls.vpc_off) #cls.debug("Enabling the VPC offering created") cls.vpc_off.update(cls.api_client, state='Enabled') # cls.debug("creating a VPC network in the account: %s" % # cls.account.name) cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create(cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup.append(cls.service_offering) return
def setUpClass(cls): cls.testClient = super( TestUpdateSecurityGroup, 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.template = get_template(cls.apiclient, cls.zone.id) cls._cleanup = [] if str(cls.zone.securitygroupsenabled) != "True": sys.exit(1) cls.logger = logging.getLogger("TestUpdateSecurityGroup") 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) testClient = super(TestUpdateSecurityGroup, cls).getClsTestClient() cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype # 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.account = Account.create( cls.apiclient, cls.testdata["acl"]["accountD2"], admin=True, domainid=cls.user_domain.id ) cls._cleanup.append(cls.account) cls._cleanup.append(cls.user_domain)
def setUpClass(cls): cls.logger = logging.getLogger('TestVPCRemoteAccessVPN') cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.startTime = time.time() testClient = super(TestVpcRemoteAccessVpn, 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.compute_offering = ServiceOffering.create( cls.apiclient, cls.services["compute_offering"]) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) if cls.services["default_hypervisor"] == "kvm": cls.template = Template.register( cls.apiclient, cls.services["template_kvm"], cls.zone.id, hypervisor=cls.services["template_kvm"]["hypervisor"], account=cls.account.name, domainid=cls.domain.id) else: cls.template = Template.register( cls.apiclient, cls.services["template_xen"], cls.zone.id, hypervisor=cls.services["template_xen"]["hypervisor"], account=cls.account.name, domainid=cls.domain.id) if cls.template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "compute_offering"] cls.services["virtual_machine"]["hypervisor"] = cls.services[ "default_hypervisor"] cls.cleanup = [cls.account]
def setUpClass(cls): cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls._cleanup = [] # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.unsupportedHypervisor = False cls.hypervisor = get_hypervisor_type(cls.api_client) if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["server"]["zoneid"] = cls.zone.id cls.services["template"] = template.id # Create VMs, NAT Rules etc cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["server"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls._cleanup = [ cls.service_offering, cls.account, ] return
def create_account(cls, apiclient, services, accounttype=None, domainid=None, roleid=None): """Creates an account""" cmd = createAccount.createAccountCmd() # 0 - User, 1 - Root Admin, 2 - Domain Admin if accounttype: cmd.accounttype = accounttype else: cmd.accounttype = 1 cmd.email = services["email"] cmd.firstname = services["firstname"] cmd.lastname = services["lastname"] cmd.password = services["password"] username = services["username"] # Limit account username to 99 chars to avoid failure # 6 chars start string + 85 chars apiclientid + 6 chars random string + 2 chars joining hyphen string = 99 username = username[:6] apiclientid = apiclient.id[-85:] if len( apiclient.id) > 85 else apiclient.id cmd.username = "******".join([username, random_gen(id=apiclientid, size=6)]) if "accountUUID" in services: cmd.accountid = "-".join([services["accountUUID"], random_gen()]) if "userUUID" in services: cmd.userid = "-".join([services["userUUID"], random_gen()]) if domainid: cmd.domainid = domainid if roleid: cmd.roleid = roleid account = apiclient.createAccount(cmd) return Account(account.__dict__)
def setupAccount(self, accountType): """Setup the account required for the test""" try: if accountType == CHILD_DOMAIN_ADMIN: self.domain = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.account = Account.create(self.apiclient, self.services["account"], domainid=self.domain.id, admin=True) self.cleanup.append(self.account) if accountType == CHILD_DOMAIN_ADMIN: self.cleanup.append(self.domain) except Exception as e: return [FAIL, e] return [PASS, None]
def test_02_deploy_vm_account_limit_reached(self): """Test Try to deploy VM with admin account where account has used the resources but @ domain they are available""" self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"], accountid=self.child_do_admin.name, domainid=self.child_do_admin.domainid, diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id) accounts = Account.list(self.apiclient, id=self.child_do_admin.id) self.assertEqual(validateList(accounts)[0], PASS, "accounts list validation failed") self.initialResourceCount = int(accounts[0].primarystoragetotal) accountLimit = self.initialResourceCount + 3 self.debug("Setting up account and domain hierarchy") response = self.updatePrimaryStorageLimits(accountLimit=accountLimit) 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, account=self.child_do_admin.name, domainid=self.child_do_admin.domainid, diskofferingid=disk_offering.id) except Exception as e: self.fail("failed to create volume: %s" % e) with self.assertRaises(Exception): Volume.create(self.apiclient, self.services["volume"], zoneid=self.zone.id, account=self.child_do_admin.name, domainid=self.child_do_admin.domainid, diskofferingid=disk_offering.id) return
def setUpClass(self): testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient() self.apiclient = testClient.getApiClient() self.testdata = self.testClient.getParsedTestDataConfig() #Need to add check whether zone containing the xen hypervisor or not as well hosts = list_hosts(self.apiclient, hypervisor="XenServer") if hosts is None: raise unittest.SkipTest( "There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response" ) else: gpuhosts = 0 for ghost in hosts: if ghost.hypervisorversion >= "6.2.0": sshClient = SshClient( host=ghost.ipaddress, port=22, user='******', passwd=self.testdata["host_password"]) if ghost.hypervisorversion == "6.2.0": res = sshClient.execute( "xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503" ) if len(res) == 0: continue res = sshClient.execute( "xe vgpu-type-list model-name=\"GRID K120Q\"") if len(res) != 0: gpuhosts = gpuhosts + 1 else: continue if gpuhosts == 0: raise unittest.SkipTest( "No XenServer available with GPU Drivers installed") self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) #Creating Account self.account = Account.create(self.apiclient, self.testdata["account"], domainid=self.domain.id) self._cleanup = [self.account]
def setUpClass(cls): # We want to fail quicker if it's failure socket.setdefaulttimeout(60) cls.testClient = super(TestVPCIpTablesPolicies, 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.hypervisor = cls.testClient.getHypervisorInfo() cls.template = get_test_template( cls.apiclient, cls.zone.id, cls.hypervisor) cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.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('TestVPCIpTablesPolicies') 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 setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.virtual_machine_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.public_ip = PublicIPAddress.create( self.apiclient, self.virtual_machine.account, self.virtual_machine.zoneid, self.virtual_machine.domainid, self.services["virtual_machine"] ) FireWallRule.create( self.apiclient, ipaddressid=self.public_ip.ipaddress.id, protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]], startport=self.services["fwrule"]["startport"], endport=self.services["fwrule"]["endport"] ) self.cleanup = [self.account, ] return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create( self.apiclient, self.services["account"], domainid=self.domain.id ) self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.virtual_machine_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.public_ip = PublicIPAddress.create( self.apiclient, self.virtual_machine.account, self.virtual_machine.zoneid, self.virtual_machine.domainid, self.services["virtual_machine"] ) NATRule.create( self.apiclient, self.virtual_machine, self.services["natrule"], ipaddressid=self.public_ip.ipaddress.id ) self.cleanup = [self.account, ] 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 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]