From 0d4d97047cb0c6f3628fc1647b628cce978b2e7c Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 1 Oct 2012 15:36:09 +0200 Subject: [PATCH] network: add counter for actions We also count creation, update and deletion of things. Change-Id: Iccc161a36b6332a077ef6f146e2c84d38f47c316 Signed-off-by: Julien Danjou --- ceilometer/network/notifications.py | 14 +++++++++++++- tests/network/test_notifications.py | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index 64bdf1de0..5c7c67c6a 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -60,7 +60,7 @@ class NetworkNotificationBase(plugin.NotificationBase): return [ counter.Counter(source='?', name=self.resource_name, - type='absolute', + type='gauge', volume=1, user_id=message['_context_user_id'], project_id=message['payload']['tenant_id'], @@ -70,6 +70,18 @@ class NetworkNotificationBase(plugin.NotificationBase): resource_metadata=self.notification_to_metadata( message), ), + counter.Counter(source='?', + name=message['event_type'].rpartition('.')[0], + type='gauge', + volume=1, + user_id=message['_context_user_id'], + project_id=message['payload']['tenant_id'], + resource_id='network', + timestamp=message['timestamp'], + duration=None, + resource_metadata=self.notification_to_metadata( + message), + ), ] diff --git a/tests/network/test_notifications.py b/tests/network/test_notifications.py index 7b1b62e18..71d9268e6 100644 --- a/tests/network/test_notifications.py +++ b/tests/network/test_notifications.py @@ -137,19 +137,19 @@ class TestNotifications(unittest.TestCase): def test_network_create(self): v = notifications.Network() counters = v.process_notification(NOTIFICATION_NETWORK_CREATE) - self.assertEqual(len(counters), 1) + self.assertEqual(len(counters), 2) def test_subnet_create(self): v = notifications.Subnet() counters = v.process_notification(NOTIFICATION_SUBNET_CREATE) - self.assertEqual(len(counters), 1) + self.assertEqual(len(counters), 2) def test_port_create(self): v = notifications.Port() counters = v.process_notification(NOTIFICATION_PORT_CREATE) - self.assertEqual(len(counters), 1) + self.assertEqual(len(counters), 2) def test_port_update(self): v = notifications.Port() counters = v.process_notification(NOTIFICATION_PORT_UPDATE) - self.assertEqual(len(counters), 1) + self.assertEqual(len(counters), 2)