From 1baf04d3b5f2348977dc3481fd2dd5fac181d84c Mon Sep 17 00:00:00 2001 From: Rutuja Surve Date: Tue, 14 Nov 2017 04:36:23 +0000 Subject: Cadvisor Client-Server installation automation script JIRA: BOTTLENECK-181 Automated the installation for cadvisor client from jump server host and added docker installation of cadvisor in monitoring script. Change-Id: I906b5237bc0ed320106309c1a29e8dd72a05a427 Signed-off-by: Rutuja Surve --- monitor/automate_cadvisor_client.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 monitor/automate_cadvisor_client.py (limited to 'monitor/automate_cadvisor_client.py') diff --git a/monitor/automate_cadvisor_client.py b/monitor/automate_cadvisor_client.py new file mode 100644 index 00000000..95b98e9d --- /dev/null +++ b/monitor/automate_cadvisor_client.py @@ -0,0 +1,37 @@ +############################################################################## +# Copyright (c) 2017 Huawei Tech and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import logging +import sys +import yaml +sys.path.insert(0, '/home/opnfv/bottlenecks/utils/infra_setup/passwordless_SSH/') +import ssh + +logger = logging.getLogger(__name__) +with open('/tmp/pod.yaml') as f: + dataMap = yaml.safe_load(f) + for x in dataMap: + for y in dataMap[x]: + if (y['role']=='Controller') or (y['role']=='Compute'): + ip = str(y['ip']) + user = str(y['user']) + pwd = str(y['password']) + ssh_d = ssh.SSH(user, host= ip, password= pwd) + status, stdout, stderr = ssh_d.execute("cd /etc && mkdir cadvisor-config") + if status: + raise Exception("Command failed with non-zero status.") + logger.info(stdout.splitlines()) + with open("/home/opnfv/bottlenecks/monitor/cadvisor_install.sh") as stdin_file: + ssh_d.run("cat > /etc/cadvisor-config/install.sh", stdin=stdin_file) + status, stdout, stderr = ssh_d.execute("sudo apt-get install docker.io") + if status: + raise Exception("Command for installing docker failed.") + logger.info(stdout.splitlines()) + ssh_d.run("cd /etc/cadvisor-config/ && bash ./install.sh") + -- cgit 1.2.3-korg