Browse Source

Accept oslopolicy-policy-generator path arguments

The Octavia policy enforcer object used by the oslopolicy-policy-generator
must pass the --config-file or --config-dir command line arguments to
oslo.config, otherwise those arguments are ignored.

Change-Id: Ic638c056715f8fcea3b095726964e7224c38eae2
Task: 37743
Story: 2006983
(cherry picked from commit 8800e85987a7dd4716fb92466f6a4eff9cb08f3b)
changes/33/698433/1
Stefan Nica 2 months ago
parent
commit
5c485a69ac
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      octavia/common/policy.py

+ 12
- 1
octavia/common/policy.py View File

@@ -12,6 +12,8 @@

"""Policy Engine For Octavia."""

import sys

from oslo_config import cfg
from oslo_log import log as logging
from oslo_policy import policy as oslo_policy
@@ -151,5 +153,14 @@ class IsAdminCheck(oslo_policy.Check):

# This is used for the oslopolicy-policy-generator tool
def get_no_context_enforcer():
config.init([])

# oslo.config needs access to the --config-dir and --config-file
# command line args
filtered_args = ['--config-dir', '--config-file']
# Start at 1 because cfg.CONF expects the equivalent of sys.argv[1:]
conf_args = [arg for idx, arg in enumerate(sys.argv[1:])
if (arg in filtered_args or
sys.argv[idx] in filtered_args)]

config.init(conf_args)
return Policy()

Loading…
Cancel
Save