2012-09-20 18:24:19 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/network/subnet'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Network
|
|
|
|
class OpenStack
|
|
|
|
class Subnets < Fog::Collection
|
2012-09-21 19:17:46 -04:00
|
|
|
|
|
|
|
attribute :filters
|
|
|
|
|
2012-09-20 18:24:19 -04:00
|
|
|
model Fog::Network::OpenStack::Subnet
|
|
|
|
|
2012-09-21 19:17:46 -04:00
|
|
|
def initialize(attributes)
|
|
|
|
self.filters ||= {}
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all(filters = filters)
|
|
|
|
self.filters = filters
|
|
|
|
load(connection.list_subnets(filters).body['subnets'])
|
2012-09-20 18:24:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(subnet_id)
|
|
|
|
if subnet = connection.get_subnet(subnet_id).body['subnet']
|
|
|
|
new(subnet)
|
|
|
|
end
|
|
|
|
rescue Fog::Network::OpenStack::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|