]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Adds state reporting to SDN-VE agent
authorMohammad Banikazemi <mb@us.ibm.com>
Fri, 7 Mar 2014 02:50:18 +0000 (21:50 -0500)
committerMohammad Banikazemi <mb@us.ibm.com>
Fri, 7 Mar 2014 12:11:23 +0000 (07:11 -0500)
Adds periodic reporting of state by the agent
and support for agent extension to the plugin.

Change-Id: Ib7c29936f1c10cb9749291ac27b3ed24b20ed2f7
Closes-Bug: #1289100

neutron/common/constants.py
neutron/plugins/ibm/agent/sdnve_neutron_agent.py
neutron/plugins/ibm/sdnve_neutron_plugin.py

index 4975c013fc341ff8665fd61cc045bb8942ce7b98..cfa7cce87f8973ece79a1af428988fb2ed0513e9 100644 (file)
@@ -79,6 +79,7 @@ AGENT_TYPE_LOADBALANCER = 'Loadbalancer agent'
 AGENT_TYPE_MLNX = 'Mellanox plugin agent'
 AGENT_TYPE_METERING = 'Metering agent'
 AGENT_TYPE_METADATA = 'Metadata agent'
+AGENT_TYPE_SDNVE = 'IBM SDN-VE agent'
 L2_AGENT_TOPIC = 'N/A'
 
 PAGINATION_INFINITE = 'infinite'
index a67976e5094504f1518f4e376c66d1a844febeb5..5221c974cfa5e8267c0d640d5c79eac744a1632c 100644 (file)
@@ -27,11 +27,13 @@ from neutron.agent.linux import ip_lib
 from neutron.agent.linux import ovs_lib
 from neutron.agent import rpc as agent_rpc
 from neutron.common import config as logging_config
+from neutron.common import constants as n_const
 from neutron.common import legacy
 from neutron.common import topics
-from neutron.common import utils as q_utils
+from neutron.common import utils as n_utils
 from neutron import context
 from neutron.openstack.common import log as logging
+from neutron.openstack.common import loopingcall
 from neutron.openstack.common.rpc import dispatcher
 from neutron.plugins.ibm.common import config  # noqa
 from neutron.plugins.ibm.common import constants
@@ -76,6 +78,17 @@ class SdnveNeutronAgent():
         self.reset_br = reset_br
         self.out_of_band = out_of_band
 
+        self.agent_state = {
+            'binary': 'neutron-sdnve-agent',
+            'host': cfg.CONF.host,
+            'topic': n_const.L2_AGENT_TOPIC,
+            'configurations': {'interface_mappings': interface_mappings,
+                               'reset_br': self.reset_br,
+                               'out_of_band': self.out_of_band,
+                               'controller_ip': self.controller_ip},
+            'agent_type': n_const.AGENT_TYPE_SDNVE,
+            'start_flag': True}
+
         if self.int_bridge_name:
             self.int_br = self.setup_integration_br(integ_br, reset_br,
                                                     out_of_band,
@@ -86,6 +99,14 @@ class SdnveNeutronAgent():
 
         self.setup_rpc()
 
+    def _report_state(self):
+        try:
+            self.state_rpc.report_state(self.context,
+                                        self.agent_state)
+            self.agent_state.pop('start_flag', None)
+        except Exception:
+            LOG.exception(_("Failed reporting state!"))
+
     def setup_rpc(self):
         if self.int_br:
             mac = self.int_br.get_local_port_mac()
@@ -105,6 +126,10 @@ class SdnveNeutronAgent():
         self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                      self.topic,
                                                      consumers)
+        if self.polling_interval:
+            heartbeat = loopingcall.FixedIntervalLoopingCall(
+                self._report_state)
+            heartbeat.start(interval=self.polling_interval)
 
     # Plugin calls the agents through the following
     def info_update(self, context, **kwargs):
@@ -209,7 +234,7 @@ class SdnveNeutronAgent():
 
 def create_agent_config_map(config):
 
-    interface_mappings = q_utils.parse_mappings(
+    interface_mappings = n_utils.parse_mappings(
         config.SDNVE.interface_mappings)
 
     controller_ips = config.SDNVE.controller_ips
index b8c83190aef455423d570c7f2045dd7f50733083..fda586eb7eafeb2405b2a6864e56b0c7dd9e07f0 100644 (file)
@@ -107,6 +107,7 @@ class SdnvePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                     external_net_db.External_net_db_mixin,
                     portbindings_db.PortBindingMixin,
                     l3_gwmode_db.L3_NAT_db_mixin,
+                    agents_db.AgentDbMixin,
                     ):
 
     '''
@@ -117,7 +118,8 @@ class SdnvePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
     __native_pagination_support = False
     __native_sorting_support = False
 
-    supported_extension_aliases = ["binding", "router", "external-net"]
+    supported_extension_aliases = ["binding", "router", "external-net",
+                                   "agent"]
 
     def __init__(self, configfile=None):
         self.base_binding_dict = {