Make DhcpRpcCallback a separate callback class
RPC has a version of itself. In Neutron a plugin implements several RPC interface, so a single RPC version doesn't work. In Mixin callback class approach, RPC versioning depends on each plugin implementation and it makes harder to maintain RPC version appropriately. This patch series replaces mixin RPC callback of server side with a separate class. This commit handles server-side callback of dhcp-agent RPC interface. DHCP-agent server-side callback class is moved from db/ to api/rpc/handlers because it doesn't involve any db operations and defining all RPC interfaces in a single place sounds reasonable. Note that moving other DHCP-agent related RPC interface class to api/rpc/handlers can be done in a separate patch as this patch focuses on reorganizing the server-side RPC callback class. Partial-Bug: #1359416 Change-Id: Ifb2a1bc0b7971995aae2856c9d4cd88c6dbc22d6
This commit is contained in:
parent
fed5dcf5ee
commit
42a8770a49
@ -19,6 +19,7 @@ from oslo.db import exception as db_exc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import utils
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
@ -29,8 +30,14 @@ from neutron.openstack.common import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DhcpRpcCallbackMixin(object):
|
||||
"""A mix-in that enable DHCP agent support in plugin implementations."""
|
||||
class DhcpRpcCallback(n_rpc.RpcCallback):
|
||||
"""DHCP agent RPC callback in plugin implementations."""
|
||||
|
||||
# API version history:
|
||||
# 1.0 - Initial version.
|
||||
# 1.1 - Added get_active_networks_info, create_dhcp_port,
|
||||
# and update_dhcp_port methods.
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
def _get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active networks."""
|
@ -55,6 +55,7 @@ from sqlalchemy.orm import exc as sqlexc
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api import extensions as neutron_extensions
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import exceptions
|
||||
from neutron.common import rpc as n_rpc
|
||||
@ -66,7 +67,6 @@ from neutron.db import agentschedulers_db
|
||||
from neutron.db import allowedaddresspairs_db as addr_pair_db
|
||||
from neutron.db import api as db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extradhcpopt_db
|
||||
from neutron.db import l3_db
|
||||
@ -114,8 +114,7 @@ class AgentNotifierApi(n_rpc.RpcProxy,
|
||||
|
||||
|
||||
class RestProxyCallbacks(n_rpc.RpcCallback,
|
||||
sg_rpc_base.SecurityGroupServerRpcCallbackMixin,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
sg_rpc_base.SecurityGroupServerRpcCallbackMixin):
|
||||
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
@ -511,6 +510,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
||||
self._dhcp_agent_notifier
|
||||
)
|
||||
self.endpoints = [RestProxyCallbacks(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
self.conn.create_consumer(self.topic, self.endpoints,
|
||||
fanout=False)
|
||||
|
@ -28,6 +28,7 @@ from oslo.config import cfg
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.common import constants as q_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
@ -37,7 +38,6 @@ from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import api as db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
@ -78,7 +78,6 @@ cfg.CONF.register_opts(PHYSICAL_INTERFACE_OPTS, "PHYSICAL_INTERFACE")
|
||||
|
||||
|
||||
class BridgeRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
"""Agent callback."""
|
||||
|
||||
@ -263,6 +262,7 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
is_admin=False)
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [BridgeRpcCallbacks(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -23,6 +23,7 @@ from oslo.config import cfg as q_conf
|
||||
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants
|
||||
@ -33,7 +34,6 @@ from neutron.common import utils
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
@ -58,15 +58,6 @@ from neutron.plugins.common import constants as svc_constants
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class N1kvRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
|
||||
"""Class to handle agent RPC calls."""
|
||||
|
||||
# Set RPC API version to 1.1 by default.
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
|
||||
class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
external_net_db.External_net_db_mixin,
|
||||
extraroute_db.ExtraRoute_db_mixin,
|
||||
@ -127,7 +118,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.service_topics = {svc_constants.CORE: topics.PLUGIN,
|
||||
svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [N1kvRpcCallbacks(),
|
||||
self.endpoints = [dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import exceptions as n_exc
|
||||
@ -189,6 +190,7 @@ class HyperVNeutronPlugin(agents_db.AgentDbMixin,
|
||||
self.notifier = agent_notifier_api.AgentNotifierApi(
|
||||
topics.AGENT)
|
||||
self.endpoints = [rpc_callbacks.HyperVRpcCallbacks(self.notifier),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
from neutron.common import constants as q_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.hyperv import db as hyperv_db
|
||||
|
||||
@ -24,9 +23,7 @@ from neutron.plugins.hyperv import db as hyperv_db
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HyperVRpcCallbacks(
|
||||
n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
class HyperVRpcCallbacks(n_rpc.RpcCallback):
|
||||
|
||||
# history
|
||||
# 1.1 Support Security Group RPC
|
||||
|
@ -20,6 +20,7 @@ from oslo.config import cfg
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as q_const
|
||||
@ -31,7 +32,6 @@ from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
@ -54,7 +54,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin
|
||||
):
|
||||
|
||||
@ -284,6 +283,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [LinuxBridgeRpcCallbacks(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -29,6 +29,7 @@ from oslo.config import cfg
|
||||
from sqlalchemy.orm import exc as sa_exc
|
||||
from webob import exc as w_exc
|
||||
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants
|
||||
from neutron.common import exceptions as n_exc
|
||||
@ -37,7 +38,6 @@ from neutron.common import topics
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import models_v2
|
||||
@ -194,11 +194,6 @@ def _check_resource_exists(func, id, name, raise_exc=False):
|
||||
raise MidonetPluginException(msg=exc)
|
||||
|
||||
|
||||
class MidoRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
|
||||
class MidonetPluginException(n_exc.NeutronException):
|
||||
message = _("%(msg)s")
|
||||
|
||||
@ -395,7 +390,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
# RPC support
|
||||
self.topic = topics.PLUGIN
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [MidoRpcCallbacks(),
|
||||
self.endpoints = [dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
self.conn.create_consumer(self.topic, self.endpoints,
|
||||
fanout=False)
|
||||
|
@ -23,6 +23,7 @@ from sqlalchemy.orm import exc as sa_exc
|
||||
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import exceptions as exc
|
||||
@ -134,6 +135,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def start_rpc_listeners(self):
|
||||
self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
self.topic = topics.PLUGIN
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
|
@ -20,7 +20,6 @@ from neutron.common import exceptions
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import securitygroups_rpc_base as sg_db_rpc
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
@ -40,7 +39,6 @@ TAP_DEVICE_PREFIX_LENGTH = 3
|
||||
|
||||
|
||||
class RpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
dvr_rpc.DVRServerRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin,
|
||||
type_tunnel.TunnelRpcCallbackMixin):
|
||||
|
@ -20,6 +20,7 @@ from oslo.config import cfg
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as q_const
|
||||
@ -121,6 +122,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [rpc_callbacks.MlnxRpcCallbacks(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -17,7 +17,6 @@ from oslo.config import cfg
|
||||
from neutron.common import constants as q_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import securitygroups_rpc_base as sg_db_rpc
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.mlnx.db import mlnx_db_v2 as db
|
||||
@ -26,7 +25,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MlnxRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
# History
|
||||
# 1.1 Support Security Group RPC
|
||||
|
@ -17,6 +17,7 @@
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api import extensions as neutron_extensions
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
from neutron.common import constants as const
|
||||
@ -27,7 +28,6 @@ from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import allowedaddresspairs_db as addr_pair_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import portbindings_base
|
||||
from neutron.db import portbindings_db
|
||||
@ -146,7 +146,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.callback_sg = SecurityGroupServerRpcCallback()
|
||||
self.endpoints = [
|
||||
NECPluginV2RPCCallbacks(self.safe_reference),
|
||||
DhcpRpcCallback(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
self.callback_sg,
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
@ -680,12 +680,6 @@ class NECPluginV2AgentNotifierApi(n_rpc.RpcProxy,
|
||||
topic=self.topic_port_update)
|
||||
|
||||
|
||||
class DhcpRpcCallback(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
# DhcpPluginApi BASE_RPC_API_VERSION
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
|
||||
class SecurityGroupServerRpcCallback(
|
||||
n_rpc.RpcCallback,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
|
@ -21,6 +21,7 @@ from oslo.config import cfg
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.common import constants as q_const
|
||||
from neutron.common import exceptions as nexception
|
||||
@ -29,7 +30,6 @@ from neutron.common import topics
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
@ -52,7 +52,6 @@ IPv6 = 6
|
||||
|
||||
|
||||
class NVSDPluginRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
|
||||
RPC_API_VERSION = '1.1'
|
||||
@ -161,6 +160,7 @@ class OneConvergencePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
l3_rpc_agent_api.L3AgentNotifyAPI()
|
||||
)
|
||||
self.endpoints = [NVSDPluginRpcCallbacks(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -20,6 +20,7 @@ from oslo.config import cfg
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as q_const
|
||||
@ -31,7 +32,6 @@ from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import allowedaddresspairs_db as addr_pair_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extradhcpopt_db
|
||||
from neutron.db import extraroute_db
|
||||
@ -59,7 +59,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OVSRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
|
||||
# history
|
||||
@ -345,6 +344,7 @@ class OVSNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
l3_rpc_agent_api.L3AgentNotifyAPI()
|
||||
)
|
||||
self.endpoints = [OVSRpcCallbacks(self.notifier, self.tunnel_type),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
|
@ -20,6 +20,7 @@ from ryu.app import client
|
||||
from ryu.app import rest_nw_id
|
||||
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.common import constants as q_const
|
||||
from neutron.common import exceptions as n_exc
|
||||
@ -27,7 +28,6 @@ from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.db import api as db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.db import l3_gwmode_db
|
||||
@ -46,7 +46,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RyuRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin,
|
||||
sg_db_rpc.SecurityGroupServerRpcCallbackMixin):
|
||||
|
||||
RPC_API_VERSION = '1.1'
|
||||
@ -139,6 +138,7 @@ class RyuNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.notifier = AgentNotifierApi(topics.AGENT)
|
||||
self.endpoints = [RyuRpcCallbacks(self.ofp_api_host),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
l3_rpc.L3RpcCallback()]
|
||||
for svc_topic in self.service_topics.values():
|
||||
self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
|
||||
|
@ -22,9 +22,7 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import exceptions as ntn_exc
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import models_v2
|
||||
from neutron.openstack.common import log as logging
|
||||
@ -40,12 +38,6 @@ METADATA_GATEWAY_IP = '169.254.169.253'
|
||||
METADATA_DHCP_ROUTE = '169.254.169.254/32'
|
||||
|
||||
|
||||
class NSXRpcCallbacks(n_rpc.RpcCallback,
|
||||
dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
|
||||
RPC_API_VERSION = '1.1'
|
||||
|
||||
|
||||
def handle_network_dhcp_access(plugin, context, network, action):
|
||||
pass
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
@ -71,7 +72,7 @@ class DhcpMetadataAccess(object):
|
||||
def _setup_rpc_dhcp_metadata(self, notifier=None):
|
||||
self.topic = topics.PLUGIN
|
||||
self.conn = n_rpc.create_connection(new=True)
|
||||
self.endpoints = [nsx_rpc.NSXRpcCallbacks(),
|
||||
self.endpoints = [dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback()]
|
||||
self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
|
||||
self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
|
||||
|
@ -23,12 +23,12 @@ from webob import exc
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
from neutron.extensions import agent
|
||||
from neutron.extensions import dhcpagentscheduler
|
||||
@ -263,16 +263,16 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
with contextlib.nested(self.subnet(),
|
||||
self.subnet()):
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
self._register_agent_states()
|
||||
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTA)
|
||||
hostc_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTC)
|
||||
self._disable_agent(hosta_id)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
# second agent will host all the networks since first is disabled.
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hostc_id)
|
||||
num_hostc_nets = len(networks['networks'])
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hosta_id)
|
||||
@ -284,15 +284,15 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
with contextlib.nested(self.subnet(enable_dhcp=False),
|
||||
self.subnet(enable_dhcp=False)):
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
self._register_agent_states()
|
||||
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTA)
|
||||
hostc_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTC)
|
||||
self._disable_agent(hosta_id)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hostc_id)
|
||||
num_hostc_nets = len(networks['networks'])
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hosta_id)
|
||||
@ -305,14 +305,14 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
with contextlib.nested(self.subnet(),
|
||||
self.subnet()):
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
self._register_agent_states()
|
||||
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTA)
|
||||
hostc_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTC)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hostc_id)
|
||||
num_hostc_nets = len(networks['networks'])
|
||||
networks = self._list_networks_hosted_by_dhcp_agent(hosta_id)
|
||||
@ -323,10 +323,10 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
def test_network_auto_schedule_restart_dhcp_agent(self):
|
||||
cfg.CONF.set_override('dhcp_agents_per_network', 2)
|
||||
with self.subnet() as sub1:
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
self._register_agent_states()
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_agents = self._list_dhcp_agents_hosting_network(
|
||||
sub1['subnet']['network_id'])
|
||||
self.assertEqual(1, len(dhcp_agents['agents']))
|
||||
@ -336,11 +336,11 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
with contextlib.nested(self.subnet(),
|
||||
self.subnet()) as (sub1, sub2):
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
self._register_agent_states()
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
# second agent will not host the network since first has got it.
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTC)
|
||||
dhcp_agents = self._list_dhcp_agents_hosting_network(
|
||||
sub1['subnet']['network_id'])
|
||||
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
@ -359,7 +359,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
|
||||
def test_network_auto_schedule_with_hosted_2(self):
|
||||
# one agent hosts one network
|
||||
dhcp_rpc = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
|
||||
dhcp_hosta = {
|
||||
'binary': 'neutron-dhcp-agent',
|
||||
'host': DHCP_HOSTA,
|
||||
@ -373,13 +373,13 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
with self.subnet() as sub1:
|
||||
self._register_one_agent_state(dhcp_hosta)
|
||||
dhcp_rpc.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext, host=DHCP_HOSTA)
|
||||
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
|
||||
DHCP_HOSTA)
|
||||
self._disable_agent(hosta_id, admin_state_up=False)
|
||||
with self.subnet() as sub2:
|
||||
self._register_one_agent_state(dhcp_hostc)
|
||||
dhcp_rpc.get_active_networks(self.adminContext,
|
||||
dhcp_rpc_cb.get_active_networks(self.adminContext,
|
||||
host=DHCP_HOSTC)
|
||||
dhcp_agents_1 = self._list_dhcp_agents_hosting_network(
|
||||
sub1['subnet']['network_id'])
|
||||
|
@ -16,22 +16,22 @@
|
||||
import mock
|
||||
from oslo.db import exception as db_exc
|
||||
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.common import constants
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.db import dhcp_rpc_base
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestDhcpRpcCallbackMixin(base.BaseTestCase):
|
||||
class TestDhcpRpcCallback(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDhcpRpcCallbackMixin, self).setUp()
|
||||
super(TestDhcpRpcCallback, self).setUp()
|
||||
self.plugin_p = mock.patch('neutron.manager.NeutronManager.get_plugin')
|
||||
get_plugin = self.plugin_p.start()
|
||||
self.plugin = mock.MagicMock()
|
||||
get_plugin.return_value = self.plugin
|
||||
self.callbacks = dhcp_rpc_base.DhcpRpcCallbackMixin()
|
||||
self.log_p = mock.patch('neutron.db.dhcp_rpc_base.LOG')
|
||||
self.callbacks = dhcp_rpc.DhcpRpcCallback()
|
||||
self.log_p = mock.patch('neutron.api.rpc.handlers.dhcp_rpc.LOG')
|
||||
self.log = self.log_p.start()
|
||||
|
||||
def test_get_active_networks(self):
|
Loading…
Reference in New Issue
Block a user