]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Clarify the init logic for the ML2 plugin
authorarmando-migliaccio <armamig@gmail.com>
Thu, 16 Apr 2015 00:35:13 +0000 (17:35 -0700)
committerarmando-migliaccio <armamig@gmail.com>
Thu, 16 Apr 2015 18:27:07 +0000 (11:27 -0700)
This patch cleans up the init logic for the plugin so that
we better separate the tasks required for establishing
the integration with DHCP and RPC layers.

In other words: some bikeshedding whilst dealing with bug #1444112

Change-Id: I68710ad002b0e1b5bff40baa5de343b0bd7ecea6

neutron/plugins/ml2/plugin.py

index 6656a88d2907209c10d17c27d7ccbf5fbd5cffd3..c57bfe71d62de5cd0109e70f59f08a6df92b9ac6 100644 (file)
@@ -141,32 +141,36 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
         self.mechanism_manager.initialize()
 
         self._setup_rpc()
-
-        # REVISIT(rkukura): Use stevedore for these?
-        self.network_scheduler = importutils.import_object(
-            cfg.CONF.network_scheduler_driver
-        )
-
-        self.start_periodic_dhcp_agent_status_check()
+        self._setup_dhcp()
         LOG.info(_LI("Modular L2 Plugin initialization complete"))
 
     def _setup_rpc(self):
+        """Initialize components to support agent communication."""
         self.notifier = rpc.AgentNotifierApi(topics.AGENT)
         self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
             dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
         )
+        self.endpoints = [
+            rpc.RpcCallbacks(self.notifier, self.type_manager),
+            securitygroups_rpc.SecurityGroupServerRpcCallback(),
+            dvr_rpc.DVRServerRpcCallback(),
+            dhcp_rpc.DhcpRpcCallback(),
+            agents_db.AgentExtRpcCallback(),
+            metadata_rpc.MetadataRpcCallback()
+        ]
+
+    def _setup_dhcp(self):
+        """Initialize components to support DHCP."""
+        self.network_scheduler = importutils.import_object(
+            cfg.CONF.network_scheduler_driver
+        )
+        self.start_periodic_dhcp_agent_status_check()
 
     def start_rpc_listeners(self):
-        self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
-                          securitygroups_rpc.SecurityGroupServerRpcCallback(),
-                          dvr_rpc.DVRServerRpcCallback(),
-                          dhcp_rpc.DhcpRpcCallback(),
-                          agents_db.AgentExtRpcCallback(),
-                          metadata_rpc.MetadataRpcCallback()]
+        """Start the RPC loop to let the plugin communicate with agents."""
         self.topic = topics.PLUGIN
         self.conn = n_rpc.create_connection(new=True)
-        self.conn.create_consumer(self.topic, self.endpoints,
-                                  fanout=False)
+        self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
         return self.conn.consume_in_threads()
 
     def _filter_nets_provider(self, context, networks, filters):