NSX: pass the right argument during metadata setup
The NSX cluster was erroneously passed instead of context. This patch addressed that and tweaks UT to verify the right parameter is passed instead. Change-Id: Ife660b3a23705342043d121c7dcecad43e22abc1 Closes-bug: #1315538
This commit is contained in:
parent
3c2f87be9f
commit
12188aa03c
@ -222,7 +222,7 @@ class LsnManager(object):
|
||||
self.cluster, switch_id, tenant_id,
|
||||
const.METADATA_PORT_ID, const.METADATA_PORT_NAME,
|
||||
const.METADATA_DEVICE_ID, True)['uuid']
|
||||
lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
|
||||
lsn_port_id = self.lsn_port_create(context, lsn_id, data)
|
||||
except (n_exc.NotFound, p_exc.NsxPluginException,
|
||||
api_exc.NsxApiException):
|
||||
raise p_exc.PortConfigurationError(
|
||||
|
@ -264,6 +264,7 @@ class LsnManagerTestCase(base.BaseTestCase):
|
||||
self.lsn_port_id = 'foo_lsn_port_id'
|
||||
self.tenant_id = 'foo_tenant_id'
|
||||
self.manager = lsn_man.LsnManager(mock.Mock())
|
||||
self.context = context.get_admin_context()
|
||||
self.mock_lsn_api_p = mock.patch.object(lsn_man, 'lsn_api')
|
||||
self.mock_lsn_api = self.mock_lsn_api_p.start()
|
||||
self.mock_nsx_utils_p = mock.patch.object(lsn_man, 'nsx_utils')
|
||||
@ -565,14 +566,22 @@ class LsnManagerTestCase(base.BaseTestCase):
|
||||
'network_id': self.net_id,
|
||||
'tenant_id': self.tenant_id
|
||||
}
|
||||
expected_data = {
|
||||
'subnet_id': subnet['id'],
|
||||
'ip_address': subnet['cidr'],
|
||||
'mac_address': constants.METADATA_MAC
|
||||
}
|
||||
self.mock_nsx_utils.get_nsx_switch_ids.return_value = [self.switch_id]
|
||||
with mock.patch.object(lsn_man.switch_api, 'create_lport') as f:
|
||||
f.return_value = {'uuid': self.port_id}
|
||||
self.manager.lsn_port_metadata_setup(
|
||||
mock.Mock(), self.lsn_id, subnet)
|
||||
self.assertEqual(1, self.mock_lsn_api.lsn_port_create.call_count)
|
||||
self.mock_lsn_api.lsn_port_plug_network.assert_called_once_with(
|
||||
mock.ANY, self.lsn_id, mock.ANY, self.port_id)
|
||||
with mock.patch.object(self.manager, 'lsn_port_create') as g:
|
||||
f.return_value = {'uuid': self.port_id}
|
||||
self.manager.lsn_port_metadata_setup(
|
||||
self.context, self.lsn_id, subnet)
|
||||
(self.mock_lsn_api.lsn_port_plug_network.
|
||||
assert_called_once_with(mock.ANY, self.lsn_id,
|
||||
mock.ANY, self.port_id))
|
||||
g.assert_called_once_with(
|
||||
self.context, self.lsn_id, expected_data)
|
||||
|
||||
def test_lsn_port_metadata_setup_raise_not_found(self):
|
||||
subnet = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user