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
This commit is contained in:
ericxiett 2020-09-11 02:03:47 +00:00
parent 4f5f834681
commit fd99a7ca0f
1 changed files with 2 additions and 1 deletions

View File

@ -666,7 +666,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,