Send port ID in network-changed event to Nova
When Nova gets a network-changed event, it rebuilds the entire network info cache for the instance if it does not have a specific port ID. This can be costly and redundant when performing something like a live migration with multiple ports attached to the same instance. This change simply adds the port ID to the network-changed event since we have it in scope. Nova can use it or not, but at least the information is provided for context. Change-Id: Ifdaef05208d09ddd9587fed6214cf388e5265ba4 Closes-Bug: #1691602
This commit is contained in:
parent
ced89e3329
commit
bf8e6007cf
|
@ -86,9 +86,10 @@ class Notifier(object):
|
|||
pass
|
||||
return False
|
||||
|
||||
def _get_network_changed_event(self, device_id):
|
||||
def _get_network_changed_event(self, port):
|
||||
return {'name': 'network-changed',
|
||||
'server_uuid': device_id}
|
||||
'server_uuid': port['device_id'],
|
||||
'tag': port['id']}
|
||||
|
||||
def _get_port_delete_event(self, port):
|
||||
return {'server_uuid': port['device_id'],
|
||||
|
@ -158,7 +159,7 @@ class Notifier(object):
|
|||
if action == 'delete_port':
|
||||
return self._get_port_delete_event(port)
|
||||
else:
|
||||
return self._get_network_changed_event(port['device_id'])
|
||||
return self._get_network_changed_event(port)
|
||||
|
||||
def _can_notify(self, port):
|
||||
if not port.id:
|
||||
|
|
|
@ -40,7 +40,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
def get_port(self, context, port_id):
|
||||
device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
|
||||
return {'device_id': device_id,
|
||||
'device_owner': DEVICE_OWNER_COMPUTE}
|
||||
'device_owner': DEVICE_OWNER_COMPUTE,
|
||||
'id': port_id}
|
||||
|
||||
self.nova_notifier = nova.Notifier()
|
||||
directory.add_plugin(n_const.CORE, FakePlugin())
|
||||
|
@ -144,7 +145,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
'device_id': device_id}}
|
||||
|
||||
expected_event = {'server_uuid': device_id,
|
||||
'name': 'network-changed'}
|
||||
'name': 'network-changed',
|
||||
'tag': returned_obj['port']['id']}
|
||||
event = self.nova_notifier.create_port_changed_event('update_port',
|
||||
{}, returned_obj)
|
||||
self.assertEqual(event, expected_event)
|
||||
|
@ -155,7 +157,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
{'port_id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222'}}
|
||||
|
||||
expected_event = {'server_uuid': device_id,
|
||||
'name': 'network-changed'}
|
||||
'name': 'network-changed',
|
||||
'tag': returned_obj['floatingip']['port_id']}
|
||||
event = self.nova_notifier.create_port_changed_event(
|
||||
'create_floatingip', {}, returned_obj)
|
||||
self.assertEqual(event, expected_event)
|
||||
|
@ -174,7 +177,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
{'port_id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222'}}
|
||||
|
||||
expected_event = {'server_uuid': device_id,
|
||||
'name': 'network-changed'}
|
||||
'name': 'network-changed',
|
||||
'tag': returned_obj['floatingip']['port_id']}
|
||||
event = self.nova_notifier.create_port_changed_event(
|
||||
'delete_floatingip', {}, returned_obj)
|
||||
self.assertEqual(expected_event, event)
|
||||
|
@ -205,7 +209,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
original_obj = {'port_id': None}
|
||||
|
||||
expected_event = {'server_uuid': device_id,
|
||||
'name': 'network-changed'}
|
||||
'name': 'network-changed',
|
||||
'tag': returned_obj['floatingip']['port_id']}
|
||||
event = self.nova_notifier.create_port_changed_event(
|
||||
'update_floatingip', original_obj, returned_obj)
|
||||
self.assertEqual(expected_event, event)
|
||||
|
@ -216,7 +221,8 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
original_obj = {'port_id': '5a39def4-3d3f-473d-9ff4-8e90064b9cc1'}
|
||||
|
||||
expected_event = {'server_uuid': device_id,
|
||||
'name': 'network-changed'}
|
||||
'name': 'network-changed',
|
||||
'tag': original_obj['port_id']}
|
||||
|
||||
event = self.nova_notifier.create_port_changed_event(
|
||||
'update_floatingip', original_obj, returned_obj)
|
||||
|
|
Loading…
Reference in New Issue