Browse Source

Merge "Fix AttributeError in check allowed port fields"

tags/15.0.0
Zuul 3 months ago
committed by Gerrit Code Review
parent
commit
2381c081f0
2 changed files with 12 additions and 3 deletions
  1. +3
    -3
      ironic/api/controllers/v1/port.py
  2. +9
    -0
      ironic/tests/unit/api/controllers/v1/test_port.py

+ 3
- 3
ironic/api/controllers/v1/port.py View File

@@ -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')


+ 9
- 0
ironic/tests/unit/api/controllers/v1/test_port.py View File

@@ -185,6 +185,15 @@ class TestPortsController__CheckAllowedPortFields(base.TestCase):
self.assertFalse(mock_allow_portgroup.called)
mock_allow_physnet.assert_called_once_with()

def test__check_allowed_port_fields_local_link_connection_none_type(
self, mock_allow_port, mock_allow_portgroup, mock_allow_physnet):
mock_allow_port.return_value = True
mock_allow_physnet.return_value = True
self.assertIsNone(
self.controller._check_allowed_port_fields(
{'local_link_connection': None}))
mock_allow_port.assert_called_once_with()


class TestListPorts(test_api_base.BaseApiTest):



Loading…
Cancel
Save