Merge "Implements vcpus counter"

This commit is contained in:
Jenkins 2012-08-01 10:38:22 +00:00 committed by Gerrit Code Review
commit ffa4f93c9c
2 changed files with 19 additions and 4 deletions

View File

@ -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={}),

View File

@ -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')