2012-05-16 14:12:08 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/cloudstack/models/compute/zone'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Cloudstack
|
|
|
|
|
|
|
|
class Zones < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::Cloudstack::Zone
|
|
|
|
|
|
|
|
def all(filters={})
|
|
|
|
options = {
|
|
|
|
'templatefilter' => 'self'
|
|
|
|
}.merge(filters)
|
|
|
|
|
2012-12-22 18:28:53 -05:00
|
|
|
data = service.list_zones(options)["listzonesresponse"]["zone"] || []
|
2012-05-16 14:12:08 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(zone_id)
|
2012-12-22 18:28:53 -05:00
|
|
|
if zone = service.list_zones('id' => zone_id)["listzonesresponse"]["zone"].first
|
2012-05-16 14:12:08 -04:00
|
|
|
new(zone)
|
|
|
|
end
|
|
|
|
rescue Fog::Compute::Cloudstack::BadRequest
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|