]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ML2 BigSwitch: Don't modify parent context
authorKevin Benton <blak111@gmail.com>
Tue, 18 Mar 2014 19:11:53 +0000 (12:11 -0700)
committerKevin Benton <blak111@gmail.com>
Tue, 18 Mar 2014 19:15:27 +0000 (12:15 -0700)
Makes a copy of the port context before changing
it in preparation for the backend controller so
other drivers are not affected. Also removes a
UT that was exercising direct modification of VIF
details in the port context, which is not allowed
by the ML2 plugin.

Closes-Bug: #1294308
Change-Id: I47281dcd23c022813b8b6eda0a3d39c4482277b9

neutron/plugins/ml2/drivers/mech_bigswitch/driver.py
neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py

index ced7b37ff1aee4de3304ef4ece4d766e74d2a595..7954b7d374711e84b17389ebe1c4d3eed8524906 100644 (file)
@@ -17,6 +17,7 @@
 #
 # @author: Sumit Naiksatam, sumitnaiksatam@gmail.com, Big Switch Networks, Inc.
 # @author: Kevin Benton, Big Switch Networks, Inc.
+import copy
 
 import eventlet
 from oslo.config import cfg
@@ -94,7 +95,8 @@ class BigSwitchMechanismDriver(NeutronRestProxyV2Base,
         self.servers.rest_delete_port(net["tenant_id"], net["id"], port['id'])
 
     def _prepare_port_for_controller(self, context):
-        port = context.current
+        # make a copy so the context isn't changed for other drivers
+        port = copy.deepcopy(context.current)
         net = context.network.current
         port['network'] = net
         port['binding_host'] = context._binding.host
index c1d3c527797b2f00f1f56e974bd6e1fb9c7a9974..e09c690c7fc00c0ad55274c1489640fc9dda5d37 100644 (file)
@@ -77,18 +77,6 @@ class TestBigSwitchMechDriverPortsV2(test_db_plugin.TestPortsV2,
             self.assertEqual(port['port']['status'], 'DOWN')
             self.assertEqual(self.port_create_status, 'DOWN')
 
-    # exercise the host_id tracking code
-    def test_port_vif_details(self):
-        kwargs = {'name': 'name', 'binding:host_id': 'ivshost',
-                  'device_id': 'override_dev'}
-        with self.port(**kwargs) as port:
-            self.assertEqual(port['port']['binding:vif_type'],
-                             portbindings.VIF_TYPE_IVS)
-        kwargs = {'name': 'name2', 'binding:host_id': 'someotherhost',
-                  'device_id': 'other_dev'}
-        with self.port(**kwargs) as port:
-            self.assertEqual(port['port']['binding:vif_type'], self.VIF_TYPE)
-
     def _make_port(self, fmt, net_id, expected_res_status=None, arg_list=None,
                    **kwargs):
         arg_list = arg_list or ()