def test_detach_iscsi_disk_from_vm(self): self._create_vm() connection_info = self._test_vmdk_connection_info("iscsi") connection_info["data"]["target_portal"] = "fake_target_portal" connection_info["data"]["target_iqn"] = "fake_target_iqn" mount_point = "/dev/vdc" find = ("fake_name", "fake_uuid") self.mox.StubOutWithMock(volume_util, "find_st") volume_util.find_st(mox.IgnoreArg(), connection_info["data"], mox.IgnoreArg()).AndReturn(find) self.mox.StubOutWithMock(vm_util, "get_rdm_disk") device = "fake_device" vm_util.get_rdm_disk(mox.IgnoreArg(), "fake_uuid").AndReturn(device) self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "detach_disk_from_vm") volumeops.VMwareVolumeOps.detach_disk_from_vm(mox.IgnoreArg(), self.instance, device) self.mox.ReplayAll() self.conn.detach_volume(connection_info, self.instance, mount_point)
def _detach_volume_iscsi(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref(self._session, instance) # Detach Volume from VM LOG.debug("Detach_volume: %(instance_name)s, %(mountpoint)s", {'mountpoint': mountpoint, 'instance_name': instance_name}, instance=instance) data = connection_info['data'] # Discover iSCSI Target device_name, uuid = self._iscsi_get_target(data) if device_name is None: raise exception.StorageError( reason=_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method(vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise exception.StorageError(reason=_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance, device, destroy_disk=True) LOG.info(_("Mountpoint %(mountpoint)s detached from " "instance %(instance_name)s"), {'mountpoint': mountpoint, 'instance_name': instance_name}, instance=instance)
def detach_volume(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name) if vm_ref is None: raise exception.InstanceNotFound(instance_id=instance_name) # Detach Volume from VM LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s") % locals()) driver_type = connection_info['driver_volume_type'] if driver_type not in ['iscsi']: raise exception.VolumeDriverNotFound(driver_type=driver_type) data = connection_info['data'] # Discover iSCSI Target device_name, uuid = volume_util.find_st(self._session, data, self._cluster) if device_name is None: raise volume_util.StorageError(_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method(vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise volume_util.StorageError(_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance_name, device) LOG.info(_("Mountpoint %(mountpoint)s detached from " "instance %(instance_name)s") % locals())
def _detach_volume_iscsi(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref(self._session, instance) # Detach Volume from VM LOG.debug("Detach_volume: %(instance_name)s, %(mountpoint)s", { 'mountpoint': mountpoint, 'instance_name': instance_name }, instance=instance) data = connection_info['data'] # Discover iSCSI Target device_name, uuid = self._iscsi_get_target(data) if device_name is None: raise exception.StorageError( reason=_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method( vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise exception.StorageError(reason=_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance, device, destroy_disk=True) LOG.info(_("Mountpoint %(mountpoint)s detached from " "instance %(instance_name)s"), { 'mountpoint': mountpoint, 'instance_name': instance_name }, instance=instance)
def test_detach_iscsi_disk_from_vm(self): self._create_vm() connection_info = self._test_vmdk_connection_info('iscsi') connection_info['data']['target_portal'] = 'fake_target_portal' connection_info['data']['target_iqn'] = 'fake_target_iqn' mount_point = '/dev/vdc' find = ('fake_name', 'fake_uuid') self.mox.StubOutWithMock(volume_util, 'find_st') volume_util.find_st(mox.IgnoreArg(), connection_info['data'], mox.IgnoreArg()).AndReturn(find) self.mox.StubOutWithMock(vm_util, 'get_rdm_disk') device = 'fake_device' vm_util.get_rdm_disk(mox.IgnoreArg(), 'fake_uuid').AndReturn(device) self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, 'detach_disk_from_vm') volumeops.VMwareVolumeOps.detach_disk_from_vm(mox.IgnoreArg(), self.instance, device) self.mox.ReplayAll() self.conn.detach_volume(connection_info, self.instance, mount_point)
def _detach_volume_iscsi(self, connection_info, instance): """Detach volume storage to VM instance.""" vm_ref = vm_util.get_vm_ref(self._session, instance) # Detach Volume from VM LOG.debug("_detach_volume_iscsi: %s", connection_info, instance=instance) data = connection_info["data"] # Discover iSCSI Target device_name, uuid = self._iscsi_get_target(data) if device_name is None: raise exception.StorageError(reason=_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method(vutil, "get_object_property", vm_ref, "config.hardware.device") device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise exception.DiskNotFound(message=_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance, device, destroy_disk=True) LOG.debug("Detached ISCSI: %s", connection_info, instance=instance)
def _detach_volume_iscsi(self, connection_info, instance): """Detach volume storage to VM instance.""" vm_ref = vm_util.get_vm_ref(self._session, instance) # Detach Volume from VM LOG.debug("_detach_volume_iscsi: %s", connection_info, instance=instance) data = connection_info['data'] # Discover iSCSI Target device_name, uuid = self._iscsi_get_target(data) if device_name is None: raise exception.StorageError( reason=_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = vm_util.get_hardware_devices(self._session, vm_ref) device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise exception.DiskNotFound(message=_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance, device, destroy_disk=True) LOG.debug("Detached ISCSI: %s", connection_info, instance=instance)
def detach_volume(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name) if vm_ref is None: raise exception.InstanceNotFound(instance_id=instance_name) # Detach Volume from VM LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s"), { 'mountpoint': mountpoint, 'instance_name': instance_name }) driver_type = connection_info['driver_volume_type'] if driver_type not in ['iscsi']: raise exception.VolumeDriverNotFound(driver_type=driver_type) data = connection_info['data'] # Discover iSCSI Target device_name, uuid = volume_util.find_st(self._session, data, self._cluster) if device_name is None: raise volume_util.StorageError(_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method( vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") device = vm_util.get_rdm_disk(hardware_devices, uuid) if device is None: raise volume_util.StorageError(_("Unable to find volume")) self.detach_disk_from_vm(vm_ref, instance_name, device) LOG.info( _("Mountpoint %(mountpoint)s detached from " "instance %(instance_name)s"), { 'mountpoint': mountpoint, 'instance_name': instance_name })