From d12a073815f559651d696892ad313faa15d607fc Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Thu, 2 Jul 2015 23:58:10 +0800 Subject: [PATCH] use graduated oslo.policy - Add oslo.policy to requirements.txt - Remove in-tree copy of oslo.policy Change-Id: Ia6fef939cfe0df33476ccee365934a5d2878f90d Partial-Bug: #1458945 --- nova/tests/unit/policy_fixture.py | 11 +++++------ requirements.txt | 1 + setup.cfg | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nova/tests/unit/policy_fixture.py b/nova/tests/unit/policy_fixture.py index 6b815319b..6ba189190 100644 --- a/nova/tests/unit/policy_fixture.py +++ b/nova/tests/unit/policy_fixture.py @@ -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): diff --git a/requirements.txt b/requirements.txt index 1b9f90413..3845923a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.cfg b/setup.cfg index 72444bbdc..2eea83494 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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