Skip to content

Commit c3b3b61

Browse files
jayofdoomJohn Garbutt
andcommitted
Fix delete_network_postcommit KeyError
Genericswitch driver was failing downstream on delete_network_postcommit with a keyerror for network_type, however testing shows that being more defensive here leads to success in those situations. Co-authored-by: John Garbutt <john.garbutt@gresearch.co.uk> Change-Id: I30b7b3d59db048e8c25917df40637383785590eb
1 parent 5246705 commit c3b3b61

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

networking_generic_switch/generic_switch_mech.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def create_network_postcommit(self, context):
7979

8080
network = context.current
8181
network_id = network['id']
82-
provider_type = network['provider:network_type']
83-
segmentation_id = network['provider:segmentation_id']
84-
physnet = network['provider:physical_network']
82+
provider_type = network.get('provider:network_type')
83+
segmentation_id = network.get('provider:segmentation_id')
84+
physnet = network.get('provider:physical_network')
8585

8686
if provider_type == 'vlan' and segmentation_id:
8787
# Create vlan on all switches from this driver
@@ -164,9 +164,9 @@ def delete_network_postcommit(self, context):
164164
deleted.
165165
"""
166166
network = context.current
167-
provider_type = network['provider:network_type']
168-
segmentation_id = network['provider:segmentation_id']
169-
physnet = network['provider:physical_network']
167+
provider_type = network.get('provider:network_type')
168+
segmentation_id = network.get('provider:segmentation_id')
169+
physnet = network.get('provider:physical_network')
170170

171171
if provider_type == 'vlan' and segmentation_id:
172172
# Delete vlan on all switches from this driver
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fixes:
2+
- |
3+
Instead of always assuming we have all provider network metadata, instead
4+
use a getter to avoid erroring in cases where that metadata may not be needed.

0 commit comments

Comments
 (0)