]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make DvrServerRpcCallback a separate callback class
authorAkihiro Motoki <motoki@da.jp.nec.com>
Tue, 19 Aug 2014 12:16:19 +0000 (21:16 +0900)
committerAkihiro Motoki <motoki@da.jp.nec.com>
Thu, 28 Aug 2014 14:30:06 +0000 (23:30 +0900)
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 DVR ML2 RPC interface.

Partial-Bug: #1359416
Change-Id: I1b6383f7b0af5d9aed18eda3a15f21d3504d0347

neutron/api/rpc/handlers/dvr_rpc.py
neutron/plugins/ml2/plugin.py
neutron/plugins/ml2/rpc.py

index 5ac21015130a2b78907e16c71f85b66c56fdfc2e..f4d0233a56c1497591ba3abfe6c025298169b21b 100644 (file)
@@ -14,6 +14,7 @@
 #    under the License.
 
 from neutron.common import log
+from neutron.common import rpc as n_rpc
 from neutron.common import topics
 from neutron import manager
 from neutron.openstack.common import log as logging
@@ -56,9 +57,14 @@ class DVRServerRpcApiMixin(object):
                          version=self.DVR_RPC_VERSION)
 
 
-class DVRServerRpcCallbackMixin(object):
+class DVRServerRpcCallback(n_rpc.RpcCallback):
     """Plugin-side RPC (implementation) for agent-to-plugin interaction."""
 
+    # History
+    #   1.0 Initial version
+
+    RPC_API_VERSION = "1.0"
+
     @property
     def plugin(self):
         if not getattr(self, '_plugin', None):
@@ -68,14 +74,20 @@ class DVRServerRpcCallbackMixin(object):
     def get_dvr_mac_address_list(self, context):
         return self.plugin.get_dvr_mac_address_list(context)
 
-    def get_dvr_mac_address_by_host(self, context, host):
+    def get_dvr_mac_address_by_host(self, context, **kwargs):
+        host = kwargs.get('host')
+        LOG.debug("DVR Agent requests mac_address for host %s", host)
         return self.plugin.get_dvr_mac_address_by_host(context, host)
 
-    def get_ports_on_host_by_subnet(self, context, host, subnet):
+    def get_ports_on_host_by_subnet(self, context, **kwargs):
+        host = kwargs.get('host')
+        subnet = kwargs.get('subnet')
+        LOG.debug("DVR Agent requests list of VM ports on host %s", host)
         return self.plugin.get_ports_on_host_by_subnet(context,
             host, subnet)
 
-    def get_subnet_for_dvr(self, context, subnet):
+    def get_subnet_for_dvr(self, context, **kwargs):
+        subnet = kwargs.get('subnet')
         return self.plugin.get_subnet_for_dvr(context, subnet)
 
 
index 66e77bb045f5a0fbdff33bcf7765f6f30f24de81..cb57323544d89f381a12d365c229b13c8e6d4fd2 100644 (file)
@@ -24,6 +24,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.rpc.handlers import dvr_rpc
 from neutron.api.v2 import attributes
 from neutron.common import constants as const
 from neutron.common import exceptions as exc
@@ -135,6 +136,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
 
     def start_rpc_listeners(self):
         self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
+                          dvr_rpc.DVRServerRpcCallback(),
                           dhcp_rpc.DhcpRpcCallback(),
                           agents_db.AgentExtRpcCallback()]
         self.topic = topics.PLUGIN
index 8e77e309d26cc71abb99e05ae74570a87fcd9c2d..6a1c647cde2123a1baa2e695ddc76f508d06417b 100644 (file)
@@ -39,7 +39,6 @@ TAP_DEVICE_PREFIX_LENGTH = 3
 
 
 class RpcCallbacks(n_rpc.RpcCallback,
-                   dvr_rpc.DVRServerRpcCallbackMixin,
                    sg_db_rpc.SecurityGroupServerRpcCallbackMixin,
                    type_tunnel.TunnelRpcCallbackMixin):
 
@@ -199,24 +198,6 @@ class RpcCallbacks(n_rpc.RpcCallback,
             except exceptions.PortNotFound:
                 LOG.debug('Port %s not found during ARP update', port_id)
 
-    def get_dvr_mac_address_by_host(self, rpc_context, **kwargs):
-        host = kwargs.get('host')
-        LOG.debug("DVR Agent requests mac_address for host %s", host)
-        return super(RpcCallbacks, self).get_dvr_mac_address_by_host(
-            rpc_context, host)
-
-    def get_ports_on_host_by_subnet(self, rpc_context, **kwargs):
-        host = kwargs.get('host')
-        subnet = kwargs.get('subnet')
-        LOG.debug("DVR Agent requests list of VM ports on host %s", host)
-        return super(RpcCallbacks, self).get_ports_on_host_by_subnet(
-            rpc_context, host, subnet)
-
-    def get_subnet_for_dvr(self, rpc_context, **kwargs):
-        subnet = kwargs.get('subnet')
-        return super(RpcCallbacks, self).get_subnet_for_dvr(rpc_context,
-                                                            subnet)
-
 
 class AgentNotifierApi(n_rpc.RpcProxy,
                        dvr_rpc.DVRAgentRpcApiMixin,