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

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

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(new_attributes = {}) ⇒ Attachment

Returns a new instance of Attachment.



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

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:



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

attribute :device

#server_idString (readonly)

Returns The server id.

Returns:



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

attribute :server_id, :aliases => 'serverId'

#volume_idString (readonly)

Returns The volume id.

Returns:



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

attribute :volume_id, :aliases => 'volumeId'

Instance Method Details

#destroyBoolean Also known as: detach

Detaches volume from server

Returns:

  • (Boolean)

    true if volume is detaching

See Also:



40
41
42
43
44
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 40

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

See Also:



30
31
32
33
34
35
# File 'lib/fog/rackspace/models/compute_v2/attachment.rb', line 30

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