]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes port update failure when device ID is not updated
authorMithil Arun <arun.mithil@gmail.com>
Tue, 8 Jul 2014 13:08:04 +0000 (18:38 +0530)
committerMithil Arun <arun.mithil@gmail.com>
Wed, 16 Jul 2014 08:34:50 +0000 (14:04 +0530)
The updation was failing because the changed_device_id variable
was undeclared.This fix declares the variable with a default value
at the beginning of the method.

Change-Id: I06dfea1170a6b2a649f4e1efe4bf70b7cee0eacb
Closes-Bug: 1337787

neutron/db/db_base_plugin_v2.py
neutron/tests/unit/test_db_plugin.py

index 4d804f559d896f9063fb43401d7e8fb6c003001f..4c2994edb9540816ed6aa336acb81e3794325986 100644 (file)
@@ -1469,6 +1469,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
         p = port['port']
 
         changed_ips = False
+        changed_device_id = False
         with context.session.begin(subtransactions=True):
             port = self._get_port(context, id)
             if 'device_owner' in p:
index c196b8afbd0b9d178da56665f15b65bd8b295c5a..93b9b4e3952a89c363fb810a7d2dc0a7f541ebe3 100644 (file)
@@ -1105,6 +1105,14 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
                             neutron_context=neutron_context)
         self.assertEqual(port['port']['admin_state_up'], False)
 
+    def test_update_device_id_unchanged(self):
+        with self.port() as port:
+            data = {'port': {'admin_state_up': True,
+                             'device_id': port['port']['device_id']}}
+            req = self.new_update_request('ports', data, port['port']['id'])
+            res = self.deserialize(self.fmt, req.get_response(self.api))
+            self.assertEqual(res['port']['admin_state_up'], True)
+
     def test_update_device_id_null(self):
         with self.port() as port:
             data = {'port': {'device_id': None}}