]> 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)
committerarmando-migliaccio <armamig@gmail.com>
Fri, 2 May 2014 21:56:57 +0000 (14:56 -0700)
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

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 31cb01da8257a57b7b310d760136ed0aaa6f2875..9fa5a5bc463c7d9fb77159149fa27353c2a27350 100644 (file)
@@ -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 = {