Add VIF mac address to fixed_ips in notifications
Currently the payload of the notification only contains fixed_ips from VIFs,
the mac address from VIFs is also a very important information and
should be included with the payload of the notification.
This patch add the VIF mac address to each fixed_ips as a new attribute
named "vif_mac".
Notification will looks like:
u'fixed_ips': [{u'address': u'192.168.44.1',
u'floating_ips': [],
u'label': u'publica',
u'meta': {},
u'type': u'fixed',
u'version': 4,
u'vif_mac': u'fa:16:3e:93:ec:d5'}],
Closes-Bug: #1320374
Change-Id: I071b8fa75fecdae556c7ad72878ca8f86cf57139
This commit is contained in:
committed by
Michael Still
parent
995a7e5e5c
commit
54079687c0
@@ -405,6 +405,7 @@ def info_from_instance(context, instance_ref, network_info,
|
||||
for vif in network_info:
|
||||
for ip in vif.fixed_ips():
|
||||
ip["label"] = vif["network"]["label"]
|
||||
ip["vif_mac"] = vif["address"]
|
||||
fixed_ips.append(ip)
|
||||
instance_info['fixed_ips'] = fixed_ips
|
||||
|
||||
|
||||
@@ -278,6 +278,13 @@ class NotificationsTestCase(test.TestCase):
|
||||
self.assertIn("fixed_ips", info)
|
||||
self.assertEqual(info["fixed_ips"][0]["label"], "test1")
|
||||
|
||||
def test_payload_has_vif_mac_address(self):
|
||||
info = notifications.info_from_instance(self.context, self.instance,
|
||||
self.net_info, None)
|
||||
self.assertIn("fixed_ips", info)
|
||||
self.assertEqual(self.net_info[0]['address'],
|
||||
info["fixed_ips"][0]["vif_mac"])
|
||||
|
||||
def test_send_access_ip_update(self):
|
||||
notifications.send_update(self.context, self.instance, self.instance)
|
||||
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
|
||||
|
||||
Reference in New Issue
Block a user