diff --git a/nova/network/base_api.py b/nova/network/base_api.py index dc80dc8b5c74..b9c4e3bd2ed7 100644 --- a/nova/network/base_api.py +++ b/nova/network/base_api.py @@ -17,6 +17,7 @@ import functools import inspect from nova.db import base +from nova import hooks from nova.network import model as network_model from nova.objects import instance_info_cache as info_cache_obj from nova.openstack.common import excutils @@ -27,6 +28,7 @@ from nova.openstack.common import log as logging LOG = logging.getLogger(__name__) +@hooks.add_hook('instance_network_info') def update_instance_cache_with_nw_info(impl, context, instance, nw_info=None, update_cells=True): try: diff --git a/nova/tests/network/test_api.py b/nova/tests/network/test_api.py index 7ecd832b1549..0362a511e2b0 100644 --- a/nova/tests/network/test_api.py +++ b/nova/tests/network/test_api.py @@ -399,3 +399,9 @@ class TestUpdateInstanceCache(test.TestCase): self.instance) db_mock.assert_called_once_with(self.context, self.instance['uuid'], {'network_info': self.nw_json}) + + +class NetworkHooksTestCase(test.BaseHookTestCase): + def test_instance_network_info_hook(self): + info_func = base_api.update_instance_cache_with_nw_info + self.assert_has_hook('instance_network_info', info_func)