Make notifications module use flavor capacity attributes
This makes the notifications module use instance.flavor.$resource instead of instance.$resource. Change-Id: Ic31589aea0a2948179f6b3fb9cb759da4e2a2e78
This commit is contained in:
parent
3b80ed8d1e
commit
c521ba7fa6
@ -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,
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user