]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: pass the right argument during metadata setup
authorarmando-migliaccio <armamig@gmail.com>
Fri, 2 May 2014 21:56:57 +0000 (14:56 -0700)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:54 +0000 (23:06 +0800)
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
(cherry picked from commit a3a8a86d7bccb824725d91735bd032237786f5aa)

neutron/plugins/vmware/dhcp_meta/lsnmanager.py
neutron/tests/unit/vmware/test_dhcpmeta.py

index cc69641e03f389a658abf159e8177c48bf258709..d5ba9db2dbeddb6bda799d3edeac12c8a4391bb3 100644 (file)
@@ -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(
index 8005da942d78abc07c4c2293672005ee0f0dcf15..383833be71b8db9aa931c81f9bf0c1b719731576 100644 (file)
@@ -265,6 +265,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')
@@ -567,14 +568,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 = {