From 9c5adb0b5dd65834bd135d2b106d8654158151f5 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Tue, 20 Sep 2022 18:51:40 -0300 Subject: [PATCH] Fix neutron plugin get network_type Some neutron integrations might not have the provider:network_type and provider:segmentation_id set in the network information. The plugin is changed to read from dict using get method to avoid key error exception. Closes-bug: #1987315 Change-Id: I9a7460135a0c613c10a91fcef471d4da4f17f041 (cherry picked from commit 48bc4656f8267007a3833c43a8182728582b44e3) (cherry picked from commit df2cc333e6247f1741116567b12875c59194ea1a) --- manila/network/neutron/neutron_network_plugin.py | 6 +++--- ...x-neutron-plugin-invalid-key-dict-68c3d6bcbf2f19f0.yaml | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-neutron-plugin-invalid-key-dict-68c3d6bcbf2f19f0.yaml diff --git a/manila/network/neutron/neutron_network_plugin.py b/manila/network/neutron/neutron_network_plugin.py index 54c28f59d8..7ebdbec6ab 100644 --- a/manila/network/neutron/neutron_network_plugin.py +++ b/manila/network/neutron/neutron_network_plugin.py @@ -398,13 +398,13 @@ class NeutronNetworkPlugin(network.NetworkBaseAPI): "(found: %s)." % (phy, phy_nets)) raise exception.NetworkBadConfigurationException(reason=msg) else: - network_type = net_info['provider:network_type'] - segmentation_id = net_info['provider:segmentation_id'] + network_type = net_info.get('provider:network_type') + segmentation_id = net_info.get('provider:segmentation_id') provider_nw_dict = { 'network_type': network_type, 'segmentation_id': segmentation_id, - 'mtu': net_info['mtu'], + 'mtu': net_info.get('mtu'), } share_network_subnet.update(provider_nw_dict) diff --git a/releasenotes/notes/fix-neutron-plugin-invalid-key-dict-68c3d6bcbf2f19f0.yaml b/releasenotes/notes/fix-neutron-plugin-invalid-key-dict-68c3d6bcbf2f19f0.yaml new file mode 100644 index 0000000000..bf6972c637 --- /dev/null +++ b/releasenotes/notes/fix-neutron-plugin-invalid-key-dict-68c3d6bcbf2f19f0.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Some neutron integrations might not have the network type, so the neutron network + plugin is fixed by taking that scenario in consideration. + `Launchpad bug #1987315 `_ + for more details.