X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?p=bottlenecks.git;a=blobdiff_plain;f=monitor%2Fdispatch%2Finstall_clients.py;fp=monitor%2Fdispatch%2Finstall_clients.py;h=26174133f8e58b2e662f395618e6c08edeaae306;hp=ab7d0f5a3d24486d27c2fa734aea45e998f36d6b;hb=1296d177d1dc0932369162bfbba2c8f730808479;hpb=a0622be5cc8486bbe8c85b382644277bc408ffda diff --git a/monitor/dispatch/install_clients.py b/monitor/dispatch/install_clients.py index ab7d0f5a..26174133 100644 --- a/monitor/dispatch/install_clients.py +++ b/monitor/dispatch/install_clients.py @@ -65,12 +65,16 @@ def main(): dataMap = yaml.safe_load(f) for x in dataMap: for y in dataMap[x]: + print("Installing {} in: {}".format(INSTALlATION_SCRIPT, y)) + pwd = idkey = '' if (y['role'].lower() == 'controller') or ( y['role'].lower() == 'compute'): ip = str(y['ip']) user = str(y['user']) - pwd = str(y['password']) - idkey = str(y['key_filename']) + if 'password' in y.keys(): + pwd = str(y['password']) + if 'key_filename' in y.keys(): + idkey = str(y['key_filename']) if pwd: ssh_d = ssh.SSH(user, host=ip, password=pwd) @@ -78,18 +82,23 @@ def main(): idkey = "/tmp/id_rsa" ssh_d = ssh.SSH(user, host=ip, key_filename=idkey) status, stdout, stderr = ssh_d.execute( - "cd /etc && mkdir " + CONFIG_DIR + "cd /etc && if [ ! -d " + CONFIG_DIR + + " ]; then sudo mkdir " + CONFIG_DIR + "; fi" ) if status: print Exception( - "Command: \"mkdir {}\".format(CONFIG_DIR) failed.") + "Command: \"mkdir {}\"".format(CONFIG_DIR) + + " failed." + ) logger.info(stdout.splitlines()) if args.CLIENT_CONFIG: with open(args.CLIENT_CONFIG) as stdin_file: - ssh_d.run("cat > " + CONFIG_FILE, + ssh_d.run("sudo sh -c \"cat > " + CONFIG_FILE + + "\"", stdin=stdin_file) with open(args.INSTALlATION_SCRIPT) as stdin_file: - ssh_d.run("cat > " + INSTALlATION_SCRIPT, + ssh_d.run("sudo sh -c \"cat > " + INSTALlATION_SCRIPT + + "\"", stdin=stdin_file) for u in os.uname(): @@ -102,7 +111,7 @@ def main(): ) else: status, stdout, stderr = ssh_d.execute( - "sudo yum install -y docker-io" + "sudo service docker start" ) if status: raise Exception( @@ -110,7 +119,8 @@ def main(): logger.info(stdout.splitlines()) ssh_d.run( - "cd /etc/{}/ && bash ./install.sh".format(CONFIG_DIR) + "cd /etc/{}/ && bash ./install.sh".format(CONFIG_DIR), + raise_on_error=False )