Fixes port update failure when device ID is not updated

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
This commit is contained in:
Mithil Arun 2014-07-08 18:38:04 +05:30
parent 4ce655ae22
commit ee86bf175e
2 changed files with 9 additions and 0 deletions

View 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:

View 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}}