def _addLdapConfiguration(self, ldapConfiguration): """ :param ldapConfiguration """ # Setup Global settings updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.basedn" updateConfigurationCmd.value = ldapConfiguration['basedn'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.email.attribute" updateConfigurationCmd.value = ldapConfiguration['emailAttribute'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.user.object" updateConfigurationCmd.value = ldapConfiguration['userObject'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.username.attribute" updateConfigurationCmd.value = ldapConfiguration['usernameAttribute'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) self.debug("start addLdapConfiguration test") ldapServer = addLdapConfiguration.addLdapConfigurationCmd() ldapServer.hostname = ldapConfiguration['hostname'] ldapServer.port = ldapConfiguration['port'] self.debug("calling addLdapConfiguration API command") try: self.apiClient.addLdapConfiguration(ldapServer) self.debug("addLdapConfiguration was successful") return 1 except Exception as e: self.debug("addLdapConfiguration failed %s" % e) return 0
def setConfigurationValue(self, name, value, scope="global"): cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.scopename = scope if scope is "zone": cmd.zoneid = self.zone.id cmd.value = value self.api_client.updateConfiguration(cmd)
def add_global_config(self, name, value): self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.dbclient = self.testClient.getDbConnection() cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value return self.apiclient.updateConfiguration(cmd)
def updateConfig(self, enableFeature): updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "display.human.readable.sizes" updateConfigurationCmd.value = enableFeature updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug( "updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value))
def update_restrict_template_configuration(self, domain_id, value): """ Function to update the global setting "restrict.public.access.to.templates" for domain """ update_configuration_cmd = updateConfiguration.updateConfigurationCmd() update_configuration_cmd.name = "restrict.public.template.access.to.domain" update_configuration_cmd.value = value update_configuration_cmd.scopename = "domain" update_configuration_cmd.scopeid = domain_id return self.apiclient.updateConfiguration(update_configuration_cmd)
def setUp(self): self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.dbclient = self.testClient.getDbConnection() """ Set EnableAdditionalData to true """ updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "enable.additional.vm.configuration" updateConfigurationCmd.value = "true" updateConfigurationCmd.scopename = "account" updateConfigurationResponse = self.apiclient.updateConfiguration( updateConfigurationCmd) self.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value))
def test_09_ldap(self): """ Enable nested groups and try to login with a user that is in nested group --> login should be successful""" if self.services["configurableData"]["link_ldap_details"]["linkLdapNestedUser"] == "": self.skipTest("No nested user mentioned") updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.nested.groups.enable" updateConfigurationCmd.value = 'true' self.apiClient.updateConfiguration(updateConfigurationCmd) loginRes = checklogin( self, self.services["configurableData"]["link_ldap_details"]["linkLdapNestedUser"], self.services["configurableData"]["link_ldap_details"]["linkLdapNestedPassword"], self.parent_domain.name, method="POST") self.debug(loginRes) self.assertEquals(loginRes, 1, self.reason)
def test_list_pod_with_overcommit(self): """Test List Pod Api with cluster CPU and Memory OverProvisioning """ podlist = Pod.list(self.apiclient) for pod in podlist: clusterlist = Cluster.list(self.apiclient, podid=pod.id) if len(clusterlist) > 1: updateCpuOvercommitCmd = updateConfiguration.updateConfigurationCmd() updateCpuOvercommitCmd.clusterid = clusterlist[0].id updateCpuOvercommitCmd.name="cpu.overprovisioning.factor" if clusterlist[0].cpuovercommitratio == clusterlist[1].cpuovercommitratio and clusterlist[0].cpuovercommitratio == "1.0": cpuovercommit = "1.0" updateCpuOvercommitCmd.value="2.0" self.apiclient.updateConfiguration(updateCpuOvercommitCmd) elif clusterlist[0].cpuovercommitratio != clusterlist[1].cpuovercommitratio: cpuovercommit = clusterlist[0].cpuovercommitratio else: cpuovercommit = clusterlist[0].cpuovercommitratio updateCpuOvercommitCmd.value="1.0" self.apiclient.updateConfiguration(updateCpuOvercommitCmd) updateMemoryOvercommitCmd = updateConfiguration.updateConfigurationCmd() updateMemoryOvercommitCmd.clusterid = clusterlist[0].id updateMemoryOvercommitCmd.name="mem.overprovisioning.factor" if clusterlist[0].memoryovercommitratio == clusterlist[1].memoryovercommitratio and clusterlist[0].memoryovercommitratio == "1.0": memoryovercommit = "1.0" updateMemoryOvercommitCmd.value="2.0" self.apiclient.updateConfiguration(updateMemoryOvercommitCmd) elif clusterlist[0].memoryovercommitratio != clusterlist[1].memoryovercommitratio: memoryovercommit = clusterlist[0].memoryovercommitratio else: memoryovercommit = clusterlist[0].memoryovercommitratio updateMemoryOvercommitCmd.value="1.0" self.apiclient.updateConfiguration(updateMemoryOvercommitCmd) podWithCap = Pod.list(self.apiclient, id=pod.id, showcapacities=True) cpucapacity = Capacities.list(self.apiclient, podid=pod.id, type=1) memorycapacity = Capacities.list(self.apiclient, podid=pod.id, type=0) updateCpuOvercommitCmd.value = cpuovercommit updateMemoryOvercommitCmd.value = memoryovercommit self.apiclient.updateConfiguration(updateCpuOvercommitCmd) self.apiclient.updateConfiguration(updateMemoryOvercommitCmd) self.assertEqual( [cap for cap in podWithCap[0].capacity if cap.type == 1][0].capacitytotal, cpucapacity[0].capacitytotal, "listPods api returns wrong CPU capacity " ) self.assertEqual( [cap for cap in podWithCap[0].capacity if cap.type == 0][0].capacitytotal, memorycapacity[0].capacitytotal, "listPods api returns wrong memory capacity" )
def _addLdapConfiguration(self, ldapConfiguration): """ :param ldapConfiguration """ self.chkConfig = self._checkLdapConfiguration(ldapConfiguration) if not self.chkConfig: return 0 # Setup Global settings updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.basedn" updateConfigurationCmd.value = ldapConfiguration['basedn'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug( "updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.email.attribute" updateConfigurationCmd.value = ldapConfiguration['emailAttribute'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug( "updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.user.object" updateConfigurationCmd.value = ldapConfiguration['userObject'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug( "updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "ldap.username.attribute" updateConfigurationCmd.value = ldapConfiguration['usernameAttribute'] updateConfigurationResponse = self.apiClient.updateConfiguration( updateConfigurationCmd) self.debug( "updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) self.debug("start addLdapConfiguration test") ldapServer = addLdapConfiguration.addLdapConfigurationCmd() ldapServer.hostname = ldapConfiguration['hostname'] ldapServer.port = ldapConfiguration['port'] self.debug("calling addLdapConfiguration API command") try: self.apiClient.addLdapConfiguration(ldapServer) self.debug("addLdapConfiguration was successful") return 1 except Exception as e: self.debug("addLdapConfiguration failed %s Check the Passed passed ldap attributes" % e) self.reason = "addLdapConfiguration failed %s Check the Passed passed ldap attributes" % e return 0
def test_11_ss_nfs_version_on_ssvm(self): """Test NFS Version on Secondary Storage mounted properly on SSVM """ # 1) List SSVM in zone # 2) Get id and url from mounted nfs store # 3) Update NFS version for previous image store # 4) Stop SSVM # 5) Check NFS version of mounted nfs store after SSVM starts nfs_version = self.config.nfsVersion if nfs_version == None: self.skipTest('No NFS version provided in test data') #List SSVM for zone id list_ssvm_response = list_ssvms(self.apiclient, systemvmtype='secondarystoragevm', state='Running', zoneid=self.zone.id) self.assertNotEqual(list_ssvm_response, None) self.assertEqual(isinstance(list_ssvm_response, list), True, "Check list response returns a valid list") self.assertEqual(len(list_ssvm_response), 1, "Check list System VMs response") ssvm = list_ssvm_response[0] image_stores_response = ImageStore.list(self.apiclient, zoneid=self.zone.id) if self.hypervisor.lower() in ('vmware', 'hyperv'): # SSH into SSVMs is done via management server for Vmware and Hyper-V result = get_process_status(self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep 'type nfs'", hypervisor=self.hypervisor) for res in result: split_res = res.split("on") mounted_img_store_url = split_res[0].strip() for img_store in image_stores_response: img_store_url = str(img_store.url) if img_store_url.startswith("nfs://"): img_store_url = img_store_url[6:] #Add colon after ip address to match output from mount command first_slash = img_store_url.find('/') img_store_url = img_store_url[ 0:first_slash] + ':' + img_store_url[first_slash:] if img_store_url == mounted_img_store_url: img_store_id = img_store.id break self.assertNotEqual(img_store_id, None, "Check image store id mounted on SSVM") #Update NFS version for image store mounted on SSVM updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "secstorage.nfs.version" updateConfigurationCmd.value = nfs_version updateConfigurationCmd.imagestoreuuid = img_store_id updateConfigurationResponse = self.apiclient.updateConfiguration( updateConfigurationCmd) self.logger.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) #Stop SSVM self.debug("Stopping SSVM: %s" % ssvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = ssvm.id self.apiclient.stopSystemVm(cmd) def checkForRunningSSVM(): new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id) if isinstance(new_list_ssvm_response, list): return new_list_ssvm_response[0].state == 'Running', None res, _ = wait_until(self.services["sleep"], self.services["timeout"], checkForRunningSSVM) if not res: self.fail("List SSVM call failed!") new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id) self.assertNotEqual(new_list_ssvm_response, None) self.assertEqual(isinstance(new_list_ssvm_response, list), True, "Check list response returns a valid list") ssvm = new_list_ssvm_response[0] self.debug("SSVM state after debug: %s" % ssvm.state) self.assertEqual(ssvm.state, 'Running', "Check whether SSVM is running or not") # Wait for the agent to be up self.waitForSystemVMAgent(ssvm.name) #Check NFS version on mounted image store result = get_process_status(self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep '%s'" % mounted_img_store_url, hypervisor=self.hypervisor) self.assertNotEqual(result, None) self.assertEqual(len(result), 1, "Check result length") res = result[0] mounted_nfs_version = res.split("vers=")[1][0:1] self.assertEqual( int(mounted_nfs_version), int(nfs_version), "Check mounted NFS version to be the same as provided") return
def updateConfiguration(self, name, value): cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value self.apiclient.updateConfiguration(cmd)
def test_11_ss_nfs_version_on_ssvm(self): """Test NFS Version on Secondary Storage mounted properly on SSVM """ # 1) List SSVM in zone # 2) Get id and url from mounted nfs store # 3) Update NFS version for previous image store # 4) Stop SSVM # 5) Check NFS version of mounted nfs store after SSVM starts nfs_version = self.config.nfsVersion if nfs_version == None: self.skipTest('No NFS version provided in test data') #List SSVM for zone id list_ssvm_response = list_ssvms( self.apiclient, systemvmtype='secondarystoragevm', state='Running', zoneid=self.zone.id ) self.assertNotEqual( list_ssvm_response, None ) self.assertEqual( isinstance(list_ssvm_response, list), True, "Check list response returns a valid list" ) self.assertEqual( len(list_ssvm_response), 1, "Check list System VMs response" ) ssvm = list_ssvm_response[0] image_stores_response = ImageStore.list(self.apiclient,zoneid=self.zone.id) if self.hypervisor.lower() in ('vmware', 'hyperv'): # SSH into SSVMs is done via management server for Vmware and Hyper-V result = get_process_status( self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep 'type nfs'", hypervisor=self.hypervisor) for res in result: split_res = res.split("on") mounted_img_store_url = split_res[0].strip() for img_store in image_stores_response: img_store_url = str(img_store.url) if img_store_url.startswith("nfs://"): img_store_url = img_store_url[6:] #Add colon after ip address to match output from mount command first_slash = img_store_url.find('/') img_store_url = img_store_url[0:first_slash] + ':' + img_store_url[first_slash:] if img_store_url == mounted_img_store_url: img_store_id = img_store.id break self.assertNotEqual( img_store_id, None, "Check image store id mounted on SSVM" ) #Update NFS version for image store mounted on SSVM updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "secstorage.nfs.version" updateConfigurationCmd.value = nfs_version updateConfigurationCmd.imagestoreuuid = img_store_id updateConfigurationResponse = self.apiclient.updateConfiguration(updateConfigurationCmd) self.logger.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value)) #Stop SSVM self.debug("Stopping SSVM: %s" % ssvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = ssvm.id self.apiclient.stopSystemVm(cmd) def checkForRunningSSVM(): new_list_ssvm_response = list_ssvms( self.apiclient, id=ssvm.id ) if isinstance(new_list_ssvm_response, list): return new_list_ssvm_response[0].state == 'Running', None res, _ = wait_until(self.services["sleep"], self.services["timeout"], checkForRunningSSVM) if not res: self.fail("List SSVM call failed!") new_list_ssvm_response = list_ssvms( self.apiclient, id=ssvm.id ) self.assertNotEqual( new_list_ssvm_response, None ) self.assertEqual( isinstance(new_list_ssvm_response, list), True, "Check list response returns a valid list" ) ssvm = new_list_ssvm_response[0] self.debug("SSVM state after debug: %s" % ssvm.state) self.assertEqual( ssvm.state, 'Running', "Check whether SSVM is running or not" ) # Wait for the agent to be up self.waitForSystemVMAgent(ssvm.name) #Check NFS version on mounted image store result = get_process_status( self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep '%s'"%mounted_img_store_url, hypervisor=self.hypervisor) self.assertNotEqual( result, None ) self.assertEqual( len(result), 1, "Check result length" ) res = result[0] mounted_nfs_version = res.split("vers=")[1][0:1] self.assertEqual( int(mounted_nfs_version), int(nfs_version), "Check mounted NFS version to be the same as provided" ) return
def test_list_pod_with_overcommit(self): """Test List Pod Api with cluster CPU and Memory OverProvisioning """ podlist = Pod.list(self.apiclient) for pod in podlist: clusterlist = Cluster.list(self.apiclient, podid=pod.id) if len(clusterlist) > 1: updateCpuOvercommitCmd = updateConfiguration.updateConfigurationCmd( ) updateCpuOvercommitCmd.clusterid = clusterlist[0].id updateCpuOvercommitCmd.name = "cpu.overprovisioning.factor" if clusterlist[0].cpuovercommitratio == clusterlist[ 1].cpuovercommitratio and clusterlist[ 0].cpuovercommitratio == "1.0": cpuovercommit = "1.0" updateCpuOvercommitCmd.value = "2.0" self.apiclient.updateConfiguration(updateCpuOvercommitCmd) elif clusterlist[0].cpuovercommitratio != clusterlist[ 1].cpuovercommitratio: cpuovercommit = clusterlist[0].cpuovercommitratio else: cpuovercommit = clusterlist[0].cpuovercommitratio updateCpuOvercommitCmd.value = "1.0" self.apiclient.updateConfiguration(updateCpuOvercommitCmd) updateMemoryOvercommitCmd = updateConfiguration.updateConfigurationCmd( ) updateMemoryOvercommitCmd.clusterid = clusterlist[0].id updateMemoryOvercommitCmd.name = "mem.overprovisioning.factor" if clusterlist[0].memoryovercommitratio == clusterlist[ 1].memoryovercommitratio and clusterlist[ 0].memoryovercommitratio == "1.0": memoryovercommit = "1.0" updateMemoryOvercommitCmd.value = "2.0" self.apiclient.updateConfiguration( updateMemoryOvercommitCmd) elif clusterlist[0].memoryovercommitratio != clusterlist[ 1].memoryovercommitratio: memoryovercommit = clusterlist[0].memoryovercommitratio else: memoryovercommit = clusterlist[0].memoryovercommitratio updateMemoryOvercommitCmd.value = "1.0" self.apiclient.updateConfiguration( updateMemoryOvercommitCmd) podWithCap = Pod.list(self.apiclient, id=pod.id, showcapacities=True) cpucapacity = Capacities.list(self.apiclient, podid=pod.id, type=1) memorycapacity = Capacities.list(self.apiclient, podid=pod.id, type=0) updateCpuOvercommitCmd.value = cpuovercommit updateMemoryOvercommitCmd.value = memoryovercommit self.apiclient.updateConfiguration(updateCpuOvercommitCmd) self.apiclient.updateConfiguration(updateMemoryOvercommitCmd) self.assertEqual([ cap for cap in podWithCap[0].capacity if cap.type == 1 ][0].capacitytotal, cpucapacity[0].capacitytotal, "listPods api returns wrong CPU capacity ") self.assertEqual([ cap for cap in podWithCap[0].capacity if cap.type == 0 ][0].capacitytotal, memorycapacity[0].capacitytotal, "listPods api returns wrong memory capacity")