From 25200b5a1611280d5f05854eaeb2d00816428a9f Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 8 Nov 2018 18:27:46 -0300 Subject: [PATCH] Add charmhelpers to sys.path in first position for actions This patch inserts the hooks directory in the first position to always prefer that version over any other available in the system. Change-Id: I8d78f0ef9e11f23224e893178c2cd37fdcc42671 Closes-Bug: 1802182 --- actions/actions.py | 12 +++++++++++- actions/openstack_upgrade.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/actions/actions.py b/actions/actions.py index fd903d83..cff79c8e 100755 --- a/actions/actions.py +++ b/actions/actions.py @@ -3,7 +3,17 @@ import os import sys -sys.path.append('hooks/') +_path = os.path.dirname(os.path.realpath(__file__)) +_hooks_dir = os.path.abspath(os.path.join(_path, "..", "hooks")) + + +def _add_path(path): + if path not in sys.path: + sys.path.insert(1, path) + + +_add_path(_hooks_dir) + from charmhelpers.core.hookenv import action_fail from neutron_utils import ( diff --git a/actions/openstack_upgrade.py b/actions/openstack_upgrade.py index 89b14f11..2da6062a 100755 --- a/actions/openstack_upgrade.py +++ b/actions/openstack_upgrade.py @@ -1,7 +1,18 @@ #!/usr/bin/env python3 +import os import sys -sys.path.append('hooks/') +_path = os.path.dirname(os.path.realpath(__file__)) +_hooks_dir = os.path.abspath(os.path.join(_path, "..", "hooks")) + + +def _add_path(path): + if path not in sys.path: + sys.path.insert(1, path) + + +_add_path(_hooks_dir) + from charmhelpers.contrib.openstack.utils import ( do_action_openstack_upgrade,