Skip to content

Commit 83ca8b3

Browse files
committed
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 (cherry picked from commit 62868aa)
1 parent a5ce4d8 commit 83ca8b3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

nova/tests/fixtures.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,16 +2034,19 @@ def update_port(self, port_id, body=None):
20342034
# else update the active one
20352035
host, _ = self._get_active_binding(port_id)
20362036

2037-
self._port_bindings[port_id][host] = {
2037+
update = {
20382038
'host': host,
20392039
'status': 'ACTIVE',
2040-
'profile': copy.deepcopy(
2041-
body['port'].get('binding:profile') or {},
2042-
),
2043-
'vif_details': port.get('binding:vif_details') or {},
20442040
'vif_type': port['binding:vif_type'],
20452041
'vnic_type': port['binding:vnic_type'],
20462042
}
2043+
if body['port'].get('binding:profile'):
2044+
update['profile'] = copy.deepcopy(
2045+
body['port']['binding:profile'])
2046+
if body['port'].get('binding:vif_details'):
2047+
update['vif_details'] = copy.deepcopy(
2048+
body['port']['binding:vif_details'])
2049+
self._port_bindings[port_id][host] = update
20472050

20482051
# mark any other active bindings as inactive
20492052
self._activate_port_binding(port_id, host)

0 commit comments

Comments
 (0)