def detach_planned_volume(mapping)
      payload = {:agent_identity => @agent_identity, :device_name => mapping[:device_name]}
      Log.info("Detaching volume #{mapping[:volume_id]} for management purposes.")
      req = RetryableRequest.new("/storage_valet/detach_volume", payload, :retry_delay => VolumeManagement::VOLUME_RETRY_SECONDS)

      req.callback do |res|
        # don't set :volume_status here as that should only be queried
        mapping[:management_status] = 'detached'
        mapping[:attempts] = nil
        yield if block_given?
      end

      req.errback do |res|
        unless InstanceState.value == 'stranded'
          # volume could already be detaching or have been deleted
          # which we can't see because of latency; go around again
          # and check state of volume later.
          Log.error("Failed to detach volume #{mapping[:volume_id]} (#{res})")
          mapping[:attempts] ||= 0
          mapping[:attempts] += 1
          # retry indefinitely so long as core api instructs us to retry or else fail after max attempts.
          if mapping[:attempts] >= VolumeManagement::MAX_VOLUME_ATTEMPTS
            strand("Exceeded maximum of #{VolumeManagement::MAX_VOLUME_ATTEMPTS} attempts detaching volume #{mapping[:volume_id]} with error: #{res}")
          else
            yield if block_given?
          end
        end
      end

      req.run
    end
def detach_planned_volume(mapping)
      payload = {:agent_identity => @agent_identity, :device_name => mapping[:device_name]}
      Log.info("Detaching volume #{mapping[:volume_id]} for management purposes.")
      req = RetryableRequest.new("/storage_valet/detach_volume", payload, :retry_delay => VolumeManagement::VOLUME_RETRY_SECONDS)

      req.callback do |res|
        # don't set :volume_status here as that should only be queried
        mapping[:management_status] = 'detached'
        mapping[:attempts] = nil
        yield if block_given?
      end

      req.errback do |res|
        unless InstanceState.value == 'stranded'
          # volume could already be detaching or have been deleted
          # which we can't see because of latency; go around again
          # and check state of volume later.
          Log.error("Failed to detach volume #{mapping[:volume_id]} (#{res})")
          mapping[:attempts] ||= 0
          mapping[:attempts] += 1
          # retry indefinitely so long as core api instructs us to retry or else fail after max attempts.
          if mapping[:attempts] >= VolumeManagement::MAX_VOLUME_ATTEMPTS
            strand("Exceeded maximum of #{VolumeManagement::MAX_VOLUME_ATTEMPTS} attempts detaching volume #{mapping[:volume_id]} with error: #{res}")
          else
            yield if block_given?
          end
        end
      end

      req.run
    end
Detaches the planned volume given by its mapping.

 === Parameters
 mapping(Hash):: details of planned volume