~narindergupta/charms/trusty/odl-controller/enabledsfc

« back to all changes in this revision

Viewing changes to hooks/odl_controller_hooks.py

  • Committer: Liam Young
  • Date: 2015-07-22 13:28:25 UTC
  • Revision ID: liam.young@canonical.com-20150722132825-fqw3p56p30ja1ayn
[tribaal, r=gnuoy] Make the charm not care what the name of the archive is (it looks at the decompressed name instead)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
3
import os
4
 
import re
5
4
import shutil
6
5
from subprocess import check_call
7
6
import sys
8
 
import urlparse
9
7
 
10
8
from charmhelpers.core.hookenv import (
11
9
    Hooks,
57
55
 
58
56
    # install opendaylight
59
57
    install_url = config["install-url"]
60
 
    install_remote(install_url, dest="/opt")
61
 
    filename = re.sub("^.*/", "", urlparse.urlparse(install_url)[2])
62
 
    name = re.sub("\.tar\.gz$|\.tar$|\.gz$|\.zip$", "", filename)
 
58
    install_remote(install_url, dest="/opt")  # this extracts the archive too
 
59
 
 
60
    # The extracted dirname. Look at what's on disk instead of mangling, so
 
61
    # the distribution tar.gz's name doesn't matter.
 
62
    name = [f for f in os.listdir("/opt")
 
63
            if f.startswith("distribution-karaf")]
 
64
 
63
65
    if not os.path.exists("/opt/opendaylight-karaf"):
64
66
        os.symlink(name, "/opt/opendaylight-karaf")
 
67
 
65
68
    shutil.copy("files/odl-controller.conf", "/etc/init")
66
69
    adduser("opendaylight", system_user=True)
67
70
    mkdir("/home/opendaylight", owner="opendaylight", group="opendaylight",