Adds state reporting to SDN-VE agent

Adds periodic reporting of state by the agent
and support for agent extension to the plugin.

Change-Id: Ib7c29936f1c10cb9749291ac27b3ed24b20ed2f7
Closes-Bug: #1289100
This commit is contained in:
Mohammad Banikazemi 2014-03-06 21:50:18 -05:00
parent 8d7071111e
commit 5d782b33b7
3 changed files with 31 additions and 3 deletions

View 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'

View 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

View 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 = {