From b9a656aa30df3f7970705fc91fc0d9952390e960 Mon Sep 17 00:00:00 2001 From: Alberto Donato Date: Mon, 2 Nov 2015 14:38:08 +0200 Subject: [PATCH] Add install-origin option. --- config.yaml | 9 +++++++++ hooks/odl_controller_hooks.py | 36 ++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/config.yaml b/config.yaml index 8ad6aa3..dbfb161 100644 --- a/config.yaml +++ b/config.yaml @@ -13,6 +13,15 @@ options: type: string default: "https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.2-Helium-SR2/distribution-karaf-0.2.2-Helium-SR2.tar.gz" description: Web addressable location of OpenDayLight binaries to install + install-origin: + type: string + default: "" + description: | + Repository to install OpenDaylight binaries from. It can be a full APT + URL or a PPA. + + If not specified, the package is installed from the URL specified by the + 'install-url' option. http-proxy: type: string default: diff --git a/hooks/odl_controller_hooks.py b/hooks/odl_controller_hooks.py index ca563e8..1245641 100755 --- a/hooks/odl_controller_hooks.py +++ b/hooks/odl_controller_hooks.py @@ -21,12 +21,14 @@ from charmhelpers.core.host import ( service_start ) -from charmhelpers.fetch import apt_install, install_remote +from charmhelpers.fetch import ( + add_source, apt_update, apt_install, install_remote) from odl_controller_utils import write_mvn_config, process_odl_cmds from odl_controller_utils import PROFILES PACKAGES = ["default-jre-headless", "python-jinja2"] +KARAF_PACKAGE = "opendaylight-karaf" hooks = Hooks() config = config() @@ -50,20 +52,28 @@ def controller_api_joined(r_id=None): @hooks.hook() def install(): - # install dependencies + packages = PACKAGES.copy() + + install_origin = config["install-origin"] + if install_origin: + add_source(install_origin) + packages.append(KARAF_PACKAGE) + apt_update(fatal=True) + + # install packages apt_install(PACKAGES, fatal=True) - # install opendaylight - install_url = config["install-url"] - install_remote(install_url, dest="/opt") # this extracts the archive too - - # The extracted dirname. Look at what's on disk instead of mangling, so - # the distribution tar.gz's name doesn't matter. - name = [f for f in os.listdir("/opt") - if f.startswith("distribution-karaf")][0] - - if not os.path.exists("/opt/opendaylight-karaf"): - os.symlink(name, "/opt/opendaylight-karaf") + if not install_origin: + # install opendaylight from tarball + install_url = config["install-url"] + # this extracts the archive too + install_remote(install_url, dest="/opt") + # The extracted dirname. Look at what's on disk instead of mangling, so + # the distribution tar.gz's name doesn't matter. + name = [f for f in os.listdir("/opt") + if f.startswith("distribution-karaf")][0] + if not os.path.exists("/opt/opendaylight-karaf"): + os.symlink(name, "/opt/opendaylight-karaf") shutil.copy("files/odl-controller.conf", "/etc/init") adduser("opendaylight", system_user=True)