diff options
author | Drew Freiberger <drew.freiberger@canonical.com> | 2020-07-24 03:54:33 +0000 |
---|---|---|
committer | Canonical IS Mergebot <canonical-is-mergebot@canonical.com> | 2020-07-24 03:54:33 +0000 |
commit | 92a24f9739e46b8ac0cd09609ae0d763f0ae31ec (patch) | |
tree | 4518d1c5387d7a558189b7d01ec116a9208e64af | |
parent | 1ef9f20cfcdec9a97e013eff3897a85307ba3f0f (diff) | |
parent | 1881adcb113dacd0ba1a99e9544ce32b6e9c4e34 (diff) |
Add python3-pip to install hook to support trusty fresh installs.
Reviewed-on: https://code.launchpad.net/~afreiberger/charm-mongodb/+git/mongodb-charm/+merge/387959 Reviewed-by: Xav Paice <xav.paice@canonical.com> Reviewed-by: Giuseppe Petralia <giuseppe.petralia@canonical.com>
-rwxr-xr-x | hooks/hooks.py | 25 | ||||
-rwxr-xr-x | hooks/install | 2 |
2 files changed, 16 insertions, 11 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py index 275a0ba..0c7798b 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -9,7 +9,6 @@ import collections import distutils import json import os -import pip import pprint import re import signal @@ -19,13 +18,7 @@ import sys import time try: - import distro -except ImportError: - pip.main(['install', "distro"]) - import distro - -try: - import yaml + import yaml # flake8: noqa except ImportError: if sys.version_info.major == 2: subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml']) @@ -92,6 +85,18 @@ except ImportError: from pymongo import MongoClient from pymongo.errors import OperationFailure +try: + import pip # flake8: noqa +except ImportError: + apt_install('python3-pip', fatal=True) + import pip # flake8: noqa + +try: + import distro # flake8: noqa +except ImportError: + pip.main(['install', "distro"]) + import distro # flake8: noqa + from charmhelpers.contrib.charmsupport.nrpe import NRPE hooks = Hooks() @@ -965,8 +970,8 @@ def install_hook(): apt_install(packages=INSTALL_PACKAGES, fatal=True) -@hooks.hook('config-changed') # noqa: C901 -def config_changed(): +@hooks.hook('config-changed') +def config_changed(): # noqa: C901 juju_log("Entering config_changed") status_set('maintenance', 'Configuring unit') config_data = config() diff --git a/hooks/install b/hooks/install index baffb57..8a1f051 100755 --- a/hooks/install +++ b/hooks/install @@ -2,7 +2,7 @@ # Wrapper to deal with newer Ubuntu versions that don't have py2 installed # by default. -declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml') +declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'python3-pip') wait_for_dpkg_unlock() { while $(fuser -s /var/lib/dpkg/lock); do sleep .5;done |