From d62a89bda4da3d24f09a20e9ba09c9fe80ffd5d9 Mon Sep 17 00:00:00 2001 From: Ilia Abashin Date: Wed, 5 Sep 2018 16:15:32 +0300 Subject: updated calipso installer Change-Id: Ib1b0e13be5f969713d0cd1471cde474de486b458 Signed-off-by: Ilia Abashin --- app/install/calipso-installer.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/install/calipso-installer.py b/app/install/calipso-installer.py index b101907..008ff38 100644 --- a/app/install/calipso-installer.py +++ b/app/install/calipso-installer.py @@ -1,6 +1,6 @@ ############################################################################### -# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # -# and others # +# Copyright (c) 2017-2018 Koren Lev (Cisco Systems), # +# Yaron Yogev (Cisco Systems), Ilia Abashin (Cisco Systems) and others # # # # All rights reserved. This program and the accompanying materials # # are made available under the terms of the Apache License, Version 2.0 # @@ -25,13 +25,11 @@ dockerip = os.popen('ip addr show docker0 | grep "\" | awk \'{ print $2 } local_hostname = dockerip.read().replace("\n", "") C_MONGO_CONFIG = "/local_dir/calipso_mongo_access.conf" -H_MONGO_CONFIG = "/home/calipso/calipso_mongo_access.conf" +H_MONGO_CONFIG = "calipso_mongo_access.conf" PYTHONPATH = "/home/scan/calipso_prod/app" C_LDAP_CONFIG = "/local_dir/ldap.conf" -H_LDAP_CONFIG = "/home/calipso/ldap.conf" -H_DIR="/home/calipso/" +H_LDAP_CONFIG = "ldap.conf" -calipso_volume = {'/home/calipso': {'bind': '/local_dir', 'mode': 'rw'}} RESTART_POLICY = {"Name": "always"} # environment variables definitions @@ -290,7 +288,7 @@ def start_ui(host, dbuser, dbpassword, webport, dbport): root_url = "ROOT_URL=http://{}:{}".format(host, str(webport)) mongo_url = "MONGO_URL=mongodb://{}:{}@{}:{}/calipso" \ .format(dbuser, dbpassword, host, str(dbport)) - ports = {'3000/tcp': webport} + ports = {'4000/tcp': webport} DockerClient.containers.run(image_name, detach=True, name=name, @@ -394,6 +392,12 @@ parser.add_argument("--dbpassword", type=str, default="calipso_default", required=False) +parser.add_argument("--home", + help="Home directory for configuration files " + "(default=/home/calipso)", + type=str, + default="/home/calipso", + required=False) parser.add_argument("--command", help="'start-all' or 'stop-all' the Calipso containers " "(default=None)", @@ -406,7 +410,9 @@ parser.add_argument("--copy", type=str, default=None, required=False) + args = parser.parse_args() +calipso_volume = {args.home: {'bind': '/local_dir', 'mode': 'rw'}} print("\nrunning installer against host:", args.hostname, "\n") @@ -435,15 +441,14 @@ while container != "all" and container not in container_names: # create local directory on host, raise error if it doesn't exists try: - os.makedirs(H_DIR+'log/calipso') + os.makedirs(os.path.join(args.home, 'log/calipso')) except OSError as e: if e.errno != errno.EEXIST: raise # starting the containers per arguments: if action == "start": - # building /home/calipso/calipso_mongo_access.conf and - # /home/calipso/ldap.conf files, per the arguments: + # building mongo.conf and ldap.conf files, per the arguments: calipso_mongo_access_text = \ "server {}\n" \ "user {}\n" \ @@ -466,13 +471,15 @@ if action == "start": "group_member_attribute member" ldap_text = ldap_text.format(LDAP_PWD_ATTRIBUTE, args.hostname, LDAP_USER_PWD_ATTRIBUTE) - print("creating default", H_MONGO_CONFIG, "file...\n") - calipso_mongo_access_file = open(H_MONGO_CONFIG, "w+") + mongo_file_path = os.path.join(args.home, H_MONGO_CONFIG) + print("creating default", mongo_file_path, "file...\n") + calipso_mongo_access_file = open(mongo_file_path, "w+") time.sleep(1) calipso_mongo_access_file.write(calipso_mongo_access_text) calipso_mongo_access_file.close() - print("creating default", H_LDAP_CONFIG, "file...\n") - ldap_file = open(H_LDAP_CONFIG, "w+") + ldap_file_path = os.path.join(args.home, H_LDAP_CONFIG) + print("creating default", ldap_file_path, "file...\n") + ldap_file = open(ldap_file_path, "w+") time.sleep(1) ldap_file.write(ldap_text) ldap_file.close() -- cgit 1.2.3-korg