]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow DHCP and L3 agents to choose if they should report state
authorgongysh <gongysh@linux.vnet.ibm.com>
Mon, 4 Mar 2013 01:18:44 +0000 (09:18 +0800)
committergongysh <gongysh@linux.vnet.ibm.com>
Mon, 4 Mar 2013 09:09:28 +0000 (17:09 +0800)
Bug #1143195
blueprint quantum-scheduler

Change-Id: Iba7bf82d7130462be4dda6c1c5f9a0fc5633707d

etc/dhcp_agent.ini
etc/l3_agent.ini
quantum/agent/dhcp_agent.py
quantum/agent/l3_agent.py
quantum/agent/rpc.py

index 9625312475416fe537d2f6db6cda7ac0cbeb5560..01872e3535e1c015a95d92d09d2544d2654663f7 100644 (file)
@@ -40,6 +40,3 @@ dhcp_driver = quantum.agent.linux.dhcp.Dnsmasq
 # they will be able to reach 169.254.169.254 through a router.
 # This option requires enable_isolated_metadata = True
 # enable_metadata_network = False
-
-# The Quantum DHCP agent manager.
-# dhcp_agent_manager = quantum.agent.dhcp_agent.DhcpAgent
index c08fa37cb052cb269e65caba44d8f8d06d3e3b57..133576c3f37c5b48fd3ae175d3eae6a7f73c5f5c 100644 (file)
@@ -2,9 +2,6 @@
 # Show debugging output in log (sets DEBUG log level output)
 # debug = True
 
-# The Quantum L3 Agent manager
-# l3_agent_manager = quantum.agent.l3_agent.L3NATAgent
-
 # L3 requires that an interface driver be set.  Choose the one that best
 # matches your plugin.
 
index 917626468cb1726b48768a923984a08b3b5100e3..89aa5604dc68e860510c813194434dd9df769c0a 100644 (file)
@@ -65,9 +65,6 @@ class DhcpAgent(manager.Manager):
                     help=_("Allows for serving metadata requests from a "
                            "dedicate network. Requires "
                            "enable isolated_metadata = True ")),
-        cfg.StrOpt('dhcp_agent_manager',
-                   default='quantum.agent.dhcp_agent.DhcpAgent',
-                   help=_("The Quantum DHCP agent manager.")),
     ]
 
     def __init__(self, host=None):
@@ -669,8 +666,8 @@ class DhcpAgentWithStateReport(DhcpAgent):
             'agent_type': constants.AGENT_TYPE_DHCP}
         report_interval = cfg.CONF.AGENT.report_interval
         if report_interval:
-            heartbeat = loopingcall.LoopingCall(self._report_state)
-            heartbeat.start(interval=report_interval)
+            self.heartbeat = loopingcall.LoopingCall(self._report_state)
+            self.heartbeat.start(interval=report_interval)
 
     def _report_state(self):
         try:
@@ -679,6 +676,13 @@ class DhcpAgentWithStateReport(DhcpAgent):
             ctx = context.get_admin_context_without_session()
             self.state_rpc.report_state(ctx,
                                         self.agent_state)
+        except AttributeError:
+            # This means the server does not support report_state
+            LOG.warn(_("Quantum server does not support state report."
+                       " State report for this agent will be disabled."))
+            self.heartbeat.stop()
+            self.run()
+            return
         except Exception:
             LOG.exception(_("Failed reporting state!"))
             return
@@ -708,5 +712,6 @@ def main():
     server = quantum_service.Service.create(
         binary='quantum-dhcp-agent',
         topic=topics.DHCP_AGENT,
-        report_interval=cfg.CONF.AGENT.report_interval)
+        report_interval=cfg.CONF.AGENT.report_interval,
+        manager='quantum.agent.dhcp_agent.DhcpAgentWithStateReport')
     service.launch(server).wait()
index bfaa1c415e51596d6ddce9192c6671082862f556..f2823926a4d1e6c1024d095583ad6e99f725c81a 100644 (file)
@@ -143,9 +143,6 @@ class L3NATAgent(manager.Manager):
         cfg.StrOpt('gateway_external_network_id', default='',
                    help=_("UUID of external network for routers implemented "
                           "by the agents.")),
-        cfg.StrOpt('l3_agent_manager',
-                   default='quantum.agent.l3_agent.L3NATAgent',
-                   help=_("The Quantum L3 Agent manager.")),
     ]
 
     def __init__(self, host, conf=None):
@@ -696,8 +693,8 @@ class L3NATAgentWithStateReport(L3NATAgent):
             'agent_type': l3_constants.AGENT_TYPE_L3}
         report_interval = cfg.CONF.AGENT.report_interval
         if report_interval:
-            heartbeat = loopingcall.LoopingCall(self._report_state)
-            heartbeat.start(interval=report_interval)
+            self.heartbeat = loopingcall.LoopingCall(self._report_state)
+            self.heartbeat.start(interval=report_interval)
 
     def _report_state(self):
         num_ex_gw_ports = 0
@@ -722,6 +719,12 @@ class L3NATAgentWithStateReport(L3NATAgent):
             self.state_rpc.report_state(self.context,
                                         self.agent_state)
             self.agent_state.pop('start_flag', None)
+        except AttributeError:
+            # This means the server does not support report_state
+            LOG.warn(_("Quantum server does not support state report."
+                       " State report for this agent will be disabled."))
+            self.heartbeat.stop()
+            return
         except Exception:
             LOG.exception(_("Failed reporting state!"))
 
@@ -744,5 +747,6 @@ def main():
     server = quantum_service.Service.create(
         binary='quantum-l3-agent',
         topic=topics.L3_AGENT,
-        report_interval=cfg.CONF.AGENT.report_interval)
+        report_interval=cfg.CONF.AGENT.report_interval,
+        manager='quantum.agent.l3_agent.L3NATAgentWithStateReport')
     service.launch(server).wait()
index 4f33fb2dd1d0cc899877d3b984c4b69555a0ad7b..899c345041687419443c25611ab739b65f2d20f4 100644 (file)
@@ -57,7 +57,7 @@ class PluginReportStateAPI(proxy.RpcProxy):
             topic=topic, default_version=self.BASE_RPC_API_VERSION)
 
     def report_state(self, context, agent_state):
-        return self.cast(context,
+        return self.call(context,
                          self.make_msg('report_state',
                                        agent_state={'agent_state':
                                                     agent_state}),