def attach_planned_volume(mapping)
      # preserve the initial list of disks/volumes before attachment for comparison later.
      vm = RightScale::Platform.volume_manager
      InstanceState.planned_volume_state.disks ||= vm.disks
      InstanceState.planned_volume_state.volumes ||= vm.volumes

      # attach.
      payload = {:agent_identity => @agent_identity, :volume_id => mapping[:volume_id], :device_name => mapping[:device_name]}
      Log.info("Attaching volume #{mapping[:volume_id]}.")
      req = RetryableRequest.new("/storage_valet/attach_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] = 'attached'
        mapping[:attempts] = nil
        yield if block_given?
      end

      req.errback do |res|
        # volume could already be attaching 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 attach 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 attaching volume #{mapping[:volume_id]} with error: #{res}")
        else
          yield if block_given?
        end
      end

      req.run
    end
def attach_planned_volume(mapping)
      # preserve the initial list of disks/volumes before attachment for comparison later.
      vm = RightScale::Platform.volume_manager
      InstanceState.planned_volume_state.disks ||= vm.disks
      InstanceState.planned_volume_state.volumes ||= vm.volumes

      # attach.
      payload = {:agent_identity => @agent_identity, :volume_id => mapping[:volume_id], :device_name => mapping[:device_name]}
      Log.info("Attaching volume #{mapping[:volume_id]}.")
      req = RetryableRequest.new("/storage_valet/attach_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] = 'attached'
        mapping[:attempts] = nil
        yield if block_given?
      end

      req.errback do |res|
        # volume could already be attaching 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 attach 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 attaching volume #{mapping[:volume_id]} with error: #{res}")
        else
          yield if block_given?
        end
      end

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

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