Fix hooks path for all actions

Insert the hooks directory at the beginning of sys.path in order to
make it take precedence over other entries, e.g. in the face of
conflicting charmhelpers packages.

Change-Id: I11e870fff3d590d2ac491292f3f2c68d84a67181
Closes-Bug: 1834254
This commit is contained in:
Peter Sabaini 2019-06-25 17:27:24 +02:00 committed by Alex Kavanagh
parent 2169de6fcd
commit 4a4908160d
4 changed files with 44 additions and 4 deletions

View File

@ -14,9 +14,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
sys.path.append('hooks')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = 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)
import subprocess
from charmhelpers.core import hookenv

View File

@ -14,9 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
sys.path.append('hooks/')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = 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)
from charmhelpers.contrib.openstack.utils import (
do_action_openstack_upgrade,

View File

@ -17,7 +17,16 @@
import os
import sys
sys.path.append('hooks')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = 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)
from charmhelpers.core.hookenv import action_fail
from nova_compute_utils import (

View File

@ -17,7 +17,17 @@ import configparser
import os
import sys
sys.path.append('hooks')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = 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)
import charmhelpers.contrib.openstack.audits as audits
from charmhelpers.contrib.openstack.audits import (