From: armando-migliaccio Date: Fri, 2 May 2014 21:56:57 +0000 (-0700) Subject: NSX: pass the right argument during metadata setup X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a3a8a86d7bccb824725d91735bd032237786f5aa;p=openstack-build%2Fneutron-build.git 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 --- diff --git a/neutron/plugins/vmware/dhcp_meta/lsnmanager.py b/neutron/plugins/vmware/dhcp_meta/lsnmanager.py index cc69641e0..d5ba9db2d 100644 --- a/neutron/plugins/vmware/dhcp_meta/lsnmanager.py +++ b/neutron/plugins/vmware/dhcp_meta/lsnmanager.py @@ -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( diff --git a/neutron/tests/unit/vmware/test_dhcpmeta.py b/neutron/tests/unit/vmware/test_dhcpmeta.py index 31cb01da8..9fa5a5bc4 100644 --- a/neutron/tests/unit/vmware/test_dhcpmeta.py +++ b/neutron/tests/unit/vmware/test_dhcpmeta.py @@ -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 = {