diff options
author | Kaifeng Wang <kaifeng.w@gmail.com> | 2020-10-24 22:05:36 +0800 |
---|---|---|
committer | Kaifeng Wang <kaifeng.w@gmail.com> | 2020-10-24 22:05:36 +0800 |
commit | 91d6426b06376dd6c3b77640e3513ee0b56738cb (patch) | |
tree | 07f283fae5cf59613f7e0bf4e1fc617702656c22 /ironic/api | |
parent | 5e68f7910245408ed0705b1a97fff06676a2a60f (diff) | |
download | ironic-91d6426b06376dd6c3b77640e3513ee0b56738cb.tar.gz |
Fixes empty physical_network is not guarded
An empty physical_network can be set to port and make the port
unusable.
Change-Id: I58cf04839f40922cf0c7ddffc08b843cb3c50e06
Story: 2008279
Task: 41153
Diffstat (limited to 'ironic/api')
-rw-r--r-- | ironic/api/controllers/v1/port.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ironic/api/controllers/v1/port.py b/ironic/api/controllers/v1/port.py index 3f0ae6b47..331adb0af 100644 --- a/ironic/api/controllers/v1/port.py +++ b/ironic/api/controllers/v1/port.py @@ -627,6 +627,11 @@ class PortsController(rest.RestController): "Smart NIC port must have port_id " "and hostname in local_link_connection") + physical_network = pdict.get('physical_network') + if physical_network is not None and not physical_network: + raise exception.Invalid('A non-empty value is required when ' + 'setting physical_network') + create_remotely = api.request.rpcapi.can_send_create_port() if (not create_remotely and pdict.get('portgroup_uuid')): # NOTE(mgoddard): In RPC API v1.41, port creation was moved to the @@ -749,6 +754,12 @@ class PortsController(rest.RestController): raise exception.ClientSideError(msg, status_code=http_client.CONFLICT) + if (api_utils.is_path_updated(patch, '/physical_network') + and rpc_port['physical_network'] is not None + and not rpc_port['physical_network']): + raise exception.Invalid('A non-empty value is required when ' + 'setting physical_network') + notify_extra = {'node_uuid': rpc_node.uuid, 'portgroup_uuid': port.portgroup_uuid} notify.emit_start_notification(context, rpc_port, 'update', |