2011-08-24 20:29:14 -05:00
|
|
|
require 'fog/ecloud/models/compute/network'
|
2011-02-17 10:44:46 -08:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 16:28:54 -07:00
|
|
|
module Compute
|
|
|
|
class Ecloud
|
2011-02-17 10:44:46 -08:00
|
|
|
class Networks < Fog::Ecloud::Collection
|
|
|
|
|
2012-11-27 16:57:16 -08:00
|
|
|
attribute :href, :aliases => :Href
|
2011-02-17 10:44:46 -08:00
|
|
|
|
2011-06-20 15:00:48 -07:00
|
|
|
model Fog::Compute::Ecloud::Network
|
2011-02-17 10:44:46 -08:00
|
|
|
|
|
|
|
def all
|
2012-12-22 23:27:38 +00:00
|
|
|
body = service.get_networks(self.href).body
|
2012-11-27 16:57:16 -08:00
|
|
|
body = body[:Networks] ? body[:Networks][:Network] : body[:Network]
|
|
|
|
data = case body
|
|
|
|
when NilClass then []
|
|
|
|
when Array then body
|
|
|
|
when Hash then [body]
|
|
|
|
end
|
2012-06-07 12:50:11 -04:00
|
|
|
load(data)
|
2011-02-17 10:44:46 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-12-22 23:27:38 +00:00
|
|
|
if data = service.get_network(uri)
|
2011-02-17 10:44:46 -08:00
|
|
|
new(data.body)
|
|
|
|
end
|
2012-06-07 12:50:11 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
2011-02-17 10:44:46 -08:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|