def _detach_volume(instance, volume_id): volume = cinder.get_volume(volume_id) try: LOG.debug("Detaching volume %s from instance %s" % ( volume_id, instance.instance_name)) nova.client().volumes.delete_server_volume(instance.instance_id, volume_id) except Exception: LOG.exception(_LE("Can't detach volume %s"), volume.id) detach_timeout = CONF.detach_volume_timeout LOG.debug("Waiting %d seconds to detach %s volume" % (detach_timeout, volume_id)) s_time = tu.utcnow() while tu.delta_seconds(s_time, tu.utcnow()) < detach_timeout: volume = cinder.get_volume(volume_id) if volume.status not in ['available', 'error']: context.sleep(2) else: LOG.debug("Volume %s has been detached" % volume_id) return else: LOG.warn(_LW("Can't detach volume %(volume)s. " "Current status of volume: %(status)s"), {'volume': volume_id, 'status': volume.status})
def _detach_volume(instance, volume_id): volume = cinder.get_volume(volume_id) try: LOG.debug("Detaching volume %s from instance %s" % (volume_id, instance.instance_name)) nova.client().volumes.delete_server_volume(instance.instance_id, volume_id) except Exception: LOG.exception(_LE("Can't detach volume %s"), volume.id) detach_timeout = CONF.detach_volume_timeout LOG.debug("Waiting %d seconds to detach %s volume" % (detach_timeout, volume_id)) s_time = tu.utcnow() while tu.delta_seconds(s_time, tu.utcnow()) < detach_timeout: volume = cinder.get_volume(volume_id) if volume.status not in ['available', 'error']: context.sleep(2) else: LOG.debug("Volume %s has been detached" % volume_id) return else: LOG.warn( _LW("Can't detach volume %(volume)s. " "Current status of volume: %(status)s"), { 'volume': volume_id, 'status': volume.status })
def _delete_volume(volume_id): LOG.debug("Deleting volume {volume}".format(volume=volume_id)) volume = cinder.get_volume(volume_id) try: volume.delete() except Exception: LOG.error(_LE("Can't delete volume {volume}").format(volume=volume.id))
def _delete_volume(volume_id): LOG.debug("Deleting volume {volume}".format(volume=volume_id)) volume = cinder.get_volume(volume_id) try: b.execute_with_retries(volume.delete) except Exception: LOG.error(_LE("Can't delete volume {volume}").format(volume=volume.id))
def _delete_volume(volume_id): LOG.debug("Deleting volume {volume}".format(volume=volume_id)) volume = cinder.get_volume(volume_id) try: b.execute_with_retries(volume.delete) except Exception: LOG.error("Can't delete volume {volume}".format(volume=volume.id))
def _delete_volume(volume_id): LOG.debug("Deleting volume %s" % volume_id) volume = cinder.get_volume(volume_id) try: volume.delete() except Exception: LOG.exception("Can't delete volume %s" % volume.id)
def _create_attach_volume(ctx, instance, size, volume_type, name=None, availability_zone=None): if CONF.cinder.api_version == 1: kwargs = {'size': size, 'display_name': name} else: kwargs = {'size': size, 'name': name} kwargs['volume_type'] = volume_type if availability_zone is not None: kwargs['availability_zone'] = availability_zone volume = cinder.client().volumes.create(**kwargs) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise ex.SystemError(_("Volume %s has error status") % volume.id) context.sleep(1) resp = nova.client().volumes.create_server_volume(instance.instance_id, volume.id, None) return resp.device
def _delete_volume(volume_id): LOG.debug("Deleting volume %s" % volume_id) volume = cinder.get_volume(volume_id) try: volume.delete() except Exception: LOG.exception(_LE("Can't delete volume %s"), volume.id)
def _delete_volume(volume_id): LOG.debug("Deleting volume {volume}".format(volume=volume_id)) volume = cinder.get_volume(volume_id) try: volume.delete() except Exception: LOG.error(_LE("Can't delete volume {volume}").format( volume=volume.id))
def detach_from_instance(instance): for volume_id in instance.volumes: volume = cinder.get_volume(volume_id) try: volume.detach() volume.delete() except Exception: LOG.error("Can't detach volume %s" % volume.id) raise
def _detach_volume(instance, volume_id): volume = cinder.get_volume(volume_id) try: LOG.debug("Detaching volume {id} from instance".format(id=volume_id)) b.execute_with_retries(nova.client().volumes.delete_server_volume, instance.instance_id, volume_id) except Exception: LOG.error(_LE("Can't detach volume {id}").format(id=volume.id)) detach_timeout = CONF.timeouts.detach_volume_timeout LOG.debug("Waiting {timeout} seconds to detach {id} volume".format(timeout=detach_timeout, id=volume_id)) _await_detach(volume_id)
def _detach_volume(instance, volume_id): volume = cinder.get_volume(volume_id) try: LOG.debug("Detaching volume {id} from instance".format(id=volume_id)) b.execute_with_retries(nova.client().volumes.delete_server_volume, instance.instance_id, volume_id) except Exception: LOG.error(_LE("Can't detach volume {id}").format(id=volume.id)) detach_timeout = CONF.timeouts.detach_volume_timeout LOG.debug("Waiting {timeout} seconds to detach {id} volume".format( timeout=detach_timeout, id=volume_id)) _await_detach(volume_id)
def _create_attach_volume(ctx, instance, size, display_name=None): volume = cinder.client().volumes.create(size=size, display_name=display_name) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise ex.SystemError("Volume %s has error status" % volume.id) context.sleep(1) resp = nova.client().volumes.create_server_volume( instance.instance_id, volume.id, None) return resp.device
def _create_attach_volume(ctx, instance, size, display_name=None): volume = cinder.client().volumes.create(size=size, display_name=display_name) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise ex.SystemError(_("Volume %s has error status") % volume.id) context.sleep(1) resp = nova.client().volumes.create_server_volume(instance.instance_id, volume.id, None) return resp.device
def _create_attach_volume(ctx, instance, size, display_name=None, volume_type=None): volume = cinder.client().volumes.create(size=size, display_name=display_name, volume_type=volume_type, lvm_instance_id=instance.instance_id) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise RuntimeError("Volume %s has error status" % volume.id) context.sleep(1) nova.client().volumes.create_server_volume(instance.instance_id, volume.id, None)
def _create_attach_volume(ctx, instance, size, display_name=None, volume_type=None): volume = cinder.client().volumes.create(size=size, display_name=display_name, volume_type=volume_type) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise RuntimeError("Volume %s has error status" % volume.id) context.sleep(1) nova.client().volumes.create_server_volume(instance.instance_id, volume.id, None)
def _create_attach_volume(ctx, instance, size, volume_type, name=None, availability_zone=None): if CONF.cinder_api_version == 1: kwargs = {'size': size, 'display_name': name} else: kwargs = {'size': size, 'name': name} kwargs['volume_type'] = volume_type if availability_zone is not None: kwargs['availability_zone'] = availability_zone volume = cinder.client().volumes.create(**kwargs) conductor.append_volume(ctx, instance, volume.id) while volume.status != 'available': volume = cinder.get_volume(volume.id) if volume.status == 'error': raise ex.SystemError(_("Volume %s has error status") % volume.id) context.sleep(1) resp = nova.client().volumes.create_server_volume( instance.instance_id, volume.id, None) return resp.device
def _await_detach(volume_id): volume = cinder.get_volume(volume_id) if volume.status not in ['available', 'error']: return False return True
def _await_available(volume): volume = cinder.get_volume(volume.id) if volume.status == 'error': raise ex.SystemError(_("Volume %s has error status") % volume.id) return volume.status == 'available'