def setUpClass(cls): testClient = super(TestDeployvGPUenabledVM, cls).getClsTestClient() #Need to add check whether zone containing the xen hypervisor or not as well hypervisor = testClient.getHypervisorInfo() if hypervisor.lower() != XEN_SERVER.lower(): raise unittest.skipTest( "GPU feature is supported only on XenServer")
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 test_01_create_volume(self): """Test Volume creation for all Disk Offerings (incl. custom) """ # Validate the following # 1. Create volumes from the different sizes # 2. Verify the size of volume with actual size allocated self.volumes = [] for k, v in self.services["volume_offerings"].items(): volume = Volume.create( self.apiClient, v, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created a volume with ID: %s" % volume.id) self.volumes.append(volume) if self.virtual_machine.hypervisor == "KVM": sparse_volume = Volume.create( self.apiClient, self.services, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, diskofferingid=self.sparse_disk_offering.id ) self.debug("Created a sparse volume: %s" % sparse_volume.id) self.volumes.append(sparse_volume) volume = Volume.create_custom_disk( self.apiClient, self.services, account=self.account.name, domainid=self.account.domainid, ) self.debug("Created a volume with custom offering: %s" % volume.id) self.volumes.append(volume) #Attach a volume with different disk offerings #and check the memory allocated to each of them for volume in self.volumes: list_volume_response = Volume.list( self.apiClient, id=volume.id) self.assertEqual( isinstance(list_volume_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( list_volume_response, None, "Check if volume exists in ListVolumes" ) self.debug( "Attaching volume (ID: %s) to VM (ID: %s)" % ( volume.id, self.virtual_machine.id )) self.virtual_machine.attach_volume( self.apiClient, volume ) try: ssh = self.virtual_machine.get_ssh_client() self.debug("Rebooting VM %s" % self.virtual_machine.id) ssh.execute("reboot") except Exception as e: self.fail("SSH access failed for VM %s - %s" % (self.virtual_machine.ipaddress, e)) # Poll listVM to ensure VM is started properly timeout = self.services["timeout"] while True: time.sleep(self.services["sleep"]) # Ensure that VM is in running state list_vm_response = VirtualMachine.list( self.apiClient, id=self.virtual_machine.id ) if isinstance(list_vm_response, list): vm = list_vm_response[0] if vm.state == 'Running': self.debug("VM state: %s" % vm.state) break if timeout == 0: raise Exception( "Failed to start VM (ID: %s) " % vm.id) timeout = timeout - 1 vol_sz = str(list_volume_response[0].size) ssh = self.virtual_machine.get_ssh_client( reconnect=True ) # Get the updated volume information list_volume_response = Volume.list( self.apiClient, id=volume.id) if list_volume_response[0].hypervisor.lower() == XEN_SERVER.lower(): volume_name = "/dev/xvd" + chr(ord('a') + int(list_volume_response[0].deviceid)) self.debug(" Using XenServer volume_name: %s" % (volume_name)) ret = checkVolumeSize(ssh_handle=ssh,volume_name=volume_name,size_to_verify=vol_sz) else: ret = checkVolumeSize(ssh_handle=ssh,size_to_verify=vol_sz) self.debug(" Volume Size Expected %s Actual :%s" %(vol_sz,ret[1])) self.virtual_machine.detach_volume(self.apiClient, volume) self.assertEqual(ret[0],SUCCESS,"Check if promised disk size actually available") time.sleep(self.services["sleep"])
def test_01_create_volume(self): """Test Volume creation for all Disk Offerings (incl. custom) """ # Validate the following # 1. Create volumes from the different sizes # 2. Verify the size of volume with actual size allocated self.volumes = [] for k, v in self.services["volume_offerings"].items(): volume = Volume.create(self.apiClient, v, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, diskofferingid=self.disk_offering.id) self.debug("Created a volume with ID: %s" % volume.id) self.volumes.append(volume) if self.virtual_machine.hypervisor == "KVM": sparse_volume = Volume.create( self.apiClient, self.services, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, diskofferingid=self.sparse_disk_offering.id) self.debug("Created a sparse volume: %s" % sparse_volume.id) self.volumes.append(sparse_volume) volume = Volume.create_custom_disk( self.apiClient, self.services, account=self.account.name, domainid=self.account.domainid, ) self.debug("Created a volume with custom offering: %s" % volume.id) self.volumes.append(volume) # Attach a volume with different disk offerings # and check the memory allocated to each of them for volume in self.volumes: list_volume_response = Volume.list(self.apiClient, id=volume.id) self.assertEqual(isinstance(list_volume_response, list), True, "Check list response returns a valid list") self.assertNotEqual(list_volume_response, None, "Check if volume exists in ListVolumes") self.debug("Attaching volume (ID: %s) to VM (ID: %s)" % (volume.id, self.virtual_machine.id)) self.virtual_machine.attach_volume(self.apiClient, volume) try: ssh = self.virtual_machine.get_ssh_client() self.debug("Rebooting VM %s" % self.virtual_machine.id) ssh.execute("reboot") except Exception as e: self.fail("SSH access failed for VM %s - %s" % (self.virtual_machine.ipaddress, e)) # Poll listVM to ensure VM is started properly timeout = self.services["timeout"] while True: time.sleep(self.services["sleep"]) # Ensure that VM is in running state list_vm_response = VirtualMachine.list( self.apiClient, id=self.virtual_machine.id) if isinstance(list_vm_response, list): vm = list_vm_response[0] if vm.state == 'Running': self.debug("VM state: %s" % vm.state) break if timeout == 0: raise Exception("Failed to start VM (ID: %s) " % vm.id) timeout = timeout - 1 vol_sz = str(list_volume_response[0].size) ssh = self.virtual_machine.get_ssh_client(reconnect=True) # Get the updated volume information list_volume_response = Volume.list(self.apiClient, id=volume.id) if list_volume_response[0].hypervisor.lower() == XEN_SERVER.lower( ): volume_name = "/dev/xvd" + chr( ord('a') + int(list_volume_response[0].deviceid)) self.debug(" Using XenServer volume_name: %s" % (volume_name)) ret = checkVolumeSize(ssh_handle=ssh, volume_name=volume_name, size_to_verify=vol_sz) elif list_volume_response[0].hypervisor.lower() == "kvm": volume_name = "/dev/vd" + chr( ord('a') + int(list_volume_response[0].deviceid)) self.debug(" Using KVM volume_name: %s" % (volume_name)) ret = checkVolumeSize(ssh_handle=ssh, volume_name=volume_name, size_to_verify=vol_sz) else: ret = checkVolumeSize(ssh_handle=ssh, size_to_verify=vol_sz) self.debug(" Volume Size Expected %s Actual :%s" % (vol_sz, ret[1])) self.virtual_machine.detach_volume(self.apiClient, volume) self.assertEqual(ret[0], SUCCESS, "Check if promised disk size actually available") time.sleep(self.services["sleep"])
def setUpClass(cls): testClient = super(TestDeployvGPUenabledVM, cls).getClsTestClient() #Need to add check whether zone containing the xen hypervisor or not as well hypervisor = testClient.getHypervisorInfo() if hypervisor.lower() != XEN_SERVER.lower(): raise unittest.skipTest("GPU feature is supported only on XenServer")