diff options
author | Matt Dietz <matt.dietz@rackspace.com> | 2012-07-10 09:29:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-07-11 16:45:44 +0000 |
commit | 8f5e83c90e62a6dc6a3397e370e52f724a90939d (patch) | |
tree | c6f65bf2475fcf8e496fdc2090ee109c8379b47f | |
parent | 0c8d9c749a5d697c49ba45c08ba716c47809e2ab (diff) | |
download | nova-8f5e83c90e62a6dc6a3397e370e52f724a90939d.tar.gz nova-8f5e83c90e62a6dc6a3397e370e52f724a90939d.tar.xz nova-8f5e83c90e62a6dc6a3397e370e52f724a90939d.zip |
Adds network labels to the fixed ips in usages
Change-Id: Ib5990a7f5d7869c862ec3dd3299772e421574ae6
-rw-r--r-- | nova/notifications.py | 7 | ||||
-rw-r--r-- | nova/tests/test_notifications.py | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/nova/notifications.py b/nova/notifications.py index 7ab0f045b..3a761920c 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -269,7 +269,12 @@ def usage_from_instance(context, instance_ref, network_info, ) if network_info is not None: - usage_info['fixed_ips'] = network_info.fixed_ips() + fixed_ips = [] + for vif in network_info: + for ip in vif.fixed_ips(): + ip["label"] = vif["network"]["label"] + fixed_ips.append(ip) + usage_info['fixed_ips'] = fixed_ips # add image metadata image_meta_props = image_meta(system_metadata) diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py index 1b5a83ef2..59f179bd2 100644 --- a/nova/tests/test_notifications.py +++ b/nova/tests/test_notifications.py @@ -40,13 +40,15 @@ flags.DECLARE('stub_network', 'nova.compute.manager') class NotificationsTestCase(test.TestCase): def setUp(self): + super(NotificationsTestCase, self).setUp() + + self.net_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, + 1, spectacular=True) def fake_get_nw_info(cls, ctxt, instance): self.assertTrue(ctxt.is_admin) - return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1, - spectacular=True) + return self.net_info - super(NotificationsTestCase, self).setUp() self.stubs.Set(nova.network.API, 'get_instance_nw_info', fake_get_nw_info) @@ -198,3 +200,9 @@ class NotificationsTestCase(test.TestCase): # service name should default to 'compute' notif = test_notifier.NOTIFICATIONS[0] self.assertEquals('compute.someotherhost', notif['publisher_id']) + + def test_payload_has_fixed_ip_labels(self): + usage = notifications.usage_from_instance(self.context, self.instance, + self.net_info, None) + self.assertTrue("fixed_ips" in usage) + self.assertEquals(usage["fixed_ips"][0]["label"], "test1") |