2012-09-20 18:24:19 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/network/port'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Network
|
|
|
|
class OpenStack
|
|
|
|
class Ports < Fog::Collection
|
2012-09-21 19:17:46 -04:00
|
|
|
|
|
|
|
attribute :filters
|
|
|
|
|
2012-09-20 18:24:19 -04:00
|
|
|
model Fog::Network::OpenStack::Port
|
|
|
|
|
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_ports(filters).body['ports'])
|
2012-09-20 18:24:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(port_id)
|
2012-12-22 18:24:36 -05:00
|
|
|
if port = service.get_port(port_id).body['port']
|
2012-09-20 18:24:19 -04:00
|
|
|
new(port)
|
|
|
|
end
|
|
|
|
rescue Fog::Network::OpenStack::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-22 18:24:36 -05:00
|
|
|
end
|