]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove __init__ method from TunnelCallback mixin
authorKevin Benton <blak111@gmail.com>
Thu, 19 Jun 2014 07:19:28 +0000 (00:19 -0700)
committerKevin Benton <blak111@gmail.com>
Wed, 25 Jun 2014 15:16:37 +0000 (08:16 -0700)
Removed an __init__ method from a mixin class that
made mixing with other classes fragile and inflexible.
This replaces it with an explicit setup method.

This allows the ML2 RPCCallbacks class to correctly
inherit the common RpcCallback class.

Closes-Bug: #1332041
Change-Id: I36cb7dcf57147468f252d61f846b2b28dd77c8ff

neutron/plugins/ml2/drivers/type_tunnel.py
neutron/plugins/ml2/rpc.py

index e209029b9651de3e1b27e29f0c2c317a92953fc4..fbc7110eae9a22dc48eb69da321c9f2aec3cf774 100644 (file)
@@ -87,9 +87,9 @@ class TunnelTypeDriver(api.TypeDriver):
 
 class TunnelRpcCallbackMixin(object):
 
-    def __init__(self, notifier, type_manager):
-        self.notifier = notifier
-        self.type_manager = type_manager
+    def setup_tunnel_callback_mixin(self, notifier, type_manager):
+        self._notifier = notifier
+        self._type_manager = type_manager
 
     def tunnel_sync(self, rpc_context, **kwargs):
         """Update new tunnel.
@@ -102,14 +102,14 @@ class TunnelRpcCallbackMixin(object):
         if not tunnel_type:
             msg = _("Network_type value needed by the ML2 plugin")
             raise exc.InvalidInput(error_message=msg)
-        driver = self.type_manager.drivers.get(tunnel_type)
+        driver = self._type_manager.drivers.get(tunnel_type)
         if driver:
             tunnel = driver.obj.add_endpoint(tunnel_ip)
             tunnels = driver.obj.get_endpoints()
             entry = {'tunnels': tunnels}
             # Notify all other listening agents
-            self.notifier.tunnel_update(rpc_context, tunnel.ip_address,
-                                        tunnel_type)
+            self._notifier.tunnel_update(rpc_context, tunnel.ip_address,
+                                         tunnel_type)
             # Return the list of tunnels IP's to the agent
             return entry
         else:
index d58751c94d24a934bb899ee9bdb5f2d8805a511e..d8226aa7af6bebb7b4c5d56e2813580f9fe83a05 100644 (file)
@@ -13,8 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo import messaging
-
 from neutron.agent import securitygroups_rpc as sg_rpc
 from neutron.common import constants as q_const
 from neutron.common import rpc as n_rpc
@@ -37,7 +35,8 @@ TAP_DEVICE_PREFIX = 'tap'
 TAP_DEVICE_PREFIX_LENGTH = 3
 
 
-class RpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
+class RpcCallbacks(n_rpc.RpcCallback,
+                   dhcp_rpc_base.DhcpRpcCallbackMixin,
                    sg_db_rpc.SecurityGroupServerRpcCallbackMixin,
                    type_tunnel.TunnelRpcCallbackMixin):
 
@@ -46,16 +45,9 @@ class RpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
     #   1.0 Initial version (from openvswitch/linuxbridge)
     #   1.1 Support Security Group RPC
 
-    # FIXME(ihrachys): we can't use n_rpc.RpcCallback here due to
-    # inheritance problems
-    target = messaging.Target(version=RPC_API_VERSION)
-
     def __init__(self, notifier, type_manager):
-        # REVISIT(kmestery): This depends on the first three super classes
-        # not having their own __init__ functions. If an __init__() is added
-        # to one, this could break. Fix this and add a unit test to cover this
-        # test in H3.
-        super(RpcCallbacks, self).__init__(notifier, type_manager)
+        self.setup_tunnel_callback_mixin(notifier, type_manager)
+        super(RpcCallbacks, self).__init__()
 
     @classmethod
     def _device_to_port_id(cls, device):