Comment 14 for bug 1444112

Revision history for this message
Nell Jerram (neil-jerram) wrote :

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)