use graduated oslo.policy
- Add oslo.policy to requirements.txt - Remove in-tree copy of oslo.policy Change-Id: Ia6fef939cfe0df33476ccee365934a5d2878f90d Partial-Bug: #1458945
This commit is contained in:
parent
15389435aa
commit
d12a073815
@ -16,10 +16,10 @@ import os
|
||||
|
||||
import fixtures
|
||||
from oslo_config import cfg
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from nova.openstack.common import policy as common_policy
|
||||
from nova import paths
|
||||
import nova.policy
|
||||
from nova.tests.unit import fake_policy
|
||||
@ -48,15 +48,14 @@ class RealPolicyFixture(fixtures.Fixture):
|
||||
# policy_file can be overridden by subclasses
|
||||
self.policy_file = paths.state_path_def('etc/nova/policy.json')
|
||||
self._prepare_policy()
|
||||
CONF.set_override('policy_file', self.policy_file)
|
||||
CONF.set_override('policy_file', self.policy_file, group='oslo_policy')
|
||||
nova.policy.reset()
|
||||
nova.policy.init()
|
||||
self.addCleanup(nova.policy.reset)
|
||||
|
||||
def set_rules(self, rules):
|
||||
policy = nova.policy._ENFORCER
|
||||
policy.set_rules({k: common_policy.parse_rule(v)
|
||||
for k, v in rules.items()})
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
|
||||
|
||||
class PolicyFixture(RealPolicyFixture):
|
||||
@ -80,7 +79,7 @@ class PolicyFixture(RealPolicyFixture):
|
||||
'policy.json')
|
||||
with open(self.policy_file, 'w') as f:
|
||||
f.write(fake_policy.policy_data)
|
||||
CONF.set_override('policy_dirs', [])
|
||||
CONF.set_override('policy_dirs', [], group='oslo_policy')
|
||||
|
||||
|
||||
class RoleBasedPolicyFixture(RealPolicyFixture):
|
||||
@ -101,7 +100,7 @@ class RoleBasedPolicyFixture(RealPolicyFixture):
|
||||
self.role = role
|
||||
|
||||
def _prepare_policy(self):
|
||||
policy = jsonutils.load(open(CONF.policy_file))
|
||||
policy = jsonutils.load(open(CONF.oslo_policy.policy_file))
|
||||
|
||||
# Convert all actions to require specified role
|
||||
for action, rule in six.iteritems(policy):
|
||||
|
@ -44,6 +44,7 @@ oslo.utils>=2.8.0 # Apache-2.0
|
||||
oslo.db>=3.2.0 # Apache-2.0
|
||||
oslo.rootwrap>=2.0.0 # Apache-2.0
|
||||
oslo.messaging!=2.8.0,>2.6.1 # Apache-2.0
|
||||
oslo.policy>=0.5.0 # Apache-2.0
|
||||
oslo.i18n>=1.5.0 # Apache-2.0
|
||||
oslo.service>=0.12.0 # Apache-2.0
|
||||
rfc3986>=0.2.0 # Apache-2.0
|
||||
|
@ -36,7 +36,6 @@ oslo.config.opts =
|
||||
nova.scheduler = nova.scheduler.opts:list_opts
|
||||
nova.virt = nova.virt.opts:list_opts
|
||||
nova.openstack.common.memorycache = nova.openstack.common.memorycache:list_opts
|
||||
nova.openstack.common.policy = nova.openstack.common.policy:list_opts
|
||||
|
||||
nova.compute.monitors.cpu =
|
||||
virt_driver = nova.compute.monitors.cpu.virt_driver:Monitor
|
||||
|
Loading…
Reference in New Issue
Block a user