Fix quantum notification subscriptions
Correct a problem with the way the notification event_type names were constructed in get_event_types() and ignore delete events for now since they do not include the relevant metadata. Change-Id: I313727203a215118d3b9faabdd3f7600efb7be32 Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
parent
3cdac9f3d0
commit
658ea8ed33
@ -23,6 +23,7 @@
|
|||||||
from ceilometer import counter
|
from ceilometer import counter
|
||||||
from ceilometer import plugin
|
from ceilometer import plugin
|
||||||
from ceilometer.openstack.common import cfg
|
from ceilometer.openstack.common import cfg
|
||||||
|
from ceilometer.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
OPTS = [
|
OPTS = [
|
||||||
@ -34,14 +35,24 @@ OPTS = [
|
|||||||
|
|
||||||
cfg.CONF.register_opts(OPTS)
|
cfg.CONF.register_opts(OPTS)
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NetworkNotificationBase(plugin.NotificationBase):
|
class NetworkNotificationBase(plugin.NotificationBase):
|
||||||
|
|
||||||
|
resource_name = None
|
||||||
|
|
||||||
def get_event_types(self):
|
def get_event_types(self):
|
||||||
return [
|
return [
|
||||||
'%s.create.end' % (self.resource_name, event),
|
'%s.create.end' % (self.resource_name),
|
||||||
'%s.update.end' % (self.resource_name, event),
|
'%s.update.end' % (self.resource_name),
|
||||||
'%s.delete.start' % (self.resource_name, event),
|
# FIXME(dhellmann): Quantum delete notifications do
|
||||||
|
# not include the same metadata as the other messages,
|
||||||
|
# so we ignore them for now. This isn't ideal, since
|
||||||
|
# it may mean we miss charging for some amount of time,
|
||||||
|
# but it is better than throwing away the existing
|
||||||
|
# metadata for a resource when it is deleted.
|
||||||
|
##'%s.delete.start' % (self.resource_name),
|
||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -56,6 +67,7 @@ class NetworkNotificationBase(plugin.NotificationBase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def process_notification(self, message):
|
def process_notification(self, message):
|
||||||
|
LOG.info('network notification %r', message)
|
||||||
message['payload'] = message['payload'][self.resource_name]
|
message['payload'] = message['payload'][self.resource_name]
|
||||||
return [
|
return [
|
||||||
counter.Counter(source='?',
|
counter.Counter(source='?',
|
||||||
|
@ -153,3 +153,21 @@ class TestNotifications(unittest.TestCase):
|
|||||||
v = notifications.Port()
|
v = notifications.Port()
|
||||||
counters = v.process_notification(NOTIFICATION_PORT_UPDATE)
|
counters = v.process_notification(NOTIFICATION_PORT_UPDATE)
|
||||||
self.assertEqual(len(counters), 2)
|
self.assertEqual(len(counters), 2)
|
||||||
|
|
||||||
|
|
||||||
|
class TestEventTypes(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_network(self):
|
||||||
|
v = notifications.Network()
|
||||||
|
events = v.get_event_types()
|
||||||
|
assert events
|
||||||
|
|
||||||
|
def test_subnet(self):
|
||||||
|
v = notifications.Subnet()
|
||||||
|
events = v.get_event_types()
|
||||||
|
assert events
|
||||||
|
|
||||||
|
def test_port(self):
|
||||||
|
v = notifications.Port()
|
||||||
|
events = v.get_event_types()
|
||||||
|
assert events
|
||||||
|
Loading…
Reference in New Issue
Block a user