diff --git a/ceilometer/compute/notifications.py b/ceilometer/compute/notifications.py index aa26ac55..501d8ca9 100644 --- a/ceilometer/compute/notifications.py +++ b/ceilometer/compute/notifications.py @@ -54,7 +54,17 @@ class InstanceNotifications(plugin.NotificationBase): volume=message['payload']['memory_mb'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], - resource_id=message['payload']['instance_id'], + resource_id=message['payload']['instance_id'], + timestamp=message['timestamp'], + duration=0, + resource_metadata={}), + counter.Counter(source='?', + name='vcpus', + type='absolute', + volume=message['payload']['vcpus'], + user_id=message['payload']['user_id'], + project_id=message['payload']['tenant_id'], + resource_id=message['payload']['instance_id'], timestamp=message['timestamp'], duration=0, resource_metadata={}), diff --git a/tests/compute/test_notifications.py b/tests/compute/test_notifications.py index 7b0ce304..fdf0bcb4 100644 --- a/tests/compute/test_notifications.py +++ b/tests/compute/test_notifications.py @@ -191,7 +191,7 @@ class TestNotifications(unittest.TestCase): ic = notifications.InstanceNotifications() counters = ic.process_notification(INSTANCE_CREATE_END) - self.assertEqual(len(counters), 2) + self.assertEqual(len(counters), 3) self.assertEqual(counters[0].name, 'instance') self.assertEqual(counters[0].volume, 1) @@ -199,18 +199,23 @@ class TestNotifications(unittest.TestCase): self.assertEqual(counters[1].name, 'memory') self.assertEqual(counters[1].volume, INSTANCE_CREATE_END['payload']['memory_mb']) + self.assertEqual(counters[2].name, 'vcpus') + self.assertEqual(counters[2].volume, INSTANCE_CREATE_END['payload']['vcpus']) + def test_instance_exists(self): ic = notifications.InstanceNotifications() counters = ic.process_notification(INSTANCE_EXISTS) - self.assertEqual(len(counters), 2) + self.assertEqual(len(counters), 3) self.assertEqual(counters[0].name, 'instance') self.assertEqual(counters[1].name, 'memory') + self.assertEqual(counters[2].name, 'vcpus') def test_instance_delete(self): ic = notifications.InstanceNotifications() counters = ic.process_notification(INSTANCE_DELETE_START) - self.assertEqual(len(counters), 2) + self.assertEqual(len(counters), 3) self.assertEqual(counters[0].name, 'instance') self.assertEqual(counters[1].name, 'memory') + self.assertEqual(counters[2].name, 'vcpus')