12
12
UnregisteredHookError,
18
19
from charmhelpers.core.host import (
26
26
from charmhelpers.fetch import apt_install, install_remote
28
from odl_controller_utils import write_mvn_config
28
from odl_controller_utils import write_mvn_config, process_odl_cmds
29
from odl_controller_utils import PROFILES
30
PACKAGES = [ "default-jre-headless", "python-jinja2" ]
31
PACKAGES = ["default-jre-headless", "python-jinja2"]
35
37
@hooks.hook("config-changed")
36
38
@restart_on_change({"/home/opendaylight/.m2/settings.xml": ["odl-controller"]})
37
39
def config_changed():
40
process_odl_cmds(PROFILES[config["profile"]])
41
for r_id in relation_ids("controller-api"):
42
controller_api_joined(r_id)
40
46
@hooks.hook("controller-api-relation-joined")
41
def controller_api_joined():
42
relation_set(port=8181, username="admin", password="admin")
47
def controller_api_joined(r_id=None):
48
relation_set(relation_id=r_id,
49
port=PROFILES[config["profile"]]["port"],
50
username="admin", password="admin")
51
60
install_remote(install_url, dest="/opt")
52
61
filename = re.sub("^.*/", "", urlparse.urlparse(install_url)[2])
53
62
name = re.sub("\.tar\.gz$|\.tar$|\.gz$|\.zip$", "", filename)
54
os.symlink(name, "/opt/opendaylight-karaf")
63
if not os.path.exists("/opt/opendaylight-karaf"):
64
os.symlink(name, "/opt/opendaylight-karaf")
55
65
shutil.copy("files/odl-controller.conf", "/etc/init")
56
66
adduser("opendaylight", system_user=True)
57
mkdir("/home/opendaylight", owner="opendaylight", group="opendaylight", perms=0755)
67
mkdir("/home/opendaylight", owner="opendaylight", group="opendaylight",
58
69
check_call(["chown", "-R", "opendaylight:opendaylight", "/opt/" + name])
59
mkdir("/var/log/opendaylight", owner="opendaylight", group="opendaylight", perms=0755)
70
mkdir("/var/log/opendaylight", owner="opendaylight", group="opendaylight",
63
75
service_start("odl-controller")
64
check_call(["/opt/opendaylight-karaf/bin/client", "-r", "61",
65
"feature:install", "odl-base-all", "odl-aaa-authn",
66
"odl-restconf", "odl-nsf-all", "odl-adsal-northbound",
67
"odl-mdsal-apidocs", "odl-ovsdb-openstack",
68
"odl-ovsdb-northbound", "odl-dlux-core"])
73
81
except UnregisteredHookError as e:
74
82
log("Unknown hook {} - skipping.".format(e))
76
85
@hooks.hook("ovsdb-manager-relation-joined")
77
86
def ovsdb_manager_joined():
78
87
relation_set(port=6640, protocol="tcp")
80
90
@hooks.hook("upgrade-charm")
81
91
def upgrade_charm():