Merge "Make notifications module use flavor capacity attributes"

This commit is contained in:
Jenkins
2016-07-20 01:52:04 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 5 deletions

View File

@@ -444,14 +444,14 @@ def info_from_instance(context, instance, network_info,
architecture=instance.architecture,
# Capacity properties
memory_mb=instance.memory_mb,
disk_gb=instance.root_gb + instance.ephemeral_gb,
vcpus=instance.vcpus,
memory_mb=instance.flavor.memory_mb,
disk_gb=instance.flavor.root_gb + instance.flavor.ephemeral_gb,
vcpus=instance.flavor.vcpus,
# Note(dhellmann): This makes the disk_gb value redundant, but
# we are keeping it for backwards-compatibility with existing
# users of notifications.
root_gb=instance.root_gb,
ephemeral_gb=instance.ephemeral_gb,
root_gb=instance.flavor.root_gb,
ephemeral_gb=instance.flavor.ephemeral_gb,
# Location properties
host=instance.host,

View File

@@ -470,6 +470,24 @@ class NotificationsTestCase(test.TestCase):
self.assertIn("progress", info)
self.assertEqual(50, info["progress"])
def test_payload_has_flavor_attributes(self):
# Zero these to make sure they are not used
self.instance.vcpus = self.instance.memory_mb = 0
self.instance.root_gb = self.instance.ephemeral_gb = 0
# Set flavor values and make sure _these_ are present in the output
self.instance.flavor.vcpus = 10
self.instance.flavor.root_gb = 20
self.instance.flavor.memory_mb = 30
self.instance.flavor.ephemeral_gb = 40
info = notifications.info_from_instance(self.context, self.instance,
self.net_info, None)
self.assertEqual(10, info['vcpus'])
self.assertEqual(20, info['root_gb'])
self.assertEqual(30, info['memory_mb'])
self.assertEqual(40, info['ephemeral_gb'])
self.assertEqual(60, info['disk_gb'])
def test_send_access_ip_update(self):
notifications.send_update(self.context, self.instance, self.instance)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))