2012-09-20 18:24:19 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/network/network'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Network
|
|
|
|
class OpenStack
|
|
|
|
class Networks < Fog::Collection
|
2012-09-21 19:17:46 -04:00
|
|
|
|
|
|
|
attribute :filters
|
|
|
|
|
2012-09-20 18:24:19 -04:00
|
|
|
model Fog::Network::OpenStack::Network
|
|
|
|
|
2012-09-21 19:17:46 -04:00
|
|
|
def initialize(attributes)
|
|
|
|
self.filters ||= {}
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all(filters = filters)
|
|
|
|
self.filters = filters
|
2012-12-22 18:24:36 -05:00
|
|
|
load(service.list_networks(filters).body['networks'])
|
2012-09-20 18:24:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(network_id)
|
2012-12-22 18:24:36 -05:00
|
|
|
if network = service.get_network(network_id).body['network']
|
2012-09-20 18:24:19 -04:00
|
|
|
new(network)
|
|
|
|
end
|
|
|
|
rescue Fog::Network::OpenStack::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-22 18:24:36 -05:00
|
|
|
end
|