Skip to content

Commit 202177f

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix delete_network_postcommit KeyError"
2 parents 9c5d087 + c3b3b61 commit 202177f

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
@@ -80,9 +80,9 @@ def create_network_postcommit(self, context):
8080

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

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

172172
if provider_type == 'vlan' and segmentation_id:
173173
# 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)