summaryrefslogtreecommitdiff
path: root/nova/policies
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-07-14 12:32:10 +0000
committerGerrit Code Review <review@openstack.org>2017-07-14 12:32:10 +0000
commit57360fb72addfbc258e5d2145583445b417f3abc (patch)
tree8baa02b8bff0a47d2e9a95f3538adc5f3a41faa1 /nova/policies
parent83e234a6e9bb9f4fda11bcf5f820326482e46b90 (diff)
parent622bba1ab9b17e61bac2b1b135bd6ebafec71a64 (diff)
downloadnova-57360fb72addfbc258e5d2145583445b417f3abc.tar.gz
Merge "Use oslo.polcy DocumentedRuleDefault"
Diffstat (limited to 'nova/policies')
-rw-r--r--nova/policies/base.py35
-rw-r--r--nova/policies/cells_scheduler.py12
2 files changed, 8 insertions, 39 deletions
diff --git a/nova/policies/base.py b/nova/policies/base.py
index 3bc1deb3e8..4c24c97e21 100644
--- a/nova/policies/base.py
+++ b/nova/policies/base.py
@@ -28,39 +28,10 @@ rules = [
]
-def _unwrap_text(text):
-
- def _split_paragraphs(lines):
- output = []
- for line in lines.split('\n'):
- if line:
- output.append(line.strip())
- elif output:
- yield ' '.join(output)
- output = []
-
- if output:
- yield ' '.join(output)
-
- return '\n\n'.join([x for x in _split_paragraphs(text)])
-
-
+# TODO(johngarbutt) we can remove this now
def create_rule_default(name, check_str, description, operations):
- # TODO(sneti): use DocumentedRuleDefault instead of RuleDefault when
- # oslo.policy library is bumped to 1.21.0. The formatted_description hack
- # can be removed then.
- ops = ""
- for operation in operations:
- ops += ('%(method)s %(path)s\n' %
- {'method': operation['method'],
- 'path': operation['path']})
- template = """%(description)s\n\n%(operations)s\n"""
- formatted_description = template % {
- "description": _unwrap_text(description),
- "operations": ops,
- }
-
- return policy.RuleDefault(name, check_str, formatted_description)
+ return policy.DocumentedRuleDefault(name, check_str,
+ description, operations)
def list_rules():
diff --git a/nova/policies/cells_scheduler.py b/nova/policies/cells_scheduler.py
index bc0020c558..06d68bd1bf 100644
--- a/nova/policies/cells_scheduler.py
+++ b/nova/policies/cells_scheduler.py
@@ -13,29 +13,27 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.policies import base
+from oslo_policy import policy
POLICY_ROOT = 'cells_scheduler_filter:%s'
cells_scheduler_policies = [
- base.create_rule_default(
+ policy.RuleDefault(
POLICY_ROOT % 'DifferentCellFilter',
'is_admin:True',
"""Different cell filter to route a build away from a particular cell
This policy is read by nova-scheduler process.
-""",
- []),
- base.create_rule_default(
+"""),
+ policy.RuleDefault(
POLICY_ROOT % 'TargetCellFilter',
'is_admin:True',
"""Target cell filter to route a build to a particular cell
This policy is read by nova-scheduler process.
-""",
- [])
+""")
]