diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-11 17:15:54 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-11 17:15:54 +0000 |
| commit | 786ec05dec4afc178230b7b66aaf60ed1e8f70de (patch) | |
| tree | 56202ef9d7874a0a1dfb8db7a103e8b4fbdfcb7c | |
| parent | f220bf679086fdb3fbb01fd77fc2bb7234c121fe (diff) | |
| parent | 8f5e83c90e62a6dc6a3397e370e52f724a90939d (diff) | |
Merge "Adds network labels to the fixed ips in usages"
| -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") |
