2012-08-28 18:10:47 -03:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/rackspace/models/compute_v2/attachment'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
|
|
|
class Attachments < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::RackspaceV2::Attachment
|
|
|
|
|
|
|
|
attr_accessor :server
|
|
|
|
|
2013-01-30 09:05:10 -06:00
|
|
|
# Retrieves attachments belonging to server
|
|
|
|
# @return [Array<Fog::Compute::RackspaceV2::Attachment>] list of attachments
|
|
|
|
# @see Server#attachments
|
2012-08-28 18:10:47 -03:00
|
|
|
def all
|
2012-12-22 23:24:03 +00:00
|
|
|
data = service.list_attachments(server.id).body['volumeAttachments']
|
2012-08-28 18:10:47 -03:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2013-01-30 09:05:10 -06:00
|
|
|
# Retrieves attachment belonging to server
|
|
|
|
# @param [String] volume_id
|
|
|
|
# @return [Fog::Compute::RackspaceV2::Attachment] attachment for volume id
|
2012-08-28 18:10:47 -03:00
|
|
|
def get(volume_id)
|
2012-12-22 23:24:03 +00:00
|
|
|
data = service.get_attachment(server.id, volume_id).body['volumeAttachment']
|
2012-08-28 18:10:47 -03:00
|
|
|
data && new(data)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|