2012-05-22 19:47:53 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/cloudstack/models/compute/volume'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Cloudstack
|
|
|
|
class Volumes < Fog::Collection
|
|
|
|
model Fog::Compute::Cloudstack::Volume
|
|
|
|
|
2014-11-08 12:03:54 -05:00
|
|
|
def all(attributes = {})
|
|
|
|
response = service.list_volumes(attributes)
|
|
|
|
data = response["listvolumesresponse"]["volume"] || []
|
2012-05-22 19:47:53 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(volume_id)
|
2012-12-22 18:28:53 -05:00
|
|
|
if volume = service.list_volumes('id' => volume_id)["listvolumesresponse"]["volume"].first
|
2012-05-22 19:47:53 -04:00
|
|
|
new(volume)
|
|
|
|
end
|
|
|
|
rescue Fog::Compute::Cloudstack::BadRequest
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|