Move Neutron agents stuff from neutron/_client.py to neutron/_agent.py
Change-Id: Ie748703e98fb8de89805cca7b33459da1b20f68b
This commit is contained in:
parent
a23b564c95
commit
19199d74a0
|
@ -32,10 +32,16 @@ OVN_CONTROLLER = _agent.OVN_CONTROLLER
|
|||
OVN_METADATA_AGENT = _agent.OVN_METADATA_AGENT
|
||||
NEUTRON_OVN_METADATA_AGENT = _agent.NEUTRON_OVN_METADATA_AGENT
|
||||
AgentNotFoundOnHost = _agent.AgentNotFoundOnHost
|
||||
NeutronAgentType = _agent.NeutronAgentType
|
||||
find_l3_agent_hosting_router = _agent.find_l3_agent_hosting_router
|
||||
list_agents = _agent.list_agents
|
||||
list_dhcp_agent_hosting_network = _agent.list_dhcp_agent_hosting_network
|
||||
list_l3_agent_hosting_routers = _agent.list_l3_agent_hosting_routers
|
||||
list_networking_agents = _agent.list_networking_agents
|
||||
skip_if_missing_networking_agents = _agent.skip_if_missing_networking_agents
|
||||
skip_unless_is_ovn = _agent.skip_unless_is_ovn
|
||||
skip_unless_is_ovs = _agent.skip_unless_is_ovs
|
||||
list_networking_agents = _agent.list_networking_agents
|
||||
|
||||
|
||||
NeutronClientFixture = _client.NeutronClientFixture
|
||||
ServiceUnavailable = _client.ServiceUnavailable
|
||||
|
@ -48,7 +54,6 @@ create_port = _client.create_port
|
|||
delete_port = _client.delete_port
|
||||
list_subnets = _client.list_subnets
|
||||
list_subnet_cidrs = _client.list_subnet_cidrs
|
||||
list_agents = _client.list_agents
|
||||
get_floating_ip = _client.get_floating_ip
|
||||
create_floating_ip = _client.create_floating_ip
|
||||
delete_floating_ip = _client.delete_floating_ip
|
||||
|
@ -56,9 +61,6 @@ update_floating_ip = _client.update_floating_ip
|
|||
get_router = _client.get_router
|
||||
get_port = _client.get_port
|
||||
get_subnet = _client.get_subnet
|
||||
list_l3_agent_hosting_routers = _client.list_l3_agent_hosting_routers
|
||||
find_l3_agent_hosting_router = _client.find_l3_agent_hosting_router
|
||||
list_dhcp_agent_hosting_network = _client.list_dhcp_agent_hosting_network
|
||||
|
||||
NoSuchPort = _client.NoSuchPort
|
||||
NoSuchFIP = _client.NoSuchFIP
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import typing # noqa
|
||||
import collections
|
||||
import typing
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack.neutron import _client
|
||||
|
@ -34,7 +35,44 @@ NEUTRON_OVN_METADATA_AGENT = 'neutron-ovn-metadata-agent'
|
|||
|
||||
|
||||
class AgentNotFoundOnHost(tobiko.TobikoException):
|
||||
message = ("Agent {agent_type!s} not found on the host {host!s}")
|
||||
message = "Agent {agent_type!s} not found on the host {host!s}"
|
||||
|
||||
|
||||
NeutronAgentType = typing.Dict[str, typing.Any]
|
||||
|
||||
|
||||
def list_agents(client=None, **params) \
|
||||
-> tobiko.Selection[NeutronAgentType]:
|
||||
agents = _client.neutron_client(client).list_agents(**params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.Selection[NeutronAgentType](agents)
|
||||
|
||||
|
||||
def list_l3_agent_hosting_routers(router, client=None, **params):
|
||||
agents = _client.neutron_client(client).list_l3_agent_hosting_routers(
|
||||
router, **params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.select(agents)
|
||||
|
||||
|
||||
def find_l3_agent_hosting_router(router, client=None, unique=False,
|
||||
**list_params):
|
||||
agents = list_l3_agent_hosting_routers(router=router, client=client,
|
||||
**list_params)
|
||||
if unique:
|
||||
return agents.unique
|
||||
else:
|
||||
return agents.first
|
||||
|
||||
|
||||
def list_dhcp_agent_hosting_network(network, client=None, **params):
|
||||
agents = _client.neutron_client(client).list_dhcp_agent_hosting_networks(
|
||||
network, **params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.select(agents)
|
||||
|
||||
|
||||
class NetworkingAgentFixture(tobiko.SharedFixture):
|
||||
|
@ -42,7 +80,7 @@ class NetworkingAgentFixture(tobiko.SharedFixture):
|
|||
agents = None
|
||||
|
||||
def setup_fixture(self):
|
||||
self.agents = _client.list_agents()
|
||||
self.agents = list_agents()
|
||||
|
||||
|
||||
def list_networking_agents(**attributes):
|
||||
|
|
|
@ -127,13 +127,6 @@ def list_subnets(client=None, ip_version: typing.Optional[int] = None,
|
|||
return tobiko.select(subnets)
|
||||
|
||||
|
||||
def list_agents(client=None, **params):
|
||||
agents = neutron_client(client).list_agents(**params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.select(agents)
|
||||
|
||||
|
||||
def list_subnet_cidrs(client=None, **params):
|
||||
return tobiko.select(netaddr.IPNetwork(subnet['cidr'])
|
||||
for subnet in list_subnets(client=client, **params))
|
||||
|
@ -206,35 +199,6 @@ def get_subnet(subnet, client=None, **params):
|
|||
raise NoSuchSubnet(id=subnet) from ex
|
||||
|
||||
|
||||
def list_l3_agent_hosting_routers(router, client=None, **params):
|
||||
agents = neutron_client(client).list_l3_agent_hosting_routers(
|
||||
router, **params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.select(agents)
|
||||
|
||||
|
||||
def find_l3_agent_hosting_router(router, client=None, unique=False,
|
||||
default=_RAISE_ERROR, **params):
|
||||
agents = list_l3_agent_hosting_routers(router=router, client=client,
|
||||
**params)
|
||||
if default is _RAISE_ERROR or agents:
|
||||
if unique:
|
||||
return agents.unique
|
||||
else:
|
||||
return agents.first
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
def list_dhcp_agent_hosting_network(network, client=None, **params):
|
||||
agents = neutron_client(client).list_dhcp_agent_hosting_networks(
|
||||
network, **params)
|
||||
if isinstance(agents, collections.Mapping):
|
||||
agents = agents['agents']
|
||||
return tobiko.select(agents)
|
||||
|
||||
|
||||
class NoSuchPort(tobiko.ObjectNotFound):
|
||||
message = "No such port found for {id!r}"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import json
|
|||
from oslo_log import log
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack.neutron import _client
|
||||
from tobiko.openstack.neutron import _agent
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -35,7 +35,7 @@ def wait_for_master_and_backup_agents(
|
|||
interval=interval,
|
||||
default_timeout=300.,
|
||||
default_interval=5.):
|
||||
router_agents = _client.list_l3_agent_hosting_routers(router_id)
|
||||
router_agents = _agent.list_l3_agent_hosting_routers(router_id)
|
||||
master_agents = router_agents.with_items(ha_state='active')
|
||||
if master_agents:
|
||||
LOG.debug(
|
||||
|
|
Loading…
Reference in New Issue