Fix error that cannot overwrite policy rule for 'forced_host'

When configure 'os_compute_api:servers:create:forced_host' to
'rule:admin_or_owner', but still doesn't allow.
In nova/api/openstack/compute/servers.py#L669, the target is
set to '{}' that is not equal None, so then it will not be set
in nova/policy.py#L205.
This patch configures the target param.

Change-Id: I7a563386bd2f5d1930b5eb2cfc00425a19747e24
Closes-Bug: #1894975
(cherry picked from commit fd99a7ca0f)
This commit is contained in:
ericxiett
2020-09-11 02:03:47 +00:00
committed by Stephen Finucane
parent 2644290321
commit 35ec9357a1

View File

@@ -660,7 +660,8 @@ class ServersController(wsgi.Controller):
except exception.InvalidInput as err:
raise exc.HTTPBadRequest(explanation=six.text_type(err))
if host or node:
context.can(server_policies.SERVERS % 'create:forced_host', {})
context.can(server_policies.SERVERS % 'create:forced_host',
target=target)
if api_version_request.is_supported(req, min_version='2.74'):
self._process_hosts_for_create(context, target, server_dict,