In the Calico mechanism driver, (I believe) I've handled this problem by hooking self.db.notifier. The mechanism driver does:
if self.db.notifier.__class__ != CalicoNotifierProxy: self.db.notifier = CalicoNotifierProxy(self.db.notifier, self)
and then:
class CalicoNotifierProxy(object): """Proxy pattern class used to intercept security-related notifications from the ML2 plugin. """
def __init__(self, ml2_notifier, calico_driver): self.ml2_notifier = ml2_notifier self.calico_driver = calico_driver
def __getattr__(self, name): return getattr(self.ml2_notifier, name)
def security_groups_rule_updated(self, context, sgids): LOG.info("security_groups_rule_updated: %s %s" % (context, sgids)) self.calico_driver.send_sg_updates(sgids, context) self.ml2_notifier.security_groups_rule_updated(context, sgids)
def security_groups_member_updated(self, context, sgids): LOG.info("security_groups_member_updated: %s %s" % (context, sgids)) self.calico_driver.send_sg_updates(sgids, context) self.ml2_notifier.security_groups_member_updated(context, sgids)
I guess it's clear that this is a fairly hacky solution, and hence just confirms the problem for which this bug exists - but does it help at all as to how the problem might be solved more properly?
(https://github.com/Metaswitch/calico/blob/master/calico/openstack/mech_calico.py)
In the Calico mechanism driver, (I believe) I've handled this problem by hooking self.db.notifier. The mechanism driver does:
if self.db. notifier. __class_ _ != CalicoNotifierP roxy:
self. db.notifier = CalicoNotifierP roxy(self. db.notifier, self)
and then:
class CalicoNotifierP roxy(object) :
"""Proxy pattern class used to intercept security-related notifications
from the ML2 plugin.
"""
def __init__(self, ml2_notifier, calico_driver):
self.ml2_ notifier = ml2_notifier
self.calico_ driver = calico_driver
def __getattr__(self, name): self.ml2_ notifier, name)
return getattr(
def security_ groups_ rule_updated( self, context, sgids):
LOG.info( "security_ groups_ rule_updated: %s %s" % (context, sgids))
self.calico_ driver. send_sg_ updates( sgids, context)
self.ml2_ notifier. security_ groups_ rule_updated( context, sgids)
def security_ groups_ member_ updated( self, context, sgids):
LOG.info( "security_ groups_ member_ updated: %s %s" % (context, sgids))
self.calico_ driver. send_sg_ updates( sgids, context)
self.ml2_ notifier. security_ groups_ member_ updated( context, sgids)
I guess it's clear that this is a fairly hacky solution, and hence just confirms the problem for which this bug exists - but does it help at all as to how the problem might be solved more properly?
(https:/ /github. com/Metaswitch/ calico/ blob/master/ calico/ openstack/ mech_calico. py)