summaryrefslogtreecommitdiff
path: root/hooks
diff options
Diffstat (limited to 'hooks')
-rwxr-xr-xhooks/hooks.py48
1 files changed, 7 insertions, 41 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index fab26b9..275a0ba 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -19,19 +19,19 @@ import sys
import time
try:
- import distro # flake8: noqa
+ import distro
except ImportError:
pip.main(['install', "distro"])
- import distro # flake8: noqa
+ import distro
try:
- import yaml # flake8: noqa
+ import yaml
except ImportError:
if sys.version_info.major == 2:
subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
else:
subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml'])
- import yaml # flake8: noqa
+ import yaml
from os import chmod
from os import remove
@@ -275,7 +275,7 @@ class TimeoutException(Exception):
###############################################################################
# Charm support functions
###############################################################################
-def mongodb_conf(config_data=None): # noqa: C901 is too complex (28)
+def mongodb_conf(config_data=None): # noqa: C901
if config_data is None:
return(None)
config = []
@@ -950,19 +950,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
""" % (cron_runtime, script_filename))
-# We can remove this quirk when charm no longer supports trusty
-def arm64_trusty_quirk():
- arch = subprocess.check_output(['dpkg', '--print-architecture']).decode("utf8").strip()
- if arch != 'arm64':
- return
- if lsb_release()['DISTRIB_CODENAME'] != 'trusty':
- return
- ppa = 'ppa:mongodb-arm64/ppa'
- juju_log("*** Detected trusty/arm64. Archive version contains incomplete "
- "mongodb port, enabling installs from %s ***" % (ppa))
- add_source(ppa)
-
-
###############################################################################
# Hook functions
###############################################################################
@@ -974,16 +961,12 @@ def install_hook():
juju_log("Installing mongodb")
add_source(config('source'), config('key'))
- # Allow users to bypass arm64/trusty workaround by adding their own source
- if config('source') == 'None':
- arm64_trusty_quirk()
-
apt_update(fatal=True)
apt_install(packages=INSTALL_PACKAGES, fatal=True)
-@hooks.hook('config-changed')
-def config_changed(): # noqa: C901 is too complex (17)
+@hooks.hook('config-changed') # noqa: C901
+def config_changed():
juju_log("Entering config_changed")
status_set('maintenance', 'Configuring unit')
config_data = config()
@@ -1131,23 +1114,6 @@ def stop_hook():
return(retVal)
-@hooks.hook('benchmark-relation-joined')
-@hooks.hook('benchmark-relation-changed')
-def benchmark_relation_joined():
- juju_log('benchmark-relation-joined')
- try:
- from charms.benchmark import Benchmark
- except ImportError:
- apt_install('python3-pip', fatal=True)
- import subprocess
- subprocess.check_call(['pip3', 'install', '-U', 'charms.benchmark'])
- from charms.benchmark import Benchmark
-
- # Send a list of benchmark-enabled actions for display in the benchmark-gui
- benchmarks = ['perf']
- Benchmark(benchmarks)
-
-
@hooks.hook('database-relation-joined')
def database_relation_joined():
juju_log("database_relation_joined")