2011-03-01 12:00:48 -05:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 20:24:45 -05:00
|
|
|
require 'fog/linode/models/compute/data_center'
|
2011-03-01 12:00:48 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 16:28:54 -07:00
|
|
|
module Compute
|
|
|
|
class Linode
|
2011-03-01 12:00:48 -05:00
|
|
|
class DataCenters < Fog::Collection
|
2011-06-16 16:28:54 -07:00
|
|
|
model Fog::Compute::Linode::DataCenter
|
2011-03-01 12:00:48 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
load datacenters
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def datacenters(id=nil)
|
2011-03-01 16:37:27 -05:00
|
|
|
connection.avail_datacenters.body['DATA'].map { |datacenter| map_datacenter datacenter }
|
2011-03-01 12:00:48 -05:00
|
|
|
end
|
|
|
|
|
2011-03-01 16:37:27 -05:00
|
|
|
def map_datacenter(datacenter)
|
|
|
|
datacenter = datacenter.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
|
|
|
|
datacenter.merge! :id => datacenter[:datacenterid], :name => datacenter[:location]
|
2011-03-01 12:00:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|