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
(cherry picked from commit 25200b5a16)
This commit is contained in:
Felipe Reyes 2018-11-08 18:27:46 -03:00
parent d9f9eac0b2
commit ef5e7a36a9
2 changed files with 23 additions and 2 deletions

View File

@ -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 (

View File

@ -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,