def setupAccounts(self): self.debug("Creating a sub-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.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 setupAccounts(self): self.debug("Creating a sub-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.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 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 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 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 setUpClass(cls): cls.apiClient = super(TestDeployVmWithUserData, cls).getClsTestClient().getApiClient() cls.services = Services().services cls.zone = get_zone(cls.apiClient, cls.services) if cls.zone.localstorageenabled: #For devcloud since localstroage is enabled cls.services["service_offering"]["storagetype"] = "local" cls.service_offering = ServiceOffering.create( cls.apiClient, cls.services["service_offering"] ) cls.account = Account.create(cls.apiClient, services=cls.services["account"]) cls.cleanup = [cls.account] cls.template = get_template( cls.apiClient, cls.zone.id, cls.services["ostype"] ) cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) # Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit. # CS however allows for upto 4K bytes in the code. So this must succeed. # Overall, the query length must not exceed 4K, for then the json decoder # will fail this operation at the marvin client side itcls. user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) cls.services["virtual_machine"]["userdata"] = user_data
def test_05_remove_used_range(self): """ Test removing used vlan range """ # 1. Use a vlan id from existing range by deploying an instance which # will create a network with vlan id from this range # 4. Now try to remove this vlan range # 5. Vlan range should not get removed, should throw error account = Account.create(self.apiclient,self.services["account"], domainid=self.domain.id) self.debug("Deploying instance in the account: %s" % account.name) try: self.virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], accountid=account.name,domainid=account.domainid, serviceofferingid=self.service_offering.id, mode=self.zone.networktype) self.debug("Deployed instance in account: %s" % account.name) self.debug("Trying to remove vlan range : %s , This should fail" % self.vlan["partial_range"][0]) with self.assertRaises(Exception) as e: self.physicalnetwork.update(self.apiClient, id = self.physicalnetworkid, vlan = self.vlan["partial_range"][0]) self.debug("operation failed with exception: %s" % e.exception) account.delete(self.apiclient) except Exception as e: self.fail("Exception in test case: %s" % e) return
def create_domain_account_user(parentDomain=None): domain = Domain.create(cls.api_client, cls.services["domain"], parentdomainid=parentDomain.id if parentDomain else None) cls._cleanup.append(domain) # Create an Account associated with domain account = Account.create(cls.api_client, cls.services["account"], domainid=domain.id) cls._cleanup.append(account) # Create an User, Project, Volume associated with account user = User.create(cls.api_client, cls.services["user"], account=account.name, domainid=account.domainid) cls._cleanup.append(user) project = Project.create(cls.api_client, cls.services["project"], account=account.name, domainid=account.domainid) cls._cleanup.append(project) volume = Volume.create(cls.api_client, cls.services["volume"], zoneid=cls.zone.id, account=account.name, domainid=account.domainid, diskofferingid=cls.disk_offering.id) cls._cleanup.append(volume) return {'domain':domain, 'account':account, 'user':user, 'project':project, 'volume':volume}
def setUpClass(cls): cls.apiclient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) cls.template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.hosts = Host.list(cls.apiclient, type='Routing') cls.clusters = Cluster.list(cls.apiclient) cls.cleanup = [ cls.account ]
def setUpClass(cls): cls.api_client = super(TestSnapshotOnRootVolume, cls).getClsTestClient().getApiClient() cls.services = Services().services cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # pdb.set_trace() cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [ cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2 ]
def setUp(self): 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.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.public_ip = PublicIPAddress.create( self.apiclient, self.virtual_machine.account, self.virtual_machine.zoneid, self.virtual_machine.domainid, self.services["virtual_machine"] ) self.cleanup = [ self.account, ] return
def setupProjectAccounts(self): self.debug("Creating a domain under: %s" % self.domain.name) 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) # Create project as a domain admin self.project = Project.create(self.apiclient, self.services["project"], account=self.admin.name, domainid=self.admin.domainid) # Cleanup created project at end of test self.cleanup.append(self.project) self.cleanup.append(self.admin) self.cleanup.append(self.domain) self.debug("Created project with domain admin with name: %s" % self.project.name) projects = Project.list(self.apiclient, id=self.project.id, listall=True) self.assertEqual(isinstance(projects, list), True, "Check for a valid list projects response") project = projects[0] self.assertEqual(project.name, self.project.name, "Check project name from list response") return
def setUpClass(cls): cls._cleanup = [] cls.api_client = super(TestEgressFWRules, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone Domain and create Domains and sub Domains. cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.services['mode'] = cls.zone.networktype # Get and set template id for VM creation. cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id parentDomain = None cls.domain = Domain.create(cls.api_client, cls.services["domain"], parentdomainid=parentDomain.id if parentDomain else None) cls._cleanup.append(cls.domain) # Create an Account associated with domain cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # Create service offerings. cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"]) # Cleanup cls._cleanup.append(cls.service_offering)
def setUpClass(cls): cls.api_client = super(TestSnapshotOnRootVolume, cls).getClsTestClient().getApiClient() cls.services = Services().services cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.template = get_template( cls.api_client, cls.zone.id, cls.services["ostype"]) cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id) # pdb.set_trace() cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"], domainid=cls.domain.id) cls.service_offering2 = ServiceOffering.create( cls.api_client, cls.services["service_offering2"]) cls.disk_offering2 = DiskOffering.create( cls.api_client, cls.services["disk_offering2"], domainid=cls.domain.id) cls._cleanup = [cls.account, cls.service_offering, cls.disk_offering, cls.service_offering2, cls.disk_offering2]
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient, self.testdata) self.zone = get_zone(self.apiclient, self.testdata) 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 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.services) self.zone = get_zone(self.apiclient, self.services) self.services["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.services["ostype"], templatetype='USER') #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 setupProjectAccounts(self): self.debug("Creating a domain under: %s" % self.domain.name) 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 ) # Create project as a domain admin self.project = Project.create(self.apiclient, self.services["project"], account=self.admin.name, domainid=self.admin.domainid) # Cleanup created project at end of test self.cleanup.append(self.project) self.cleanup.append(self.admin) self.cleanup.append(self.domain) self.debug("Created project with domain admin with name: %s" % self.project.name) projects = Project.list(self.apiclient, id=self.project.id, listall=True) self.assertEqual(isinstance(projects, list), True, "Check for a valid list projects response") project = projects[0] self.assertEqual(project.name, self.project.name, "Check project name from list response") return
def setupAccounts(self, account_limit=2, domain_limit=2, project_limit=2): self.debug("Creating a domain under: %s" % self.domain.name) self.child_domain = Domain.create(self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id) self.debug("domain crated with domain id %s" % self.child_domain.id) self.child_do_admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.child_domain.id) self.debug("domain admin created for domain id %s" % self.child_do_admin.domainid) # Create project as a domain admin self.project = Project.create(self.apiclient, self.services["project"], account=self.child_do_admin.name, domainid=self.child_do_admin.domainid) # Cleanup created project at end of test self.cleanup.append(self.project) # Cleanup accounts created self.cleanup.append(self.child_do_admin) self.cleanup.append(self.child_domain) self.debug("Updating the CPU resource count for domain: %s" % self.child_domain.name) # Update resource limits for account 1 responses = Resources.updateLimit(self.apiclient, resourcetype=8, max=account_limit, account=self.child_do_admin.name, domainid=self.child_do_admin.domainid) self.debug("CPU Resource count for child domain admin account is now: %s" % responses.max) self.debug("Updating the CPU limit for project") responses = Resources.updateLimit(self.apiclient, resourcetype=8, max=project_limit, projectid=self.project.id) self.debug("CPU Resource count for project is now") self.debug(responses.max) self.debug("Updating the CPU limit for domain only") responses = Resources.updateLimit(self.apiclient, resourcetype=8, max=domain_limit, domainid=self.child_domain.id) self.debug("CPU Resource count for domain %s with id %s is now %s" % (responses.domain, responses.domainid, responses.max)) 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.testdata) self.zone = get_zone(self.apiclient, self.testdata) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) # 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.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.apiClient = super(TestDeployVmWithUserData, cls).getClsTestClient().getApiClient() cls.services = Services().services cls.zone = get_zone(cls.apiClient, cls.services) if cls.zone.localstorageenabled: #For devcloud since localstroage is enabled cls.services["service_offering"]["storagetype"] = "local" cls.service_offering = ServiceOffering.create( cls.apiClient, cls.services["service_offering"]) cls.account = Account.create(cls.apiClient, services=cls.services["account"]) cls.cleanup = [cls.account] cls.template = get_template(cls.apiClient, cls.zone.id, cls.services["ostype"]) cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) # Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit. # CS however allows for upto 4K bytes in the code. So this must succeed. # Overall, the query length must not exceed 4K, for then the json decoder # will fail this operation at the marvin client side itcls. user_data = ''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) cls.services["virtual_machine"]["userdata"] = user_data
def setUp(self): self.apiclient = self.testClient.getApiClient() self.account = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.cleanup = [self.account] self.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.cleanup.append(self.vpc_off) self.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.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) return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.account = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.domain.id ) self.cleanup = [self.account] self.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) self.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.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 ) return
def test_add_static_nat_rule(self, value): """ Add secondary IP to NIC of a VM""" # Steps: # 1. Create Account and create network in it (isoalted/ shared/ vpc) # 2. Deploy a VM in this network and account # 3. Add 2 secondary IPs to the default nic of VM # 4. Acquire public IP, open firewall for it, and # create static NAT rule for this public IP to the 1st secondary IP # 5. Repeat step 4 for another public IP # 6. Repeat step 4 for 2nd secondary IP # 7. Repeat step 4 for invalid secondary IP # 8. Try to remove 1st secondary IP (with active static nat rule) # Validations: # 1. Step 4 should succeed # 2. Step 5 should succeed # 3. Step 6 should succeed # 4. Step 7 should fail # 5. Step 8 should succeed self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id) self.cleanup.append(self.account) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) try: ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="staticnat"), PASS, "Failure in creating NAT rule") self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="staticnat"), FAIL, "Failure in creating NAT rule") self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_2.ipaddress, value, ruletype="staticnat"), PASS, "Failure in creating NAT rule") self.assertEqual(createNetworkRules(self, virtual_machine, network, "255.255.255.300", value, ruletype="staticnat"), FAIL, "Failure in NAT rule creation") try: NIC.removeIp(self.apiclient, ipaddress_1.id) self.fail("Ip address should not get removed when active static NAT rule is defined for it") except Exception as e: self.debug("Exception while removing secondary ip address as expected because static nat rule is present for it") return
def test_operations_non_root_admin_api_client(self, value): """Test basic operations using non root admin apii client""" # Steps: # 1. Create Domain and Account in it # 2. Create network in it (isoalted/ shared/ vpc) # 3. Create User API client of this account # 4. Deploy a VM in this network and account # 5. Add secondary IP to the default nic of VM using non root admin api client # 6. List secondary IPs using non root admin api client # 7. Remove secondary IP using non root admin api client # Validations: # 1. All the operations should be successful child_domain = Domain.create(self.apiclient,services=self.services["domain"], parentdomainid=self.domain.id) self.account = Account.create(self.apiclient,self.services["account"],domainid=child_domain.id) self.cleanup.append(self.account) self.cleanup.append(child_domain) apiclient = self.testClient.createUserApiClient(UserName=self.account.name, DomainName=self.account.domain) if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)): self.skipTest("Skipping test as %s network is not supported in basic zone" % value) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) try: NIC.list(apiclient, virtualmachineid=virtual_machine.id) except Exception as e: self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e)) try: NIC.list(apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id) except Exception as e: self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" % (virtual_machine.id, virtual_machine.nic[0].id, e)) try: NIC.removeIp(apiclient, ipaddressid=ipaddress_1.id) except Exception as e: self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e)) return
def test_disable_static_nat(self, value): """ Add secondary IP to NIC of a VM""" # Steps: # 1. Create Account and create network in it (isoalted/ shared/ vpc) # 2. Deploy a VM in this network and account # 3. Add 2 secondary IPs to the default nic of VM # 4. Acquire public IP, open firewall for it, and # enable static NAT rule for this public IP to the 1st secondary IP # 5. Disable the static nat rule and enable it again # Validations: # 1. Verify step 5 by listing seconday IP and checking the appropriate flag self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id) self.cleanup.append(self.account) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name, zoneid=self.zone.id,domainid=self.account.domainid, networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None) if value != VPC_NETWORK: FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id, protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]], startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"]) StaticNATRule.enable(self.apiclient, public_ip.ipaddress.id, virtual_machine.id, network.id, vmguestip=ipaddress_1.ipaddress) self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, True) # Disabling static NAT StaticNATRule.disable(self.apiclient, public_ip.ipaddress.id) self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, False) StaticNATRule.enable(self.apiclient, public_ip.ipaddress.id, virtual_machine.id, network.id, vmguestip=ipaddress_1.ipaddress) self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, True) public_ip.delete(self.apiclient) return
def setUpClass(cls): cls.api_client = super(TestServiceOfferings, cls).getClsTestClient().getApiClient() cls.services = Services().services domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.services['mode'] = cls.zone.networktype cls.service_offering_1 = ServiceOffering.create( cls.api_client, cls.services["off"] ) cls.service_offering_2 = ServiceOffering.create( cls.api_client, cls.services["off"] ) template = get_template( cls.api_client, cls.zone.id, 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.api_client, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["small"] ) cls.medium_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["medium"] ) cls.medium_virtual_machine = VirtualMachine.create( cls.api_client, 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 setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.cleanup = [self.account] return
def test_add_ip_to_nic(self, value): """ Add secondary IP to NIC of a VM""" # Steps: # 1. Create Account and create network in it (isoalted/ shared/ vpc) # 2. Deploy a VM in this network and account # 3. Add secondary IP to the default nic of VM # 4. Try to add the same IP again # 5. Try to add secondary IP providing wrong virtual machine id # 6. Try to add secondary IP with correct virtual machine id but wrong IP address # Validations: # 1. Step 3 should succeed # 2. Step 4 should fail # 3. Step 5 should should fail # 4. Step 6 should fail self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id) self.cleanup.append(self.account) if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)): self.skipTest("Skipping test as %s network is not supported in basic zone" % value) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) try: NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress=ipaddress_1.ipaddress) self.debug("Adding already added secondary IP %s to NIC of vm %s succeeded, should have failed" % (ipaddress_1.ipaddress, virtual_machine.id)) except Exception as e: self.debug("Failed while adding already added secondary IP to NIC of vm %s" % virtual_machine.id) try: NIC.addIp(self.apiclient, id=(virtual_machine.nic[0].id + random_gen())) self.fail("Adding secondary IP with wrong NIC id succeded, it shoud have failed") except Exception as e: self.debug("Failed while adding secondary IP to wrong NIC") try: NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress = "255.255.255.300") self.fail("Adding secondary IP with wrong ipaddress succeded, it should have failed") except Exception as e: self.debug("Failed while adding wrong secondary IP to NIC of VM %s" % virtual_machine.id) return
def test_deploy_virtual_machines_static_offering(self, value): """Test deploy VM with static offering""" # Steps: # 1. Create admin/user account and create its user api client # 2. Create a static compute offering # 3. Deploy a VM with account api client and static service offering # 4. Repeat step 3 but also pass custom values for cpu number, cpu speed and memory # while deploying VM # Validations: # 1. Step 3 should succeed # 2. Step 4 should fail isadmin=True if value == USER_ACCOUNT: isadmin=False # Create Account self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin) apiclient = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.cleanup.append(self.account) # Create service offering self.services["service_offering"]["cpunumber"] = 2 self.services["service_offering"]["cpuspeed"] = 256 self.services["service_offering"]["memory"] = 128 serviceOffering = ServiceOffering.create(self.apiclient, self.services["service_offering"]) self.cleanup_co.append(serviceOffering) # Deploy VM with static service offering try: VirtualMachine.create(apiclient,self.services["virtual_machine"], serviceofferingid=serviceOffering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) # Deploy VM with static service offering, also with custom values try: VirtualMachine.create(apiclient,self.services["virtual_machine"], serviceofferingid=serviceOffering.id, customcpunumber=4, customcpuspeed=512, custommemory=256, accountid=self.account.name,domainid=self.account.domainid) self.fail("VM creation should have failed, it succeeded") except Exception as e: self.debug("vm creation failed as expected: %s" % e) 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.cleanup = [self.account, ] return
def setUpClass(cls): cls.services = Services().services cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient() # Get Zone, Domain and templates domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) 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"] ) # 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["iso"]["zoneid"] = cls.zone.id cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=domain.id ) cls.debug(cls.account.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) 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'] ) cls.cleanup = [ cls.service_offering, cls.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.testdata) self.zone = get_zone(self.apiclient, self.testdata) 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] # Validate the following: # 1. Virtual Machine is accessible via SSH # 2. listVirtualMachines returns accurate information self.virtual_machine = VirtualMachine.create( self.apiclient, self.testdata["virtual_machine"], accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=self.template.id) list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id) self.debug( "Verify listVirtualMachines response for virtual machine: %s"\ % self.virtual_machine.id ) self.assertEqual(isinstance(list_vms, list), True, "List VM response was not a valid list") self.assertNotEqual(len(list_vms), 0, "List VM response was empty") vm = list_vms[0] self.assertEqual(vm.id, self.virtual_machine.id, "Virtual Machine ids do not match") self.assertEqual(vm.name, self.virtual_machine.name, "Virtual Machine names do not match") self.assertEqual(vm.state, "Running", msg="VM is not in Running state")
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create(self.apiclient, self.services["account"], admin=True) self.debug("Creating service offering with 5 GB RAM") 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"], admin=True ) self.debug("Creating service offering with 5 GB RAM") 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"], admin=True) self.cleanup = [self.account] self.debug("Setting up account and domain hierarchy") self.setupProjectAccounts() api_client = self.testClient.createUserApiClient(UserName=self.admin.name, DomainName=self.admin.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) self.vm = self.createInstance(project=self.project, service_off=self.service_offering, api_client=api_client) return
def test_disassociate_ip_mapped_to_secondary_ip_through_PF_rule(self, value): """ Add secondary IP to NIC of a VM""" ## Steps: # 1. Create Account and create network in it (isoalted/ shared/ vpc) # 2. Deploy a VM in this network and account # 3. Add secondary IP to the default nic of VM # 4. Acquire public IP, open firewall for it, and # create NAT rule for this public IP to the 1st secondary IP # 5. Try to delete the public IP used for NAT rule # Validations: # 1. Step 5 should succeed self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id) self.cleanup.append(self.account) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name, zoneid=self.zone.id,domainid=self.account.domainid, networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None) if value != VPC_NETWORK: FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id, protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]], startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"]) # Create NAT rule natrule = NATRule.create(self.api_client, virtual_machine, self.services["natrule"],ipaddressid=public_ip.ipaddress.id, networkid=network.id, vmguestip = ipaddress_1.ipaddress) try: public_ip.delete(self.apiclient) except Exception as e: self.fail("Exception while deleting nat rule %s: %s" % (natrule.id, e)) return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create( self.apiclient, self.services["account"], admin=True) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) self.vm = self.createInstance(service_off=self.service_offering) self.cleanup = [ self.account, ] return
def setUpClass(cls): cls.api_client = super(TestBaseImageUpdate, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering_with_reset = ServiceOffering.create( cls.api_client, cls.services["service_offering_with_reset"]) cls.service_offering_without_reset = ServiceOffering.create( cls.api_client, cls.services["service_offering_without_reset"]) cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.vm_with_reset = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_with_reset.id, ) cls.vm_with_reset_root_disk_id = cls.get_root_device_uuid_for_vm( cls.vm_with_reset.id, cls.vm_with_reset.rootdeviceid) cls.vm_without_reset = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_without_reset.id, ) cls.vm_without_reset_root_disk_id = cls.get_root_device_uuid_for_vm( cls.vm_without_reset.id, cls.vm_without_reset.rootdeviceid) cls._cleanup = [ cls.account, cls.service_offering_with_reset, cls.service_offering_without_reset, ] return
def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create(self.apiclient, self.services["account"], admin=True) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) self.vm = self.createInstance(service_off=self.service_offering) self.cleanup = [ self.account, ] return
def setUpClass(cls): cls.api_client = super(TestAntiAffinityRules, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) 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 test_remove_ip_from_nic(self, value): """ Remove secondary IP from NIC of a VM""" # Steps: # 1. Create Account and create network in it (isoalted/ shared/ vpc) # 2. Deploy a VM in this network and account # 3. Add secondary IP to the default nic of VM # 4. Remove the secondary IP # 5. Try to remove secondary ip by giving incorrect ipaddress id # Validations: # 1. Step 4 should succeed # 2. Step 5 should fail self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id) self.cleanup.append(self.account) if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)): self.skipTest("Skipping test as %s network is not supported in basic zone" % value) network = createNetwork(self, value) try: virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.account.domainid) except Exception as e: self.fail("vm creation failed: %s" % e) try: ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id) except Exception as e: self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id) try: NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id) except Exception as e: self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e)) try: NIC.removeIp(self.apiclient, ipaddressid=(ipaddress_1.id + random_gen())) self.fail("Removing invalid IP address, it should have failed") except Exception as e: self.debug("Removing invalid IP failed as expected with Exception %s" % e) return
def setUpClass(cls): cls.services = Services().services cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient() # Get Zone, Domain and templates domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) 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"]) # 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["iso"]["zoneid"] = cls.zone.id cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=domain.id) cls.debug(cls.account.id) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"]) 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']) cls.cleanup = [cls.service_offering, cls.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.testdata) self.zone = get_zone(self.apiclient, self.testdata) 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.apiclient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.services["account"] = cls.account.name cls.hosts = Host.list(cls.apiclient, type='Routing') cls.clusters = Cluster.list(cls.apiclient) cls.cleanup = [cls.account]
def test_06_add_VPN_user_global_admin(self): """Test as global admin, add a new VPN user to an existing VPN entry that was created by another account.""" # Steps for verification # 1. Create a new user and deploy few Vms. # 2. Enable VPN access. Add few VPN users. # 3. Make sure that VPN access works as expected. # 4. As global Admin , add VPN user to this user's existing VPN entry. # Validate the following # 1. The newly added VPN user should get configured to the router of # user account. # 2. We should be able to use this newly created user credential to # establish VPN connection that will give access all VMs of this user self.debug("Enabling VPN connection to account: %s" % self.account.name) self.create_VPN(self.public_ip) self.debug("Creating VPN user for the account: %s" % self.account.name) self.create_VPN_Users() self.debug("Creating a global admin account") admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.account.domainid) self.cleanup.append(admin) self.debug("Creating API client for newly created user") api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Adding new user to VPN as a global admin: %s" % admin.name) try: self.create_VPN_Users(api_client=api_client) except Exception as e: self.fail("Global admin should be allowed to create VPN user: %s" % e) return
def setUpClass(cls): cls.api_client = super(TestAntiAffinityRules, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) 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.api_client = super(TestServiceOfferings, cls).getClsTestClient().getApiClient() cls.services = Services().services domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.services['mode'] = cls.zone.networktype cls.service_offering_1 = ServiceOffering.create( cls.api_client, cls.services["off"]) cls.service_offering_2 = ServiceOffering.create( cls.api_client, cls.services["off"]) template = get_template(cls.api_client, cls.zone.id, 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.api_client, cls.services["account"], domainid=domain.id) cls.small_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["small"]) cls.medium_offering = ServiceOffering.create( cls.api_client, cls.services["service_offerings"]["medium"]) cls.medium_virtual_machine = VirtualMachine.create( cls.api_client, 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 setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.account = Account.create(self.apiclient, self.services["account"], admin=True) self.cleanup = [ self.account, ] self.debug("Setting up account and domain hierarchy") self.setupProjectAccounts() api_client = self.testClient.createUserApiClient( UserName=self.admin.name, DomainName=self.admin.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) self.vm = self.createInstance(project=self.project, service_off=self.service_offering, api_client=api_client) return
def create_domain_account_user(parentDomain=None): domain = Domain.create( cls.api_client, cls.services["domain"], parentdomainid=parentDomain.id if parentDomain else None) cls._cleanup.append(domain) # Create an Account associated with domain account = Account.create(cls.api_client, cls.services["account"], domainid=domain.id) cls._cleanup.append(account) # Create an User, Project, Volume associated with account user = User.create(cls.api_client, cls.services["user"], account=account.name, domainid=account.domainid) cls._cleanup.append(user) project = Project.create(cls.api_client, cls.services["project"], account=account.name, domainid=account.domainid) cls._cleanup.append(project) volume = Volume.create(cls.api_client, cls.services["volume"], zoneid=cls.zone.id, account=account.name, domainid=account.domainid, diskofferingid=cls.disk_offering.id) cls._cleanup.append(volume) return { 'domain': domain, 'account': account, 'user': user, 'project': project, 'volume': volume }
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 limit for domain: %s" % self.domain.name) Resources.updateLimit(self.apiclient, resourcetype=8, max=10, domainid=self.parentd_admin.domainid, account=self.parentd_admin.name) 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=8, max=4, domainid=self.cadmin_1.domainid) self.debug("Updating the Memory resource count for account: %s" % self.cadmin_1.name) Resources.updateLimit(self.apiclient, resourcetype=8, max=2, 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=8, max=5, domainid=self.cadmin_2.domainid) self.debug("Updating the Memory resource count for account: %s" % self.cadmin_2.name) Resources.updateLimit(self.apiclient, resourcetype=8, max=3, 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