From 62868aaac70d908ade6ff80c8ced54afa0435a76 Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Fri, 26 Mar 2021 12:36:26 -0400 Subject: [PATCH] Neutron fixture: don't clobber profile and vif_details if empty Previously, the way Neutron fixture's update_port method was coded would cause the binding:profile and binding:vid_details fields to get clobbered if they were not passed to the update. This was because if nothing was passed, a default of {} was used. This is not how the real Neutron API behaves. If nothing is passed, the previous values remain and are not replaced with {}. This patches fixes this in the Neutron fixture. Change-Id: Ia7ad1322b5a15d1407140c77fe0edb179f66ec7a --- nova/tests/fixtures.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 17c89f4db901..4d1a06f616ce 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -2034,16 +2034,19 @@ class NeutronFixture(fixtures.Fixture): # else update the active one host, _ = self._get_active_binding(port_id) - self._port_bindings[port_id][host] = { + update = { 'host': host, 'status': 'ACTIVE', - 'profile': copy.deepcopy( - body['port'].get('binding:profile') or {}, - ), - 'vif_details': port.get('binding:vif_details') or {}, 'vif_type': port['binding:vif_type'], 'vnic_type': port['binding:vnic_type'], } + if body['port'].get('binding:profile'): + update['profile'] = copy.deepcopy( + body['port']['binding:profile']) + if body['port'].get('binding:vif_details'): + update['vif_details'] = copy.deepcopy( + body['port']['binding:vif_details']) + self._port_bindings[port_id][host] = update # mark any other active bindings as inactive self._activate_port_binding(port_id, host)