2012-05-16 14:12:08 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/cloudstack/models/compute/flavor'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Cloudstack
|
|
|
|
|
|
|
|
class Flavors < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::Cloudstack::Flavor
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:28:53 -05:00
|
|
|
data = service.list_service_offerings["listserviceofferingsresponse"]["serviceoffering"] || []
|
2012-05-16 14:12:08 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(flavor_id)
|
2012-12-22 18:28:53 -05:00
|
|
|
if flavor = service.list_service_offerings('id' => flavor_id)["listserviceofferingsresponse"]["serviceoffering"].first
|
2012-05-16 14:12:08 -04:00
|
|
|
new(flavor)
|
|
|
|
end
|
|
|
|
rescue Fog::Compute::Cloudstack::BadRequest
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|