diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index 00a1845f..f87c9b67 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -70,30 +70,30 @@ class NetworkNotificationBase(plugin.NotificationBase): def process_notification(self, message): LOG.info('network notification %r', message) message['payload'] = message['payload'][self.resource_name] - return [ - counter.Counter(source='?', - name=self.resource_name, - type=counter.TYPE_GAUGE, - volume=1, - user_id=message['_context_user_id'], - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['id'], - timestamp=message['timestamp'], - resource_metadata=self.notification_to_metadata( - message), - ), - counter.Counter(source='?', - name=message['event_type'].rpartition('.')[0], - type=counter.TYPE_GAUGE, - volume=1, - user_id=message['_context_user_id'], - project_id=message['payload']['tenant_id'], - resource_id='network', - timestamp=message['timestamp'], - resource_metadata=self.notification_to_metadata( - message), - ), - ] + metadata = self.notification_to_metadata(message) + yield counter.Counter(source='?', + name=self.resource_name, + type=counter.TYPE_GAUGE, + volume=1, + user_id=message['_context_user_id'], + project_id=message['payload']['tenant_id'], + resource_id=message['payload']['id'], + timestamp=message['timestamp'], + resource_metadata=metadata, + ) + + network_counter_name = message['event_type'].rpartition('.')[0] + if network_counter_name != self.resource_name: + yield counter.Counter(source='?', + name=network_counter_name, + type=counter.TYPE_GAUGE, + volume=1, + user_id=message['_context_user_id'], + project_id=message['payload']['tenant_id'], + resource_id=message['payload']['id'], + timestamp=message['timestamp'], + resource_metadata=metadata, + ) class Network(NetworkNotificationBase): diff --git a/doc/source/measurements.rst b/doc/source/measurements.rst index f31097ef..3e8f5fee 100644 --- a/doc/source/measurements.rst +++ b/doc/source/measurements.rst @@ -62,17 +62,17 @@ Network (Quantum) Name Type Volume Resource Note ======================== ========== ======= ======== ======================================================= network Gauge 1 netw ID Duration of network -network.create Gauge 1 network -network.update Gauge 1 network -network.exists Gauge 1 network +network.create Gauge 1 netw ID +network.update Gauge 1 netw ID +network.exists Gauge 1 netw ID subnet Gauge 1 subnt ID Duration of subnet -subnet.create Gauge 1 network -subnet.update Gauge 1 network -subnet.exists Gauge 1 network +subnet.create Gauge 1 subnt ID +subnet.update Gauge 1 subnt ID +subnet.exists Gauge 1 subnt ID port Gauge 1 port ID Duration of port -port.create Gauge 1 network -port.update Gauge 1 network -port.exists Gauge 1 network +port.create Gauge 1 port ID +port.update Gauge 1 port ID +port.exists Gauge 1 port ID floating_ip Gauge 1 ip ID Duration of floating ip ======================== ========== ======= ======== ======================================================= diff --git a/tests/network/test_notifications.py b/tests/network/test_notifications.py index 5b4d5241..05fa1282 100644 --- a/tests/network/test_notifications.py +++ b/tests/network/test_notifications.py @@ -161,27 +161,27 @@ class TestNotifications(unittest.TestCase): def test_network_create(self): v = notifications.Network() counters = v.process_notification(NOTIFICATION_NETWORK_CREATE) - self.assertEqual(len(counters), 2) + self.assertEqual(len(list(counters)), 2) def test_subnet_create(self): v = notifications.Subnet() counters = v.process_notification(NOTIFICATION_SUBNET_CREATE) - self.assertEqual(len(counters), 2) + self.assertEqual(len(list(counters)), 2) def test_port_create(self): v = notifications.Port() counters = v.process_notification(NOTIFICATION_PORT_CREATE) - self.assertEqual(len(counters), 2) + self.assertEqual(len(list(counters)), 2) def test_port_update(self): v = notifications.Port() counters = v.process_notification(NOTIFICATION_PORT_UPDATE) - self.assertEqual(len(counters), 2) + self.assertEqual(len(list(counters)), 2) def test_network_exists(self): v = notifications.Network() counters = v.process_notification(NOTIFICATION_NETWORK_EXISTS) - self.assertEqual(len(counters), 2) + self.assertEqual(len(list(counters)), 1) class TestEventTypes(unittest.TestCase):