Class: Fog::Compute::RackspaceV2::Attachment

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/compute_v2/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Attachment

Returns a new instance of Attachment.



19
20
21
22
23
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 19

def initialize(new_attributes = {})
  super(new_attributes)
  server_id = server.id if server #server id should come from collection
  self
end

Instance Attribute Details

#deviceString (readonly)

Returns device name of the device /dev/xvd.

Returns:

  • (String)

    device name of the device /dev/xvd



17
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 17

attribute :device

#server_idString (readonly)

Returns The server id.

Returns:

  • (String)

    The server id



9
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 9

attribute :server_id, :aliases => 'serverId'

#volume_idString (readonly)

Returns The volume id.

Returns:

  • (String)

    The volume id



13
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 13

attribute :volume_id, :aliases => 'volumeId'

Instance Method Details

#destroyBoolean Also known as: detach

Detaches volume from server

Returns:

  • (Boolean)

    true if volume is detaching

Raises:

See Also:



47
48
49
50
51
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 47

def destroy
  requires :server_id, :volume_id
  service.delete_attachment(server_id, volume_id)
  true
end

#saveBoolean

Attaches volume to volume to server. Requires :server_id, :volume_id, and device to be populated

Returns:

  • (Boolean)

    true if volume is attaching

Raises:

See Also:



33
34
35
36
37
38
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 33

def save
  requires :server_id, :volume_id, :device
  data = service.attach_volume(server_id, volume_id, device)
  merge_attributes(data.body['volumeAttachment'])
  true
end