summaryrefslogtreecommitdiff
path: root/ironic/api/controllers/v1/port.py
diff options
context:
space:
mode:
authorHarald Jensås <hjensas@redhat.com>2020-04-07 15:55:54 +0200
committerHarald Jensås <hjensas@redhat.com>2020-04-08 12:36:29 +0200
commit78f904978db51e330190e5debb49e47580f656ad (patch)
tree71241300f98045ec6c25f7d9799509a10558d4bf /ironic/api/controllers/v1/port.py
parentef3c8ff7998dc9232fc2baa055e621f076c20ad0 (diff)
downloadironic-78f904978db51e330190e5debb49e47580f656ad.tar.gz
Fix AttributeError in check allowed port fields
When the 'local_link_connection' field is None an AttributeError is raised when attempting to get the keys. Add a check for None before trying to get the keys. Closes-Bug: #1871346 Change-Id: I5855aea79d6322f70f95709e1a87b8bda3282435
Diffstat (limited to 'ironic/api/controllers/v1/port.py')
-rw-r--r--ironic/api/controllers/v1/port.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/ironic/api/controllers/v1/port.py b/ironic/api/controllers/v1/port.py
index 141771e11..449c18ca2 100644
--- a/ironic/api/controllers/v1/port.py
+++ b/ironic/api/controllers/v1/port.py
@@ -443,10 +443,10 @@ class PortsController(rest.RestController):
if ('local_link_connection/network_type' in fields
and not api_utils.allow_local_link_connection_network_type()):
raise exception.NotAcceptable()
- if isinstance(fields, dict):
+ if (isinstance(fields, dict)
+ and fields.get('local_link_connection') is not None):
if (not api_utils.allow_local_link_connection_network_type()
- and 'network_type' in fields.get('local_link_connection',
- {}).keys()):
+ and 'network_type' in fields['local_link_connection']):
raise exception.NotAcceptable()
@METRICS.timer('PortsController.get_all')