def test_06_migrate_live_remote(self): """ Migrate VMs/Volumes live """ global vm2 volumes = list_volumes(self.apiclient, virtualmachineid = self.virtual_machine_on_remote.id) for v in volumes: vol = sptypes.VolumeUpdateDesc(rename = v.id) name = v.path.split("/")[3] rename = self.spapi.volumeUpdate(volumeName = "~" + name, json = vol) destinationHost = self.getDestinationHost(self.virtual_machine_on_remote.hostid, self.host_remote) # Migrate the VM vm2 = self.migrateVm(self.virtual_machine_on_remote, destinationHost) # self.check_files(vm,destinationHost) """ Migrate the VM and ROOT volume """ # Get all volumes to be migrated destinationHost, vol_list = self.get_destination_pools_hosts(vm2) vm2 = self.migrateVm(self.virtual_machine_on_remote, destinationHost)
def extend_volume(self, volume, new_size): size = int(new_size) * units.Gi name = self._attach.volumeName(volume['id']) try: upd = sptypes.VolumeUpdateDesc(size=size) self._attach.api().volumeUpdate(name, upd) except spapi.ApiError as e: raise self._backendException(e)
def test_11_resize_renamed_volume(self): '''Resize volume which was created with globalid than renamed with uuid''' volume_on_sp_1 = Volume.create( self.apiclient, {"diskname":"StorPoolDisk-3" }, zoneid=self.zone.id, diskofferingid=self.disk_offering.id, ) virtual_machine = VirtualMachine.create( self.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=self.zone.id, templateid=self.template.id, serviceofferingid=self.service_offering.id, hypervisor=self.hypervisor, hostid = self.host_on_local_1.id, rootdisksize=10 ) virtual_machine.attach_volume(self.apiclient, volume_on_sp_1) self.assertEqual(VirtualMachine.RUNNING, virtual_machine.state, "Running") listvol = Volume.list( self.apiclient, virtualmachineid = virtual_machine.id, id= volume_on_sp_1.id ) volume = listvol[0] vol = sptypes.VolumeUpdateDesc(rename = volume.id) name = volume.path.split("/")[3] rename = self.spapi.volumeUpdate(volumeName = "~" + name, json = vol) #resize volume with it's global id self.helper.resizing_volume(volume, globalid=True) volume_with_global_id = self.spapi.volumeList(volumeName = "~" + name) #resize volume that was renamed with uuid self.helper.resizing_volume(volume, globalid=False) volume_with_uuid = self.spapi.volumeList(volumeName = volume.id) self.debug("volume_with_global_id %s" % volume_with_global_id) self.debug("volume_with_uuid %s" % volume_with_uuid) self.assertEqual(volume_with_global_id[0].name, volume_with_uuid[0].name, "Are not the same") cmd = destroyVirtualMachine.destroyVirtualMachineCmd() cmd.id = virtual_machine.id cmd.expunge = True self.apiclient.destroyVirtualMachine(cmd) volume_on_sp_1.delete(self.apiclient)
def retype(self, context, volume, new_type, diff, host): update = {} if diff['encryption']: LOG.error('Retype of encryption type not supported.') return False templ = self.configuration.storpool_template repl = self.configuration.storpool_replication if diff['extra_specs']: for (k, v) in diff['extra_specs'].items(): if k == 'volume_backend_name': if v[0] != v[1]: # Retype of a volume backend not supported yet, # the volume needs to be migrated. return False elif k == 'storpool_template': if v[0] != v[1]: if v[1] is not None: update['template'] = v[1] elif templ is not None: update['template'] = templ else: update['replication'] = repl elif v[0] != v[1]: LOG.error( 'Retype of extra_specs "%s" not ' 'supported yet.', k) return False if update: name = self._attach.volumeName(volume['id']) try: upd = sptypes.VolumeUpdateDesc(**update) self._attach.api().volumeUpdate(name, upd) except spapi.ApiError as e: raise self._backendException(e) return True
def test_02_migrate_vm_live_attach_disk(self): """ Add a data disk and migrate vm, data disk and root disk """ global vm global data_disk_1 data_disk_1 = Volume.create( self.apiclient, {"diskname":"StorPoolDisk-4" }, zoneid=self.zone.id, diskofferingid=self.disk_offering.id, ) self.debug("Created volume with ID: %s" % data_disk_1.id) self.virtual_machine.attach_volume( self.apiclient, data_disk_1 ) volumes = list_volumes(self.apiclient, id = data_disk_1.id) vol = sptypes.VolumeUpdateDesc(rename = volumes[0].id) name = volumes[0].path.split("/")[3] rename = self.spapi.volumeUpdate(volumeName = "~" + name, json = vol) destinationHost, vol_list = self.get_destination_pools_hosts(vm) vm = self.migrateVm(self.virtual_machine, destinationHost) self.virtual_machine.attach_volume( self.apiclient, self.volume ) destinationHost, vol_list = self.get_destination_pools_hosts(vm) vm = self.migrateVm(self.virtual_machine, destinationHost)