summaryrefslogtreecommitdiffstats
path: root/monitor/dispatch/install_clients.py
diff options
context:
space:
mode:
authorYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>2018-11-29 08:33:03 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-11-29 08:33:03 +0000
commit1296d177d1dc0932369162bfbba2c8f730808479 (patch)
tree372d4b1a5f6a1d9cb5e1bc4cea35c7740773b12d /monitor/dispatch/install_clients.py
parenta0622be5cc8486bbe8c85b382644277bc408ffda (diff)
parent328beca9b53e95d4f06c1cb117b33893c9c93ff5 (diff)
Merge "Adapt monitor to apex"
Diffstat (limited to 'monitor/dispatch/install_clients.py')
-rw-r--r--monitor/dispatch/install_clients.py26
1 files changed, 18 insertions, 8 deletions
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
)