'Detach a volume from an instance in shelved offloaded state.
If the instance is shelved offloaded we just need to cleanup volume
calling the volume api detach, the volume api terminate_connection
and delete the bdm record.
If the volume has delete_on_termination option set then we call the
volume api delete as well.'

def _detach_volume_shelved_offloaded(self, context, instance, volume):

    try:
        self.volume_api.begin_detaching(context, volume['id'])
    except exception.InvalidInput as exc:
        raise exception.InvalidVolume(reason=exc.format_message())
    bdms = [objects.BlockDeviceMapping.get_by_volume_id(context, volume['id'], instance.uuid)]
    self._local_cleanup_bdm_volumes(bdms, instance, context)
