diff options
author | Artom Lifshitz <alifshit@redhat.com> | 2021-03-26 12:36:26 -0400 |
---|---|---|
committer | Artom Lifshitz <alifshit@redhat.com> | 2021-04-01 12:20:12 -0400 |
commit | 62868aaac70d908ade6ff80c8ced54afa0435a76 (patch) | |
tree | 4b1edd4724ffba4407ddf92edcbf769785beccb2 | |
parent | fdd96de20d58db3204f5eaee9f9040f0afe7e458 (diff) | |
download | nova-62868aaac70d908ade6ff80c8ced54afa0435a76.tar.gz |
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
-rw-r--r-- | nova/tests/fixtures.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 17c89f4db9..4d1a06f616 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) |