Return hydrated net info from novanet add/remove_fixed_ip calls

Compute manager expects hydrated network info from network_api

Change-Id: I36e48742144555004cbd1f71429a943c7e2952b0
Closes-bug: #1350846
This commit is contained in:
Oleg Bondarev 2014-07-31 17:59:11 +04:00
parent 717650e785
commit 984f4192ed
2 changed files with 12 additions and 5 deletions

View File

@ -304,7 +304,9 @@ class API(base_api.NetworkAPI):
'rxtx_factor': flavor['rxtx_factor'],
'host': instance['host'],
'network_id': network_id}
return self.network_rpcapi.add_fixed_ip_to_instance(context, **args)
nw_info = self.network_rpcapi.add_fixed_ip_to_instance(
context, **args)
return network_model.NetworkInfo.hydrate(nw_info)
@wrap_check_policy
@base_api.refresh_cache
@ -316,8 +318,9 @@ class API(base_api.NetworkAPI):
'rxtx_factor': flavor['rxtx_factor'],
'host': instance['host'],
'address': address}
return self.network_rpcapi.remove_fixed_ip_from_instance(context,
**args)
nw_info = self.network_rpcapi.remove_fixed_ip_from_instance(
context, **args)
return network_model.NetworkInfo.hydrate(nw_info)
@wrap_check_policy
def add_network_to_project(self, context, project_id, network_uuid=None):

View File

@ -454,11 +454,15 @@ class ApiTestCase(test.TestCase):
mock.patch.object(self.network_api.network_rpcapi, method),
mock.patch.object(self.network_api.network_rpcapi,
'get_instance_nw_info'),
mock.patch.object(network_model.NetworkInfo, 'hydrate'),
) as (
method_mock, nwinfo_mock
method_mock, nwinfo_mock, hydrate_mock
):
method_mock.return_value = network_model.NetworkInfo([])
nw_info = network_model.NetworkInfo([])
method_mock.return_value = nw_info
hydrate_mock.return_value = nw_info
getattr(self.network_api, method)(*args, **kwargs)
hydrate_mock.assert_called_once_with(nw_info)
self.assertFalse(nwinfo_mock.called)
def test_allocate_for_instance_refresh_cache(self):