summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/notifications.py7
-rw-r--r--nova/tests/test_notifications.py14
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")