Policyd override implementation

This patchset implements policy overrides for nova-cloud-controler.

This change includes a charm-helpers sync to bring in the policyd helper
code.

Note there are no functional tests for this feature as the charm still
uses the old style non-zaza amulet framework.  The Related-Bug below is
tracking this issue.

Change-Id: Ia5f3f8189d4a7b7b46a827707d964ebe40740aeb
Closes-Bug: #1741723
Related-Bug: #1845639
This commit is contained in:
Alex Kavanagh
2019-09-30 15:47:53 +01:00
parent cbf5b0bff8
commit f7f6fa295c
6 changed files with 90 additions and 6 deletions

View File

@@ -299,10 +299,17 @@ def maybe_do_policyd_overrides(openstack_release,
config = hookenv.config()
try:
if not config.get(POLICYD_CONFIG_NAME, False):
remove_policy_success_file()
clean_policyd_dir_for(service, blacklist_paths)
if (os.path.isfile(_policy_success_file()) and
restart_handler is not None and
callable(restart_handler)):
restart_handler()
remove_policy_success_file()
return
except Exception:
except Exception as e:
print("Exception is: ", str(e))
import traceback
traceback.print_exc()
return
if not is_policyd_override_valid_on_this_release(openstack_release):
return
@@ -348,8 +355,12 @@ def maybe_do_policyd_overrides_on_config_changed(openstack_release,
config = hookenv.config()
try:
if not config.get(POLICYD_CONFIG_NAME, False):
remove_policy_success_file()
clean_policyd_dir_for(service, blacklist_paths)
if (os.path.isfile(_policy_success_file()) and
restart_handler is not None and
callable(restart_handler)):
restart_handler()
remove_policy_success_file()
return
except Exception:
return
@@ -430,8 +441,13 @@ def _yamlfiles(zipfile):
"""
l = []
for infolist_item in zipfile.infolist():
if infolist_item.is_dir():
continue
try:
if infolist_item.is_dir():
continue
except AttributeError:
# fallback to "old" way to determine dir entry for pre-py36
if infolist_item.filename.endswith('/'):
continue
_, name_ext = os.path.split(infolist_item.filename)
name, ext = os.path.splitext(name_ext)
ext = ext.lower()