diff --git a/hooks/hooks.py b/hooks/hooks.py index 16286924..4187a3ec 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -19,8 +19,7 @@ import utils def install_upstart_scripts(): # Only install upstart configurations for older versions - if ceph.version_compare(ceph.get_ceph_version(), - "0.55.1") < 0: + if ceph.get_ceph_version() < "0.55.1": for x in glob.glob('files/upstart/*.conf'): shutil.copy(x, '/etc/init/') @@ -141,8 +140,7 @@ def osdize(dev): cmd = ['ceph-disk-prepare'] # Later versions of ceph support more options - if ceph.version_compare(ceph.get_ceph_version(), - "0.55") >= 0: + if ceph.get_ceph_version() >= "0.55": osd_format = utils.config_get('osd-format') if osd_format: cmd.append('--fs-type') diff --git a/hooks/utils.py b/hooks/utils.py index 65d18fc2..c21d0d4c 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -11,16 +11,19 @@ import os import subprocess import socket import sys +import re def do_hooks(hooks): hook = os.path.basename(sys.argv[0]) try: - hooks[hook]() + hook_func = hooks[hook] except KeyError: juju_log('INFO', "This charm doesn't know how to handle '{}'.".format(hook)) + else: + hook_func() def install(*pkgs): @@ -88,6 +91,18 @@ def configure_source(): ] subprocess.check_call(cmd) + +def enable_pocket(pocket): + apt_sources = "/etc/apt/sources.list" + with open(apt_sources, "r") as sources: + lines = sources.readlines() + with open(apt_sources, "w") as sources: + for line in lines: + if pocket in line: + sources.write(re.sub('^# deb', 'deb', line)) + else: + sources.write(line) + # Protocols TCP = 'TCP' UDP = 'UDP'