Merge "Return hydrated net info from novanet add/remove_fixed_ip calls"

This commit is contained in:
Jenkins 2014-09-21 04:28:10 +00:00 committed by Gerrit Code Review
commit aff83f6afe
2 changed files with 12 additions and 5 deletions

View File

@ -324,7 +324,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
@ -336,8 +338,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

@ -451,11 +451,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):