policy.py (zun-6.0.0) | : | policy.py (zun-7.0.0) | ||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
# | # | |||
# Unless required by applicable law or agreed to in writing, software | # Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
# License for the specific language governing permissions and limitations | # License for the specific language governing permissions and limitations | |||
# under the License. | # under the License. | |||
"""Policy Engine For zun.""" | """Policy Engine For zun.""" | |||
from oslo_log import log as logging | from oslo_log import log as logging | |||
from oslo_policy import opts | ||||
from oslo_policy import policy | from oslo_policy import policy | |||
from oslo_utils import excutils | from oslo_utils import excutils | |||
from zun.common import exception | from zun.common import exception | |||
from zun.common import policies | from zun.common import policies | |||
import zun.conf | import zun.conf | |||
_ENFORCER = None | _ENFORCER = None | |||
CONF = zun.conf.CONF | CONF = zun.conf.CONF | |||
LOG = logging.getLogger(__name__) | LOG = logging.getLogger(__name__) | |||
# TODO(gmann): Remove setting the default value of config policy_file | ||||
# once oslo_policy change the default value to 'policy.yaml'. | ||||
# https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d | ||||
279ab578/oslo_policy/opts.py#L49 | ||||
DEFAULT_POLICY_FILE = 'policy.yaml' | ||||
opts.set_defaults(CONF, DEFAULT_POLICY_FILE) | ||||
# we can get a policy enforcer by this init. | # we can get a policy enforcer by this init. | |||
# oslo policy support change policy rule dynamically. | # oslo policy support change policy rule dynamically. | |||
# at present, policy.enforce will reload the policy rules when it checks | # at present, policy.enforce will reload the policy rules when it checks | |||
# the policy files have been touched. | # the policy files have been touched. | |||
def init(policy_file=None, rules=None, | def init(policy_file=None, rules=None, | |||
default_rule=None, use_conf=True, overwrite=True): | default_rule=None, use_conf=True, overwrite=True): | |||
"""Init an Enforcer class. | """Init an Enforcer class. | |||
:param policy_file: Custom policy file to use, if none is | :param policy_file: Custom policy file to use, if none is | |||
specified, ``conf.policy_file`` will be | specified, ``conf.policy_file`` will be | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 8 lines changed or added |