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
|
module Network
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Networks < Fog::Collection
|
class Networks < Fog::Collection
|
||||||
|
|
||||||
|
attribute :filters
|
||||||
|
|
||||||
model Fog::Network::OpenStack::Network
|
model Fog::Network::OpenStack::Network
|
||||||
|
|
||||||
def all
|
def initialize(attributes)
|
||||||
load(connection.list_networks.body['networks'])
|
self.filters ||= {}
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def all(filters = filters)
|
||||||
|
self.filters = filters
|
||||||
|
load(connection.list_networks(filters).body['networks'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(network_id)
|
def get(network_id)
|
||||||
|
|
|
@ -5,10 +5,19 @@ module Fog
|
||||||
module Network
|
module Network
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Ports < Fog::Collection
|
class Ports < Fog::Collection
|
||||||
|
|
||||||
|
attribute :filters
|
||||||
|
|
||||||
model Fog::Network::OpenStack::Port
|
model Fog::Network::OpenStack::Port
|
||||||
|
|
||||||
def all
|
def initialize(attributes)
|
||||||
load(connection.list_ports.body['ports'])
|
self.filters ||= {}
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def all(filters = filters)
|
||||||
|
self.filters = filters
|
||||||
|
load(connection.list_ports(filters).body['ports'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(port_id)
|
def get(port_id)
|
||||||
|
|
|
@ -5,10 +5,19 @@ module Fog
|
||||||
module Network
|
module Network
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Subnets < Fog::Collection
|
class Subnets < Fog::Collection
|
||||||
|
|
||||||
|
attribute :filters
|
||||||
|
|
||||||
model Fog::Network::OpenStack::Subnet
|
model Fog::Network::OpenStack::Subnet
|
||||||
|
|
||||||
def all
|
def initialize(attributes)
|
||||||
load(connection.list_subnets.body['subnets'])
|
self.filters ||= {}
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def all(filters = filters)
|
||||||
|
self.filters = filters
|
||||||
|
load(connection.list_subnets(filters).body['subnets'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(subnet_id)
|
def get(subnet_id)
|
||||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
||||||
class OpenStack
|
class OpenStack
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
def list_networks
|
def list_networks(filters = {})
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => 'networks'
|
:path => 'networks',
|
||||||
|
:query => filters
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_networks
|
def list_networks(filters = {})
|
||||||
Excon::Response.new(
|
Excon::Response.new(
|
||||||
:body => { 'networks' => self.data[:networks].values },
|
:body => { 'networks' => self.data[:networks].values },
|
||||||
:status => 200
|
:status => 200
|
||||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
||||||
class OpenStack
|
class OpenStack
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
def list_ports
|
def list_ports(filters = {})
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => 'ports'
|
:path => 'ports',
|
||||||
|
:query => filters
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_ports
|
def list_ports(filters = {})
|
||||||
Excon::Response.new(
|
Excon::Response.new(
|
||||||
:body => { 'ports' => self.data[:ports].values },
|
:body => { 'ports' => self.data[:ports].values },
|
||||||
:status => 200
|
:status => 200
|
||||||
|
|
|
@ -3,17 +3,18 @@ module Fog
|
||||||
class OpenStack
|
class OpenStack
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
def list_subnets
|
def list_subnets(filters = {})
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => 'subnets'
|
:path => 'subnets',
|
||||||
|
:query => filters
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_subnets
|
def list_subnets(filters = {})
|
||||||
Excon::Response.new(
|
Excon::Response.new(
|
||||||
:body => { 'subnets' => self.data[:subnets].values },
|
:body => { 'subnets' => self.data[:subnets].values },
|
||||||
:status => 200
|
:status => 200
|
||||||
|
|
Loading…
Add table
Reference in a new issue