def detach_volume(self, connection_info, instance_name, mountpoint): """Detach volume storage to VM instance.""" LOG.debug("Detach_volume: %(instance_name)s, %(mountpoint)s", { 'instance_name': instance_name, 'mountpoint': mountpoint }) vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name) device_number = volume_utils.get_device_number(mountpoint) vbd_ref = volume_utils.find_vbd_by_number(self._session, vm_ref, device_number) if vbd_ref is None: # NOTE(sirp): If we don't find the VBD then it must have been # detached previously. LOG.warning( _LW('Skipping detach because VBD for %s was ' 'not found'), instance_name) else: self._detach_vbds_and_srs(vm_ref, [vbd_ref]) LOG.info( _LI('Mountpoint %(mountpoint)s detached from instance' ' %(instance_name)s'), { 'instance_name': instance_name, 'mountpoint': mountpoint })
def attach_volume(self, connection_info, instance_name, mountpoint, hotplug=True): """Attach volume to VM instance.""" # TODO(johngarbutt) move this into _attach_volume_to_vm dev_number = volume_utils.get_device_number(mountpoint) vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name) return self._attach_volume(connection_info, vm_ref, instance_name, dev_number, hotplug)
def detach_volume(self, connection_info, instance_name, mountpoint): """Detach volume storage to VM instance.""" LOG.debug("Detach_volume: %(instance_name)s, %(mountpoint)s", {'instance_name': instance_name, 'mountpoint': mountpoint}) vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name) device_number = volume_utils.get_device_number(mountpoint) vbd_ref = volume_utils.find_vbd_by_number(self._session, vm_ref, device_number) if vbd_ref is None: # NOTE(sirp): If we don't find the VBD then it must have been # detached previously. LOG.warning(_LW('Skipping detach because VBD for %s was ' 'not found'), instance_name) else: self._detach_vbds_and_srs(vm_ref, [vbd_ref]) LOG.info(_LI('Mountpoint %(mountpoint)s detached from instance' ' %(instance_name)s'), {'instance_name': instance_name, 'mountpoint': mountpoint})