2011-08-24 21:29:14 -04:00
|
|
|
require 'fog/ecloud/models/compute/network'
|
2011-02-17 13:44:46 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Ecloud
|
2011-02-17 13:44:46 -05:00
|
|
|
class Networks < Fog::Ecloud::Collection
|
|
|
|
|
2012-11-27 19:57:16 -05:00
|
|
|
attribute :href, :aliases => :Href
|
2011-02-17 13:44:46 -05:00
|
|
|
|
2011-06-20 18:00:48 -04:00
|
|
|
model Fog::Compute::Ecloud::Network
|
2011-02-17 13:44:46 -05:00
|
|
|
|
|
|
|
def all
|
2012-12-22 18:27:38 -05:00
|
|
|
body = service.get_networks(self.href).body
|
2012-11-27 19:57:16 -05: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 13:44:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-12-22 18:27:38 -05:00
|
|
|
if data = service.get_network(uri)
|
2011-02-17 13:44:46 -05:00
|
|
|
new(data.body)
|
|
|
|
end
|
2012-06-07 12:50:11 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
2011-02-17 13:44:46 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|