mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack|network] Add filters to networks, ports and subnets
This commit is contained in:
parent
0c34ca84f5
commit
6a7ea7203c
6 changed files with 48 additions and 18 deletions
|
@ -5,10 +5,19 @@ module Fog
|
|||
module Network
|
||||
class OpenStack
|
||||
class Networks < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Network::OpenStack::Network
|
||||
|
||||
def all
|
||||
load(connection.list_networks.body['networks'])
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
load(connection.list_networks(filters).body['networks'])
|
||||
end
|
||||
|
||||
def get(network_id)
|
||||
|
|
|
@ -5,10 +5,19 @@ module Fog
|
|||
module Network
|
||||
class OpenStack
|
||||
class Ports < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Network::OpenStack::Port
|
||||
|
||||
def all
|
||||
load(connection.list_ports.body['ports'])
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
load(connection.list_ports(filters).body['ports'])
|
||||
end
|
||||
|
||||
def get(port_id)
|
||||
|
|
|
@ -5,10 +5,19 @@ module Fog
|
|||
module Network
|
||||
class OpenStack
|
||||
class Subnets < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Network::OpenStack::Subnet
|
||||
|
||||
def all
|
||||
load(connection.list_subnets.body['subnets'])
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
load(connection.list_subnets(filters).body['subnets'])
|
||||
end
|
||||
|
||||
def get(subnet_id)
|
||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
|||
class OpenStack
|
||||
|
||||
class Real
|
||||
def list_networks
|
||||
def list_networks(filters = {})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'networks'
|
||||
:method => 'GET',
|
||||
:path => 'networks',
|
||||
:query => filters
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_networks
|
||||
def list_networks(filters = {})
|
||||
Excon::Response.new(
|
||||
:body => { 'networks' => self.data[:networks].values },
|
||||
:status => 200
|
||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
|||
class OpenStack
|
||||
|
||||
class Real
|
||||
def list_ports
|
||||
def list_ports(filters = {})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'ports'
|
||||
:method => 'GET',
|
||||
:path => 'ports',
|
||||
:query => filters
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_ports
|
||||
def list_ports(filters = {})
|
||||
Excon::Response.new(
|
||||
:body => { 'ports' => self.data[:ports].values },
|
||||
:status => 200
|
||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
|||
class OpenStack
|
||||
|
||||
class Real
|
||||
def list_subnets
|
||||
def list_subnets(filters = {})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'subnets'
|
||||
:method => 'GET',
|
||||
:path => 'subnets',
|
||||
:query => filters
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_subnets
|
||||
def list_subnets(filters = {})
|
||||
Excon::Response.new(
|
||||
:body => { 'subnets' => self.data[:subnets].values },
|
||||
:status => 200
|
||||
|
|
Loading…
Add table
Reference in a new issue