diff options
author | Rutuja Surve <rutuja.r.surve@gmail.com> | 2017-11-03 10:16:23 +0000 |
---|---|---|
committer | Rutuja Surve <rutuja.r.surve@gmail.com> | 2017-11-14 04:31:52 +0000 |
commit | 2b84ec5fef4272cf7df6f9c0ae5fb2c239a5b7cc (patch) | |
tree | 6c33b67ca7c808b3f6fb196c44d811154342edb4 /monitor/automate_collectd_client.py | |
parent | c839c94808a0fa2836c7d18546f32e5a6e24e37b (diff) |
Collectd Client-Server installation automation script
JIRA: BOTTLENECK-181
Automated the installation for collectd client from
jump server host and corrected docker versions in monitoring
script
Change-Id: I14ec20f2761c72e261aa1185a381f0c02b84ed45
Signed-off-by: Rutuja Surve <rutuja.r.surve@gmail.com>
Diffstat (limited to 'monitor/automate_collectd_client.py')
-rw-r--r-- | monitor/automate_collectd_client.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/monitor/automate_collectd_client.py b/monitor/automate_collectd_client.py new file mode 100644 index 00000000..6dd70676 --- /dev/null +++ b/monitor/automate_collectd_client.py @@ -0,0 +1,38 @@ +############################################################################## +# 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 collectd-config") + if status: + raise Exception("Command failed with non-zero status.") + logger.info(stdout.splitlines()) + with open("/home/opnfv/bottlenecks/monitor/install-collectd-client.sh") as stdin_file: + ssh_d.run("cat > /etc/collectd-config/install.sh", stdin=stdin_file) + with open("/home/opnfv/bottlenecks/monitor/config/collectd-client.conf") as stdin_file: + ssh_d.run("cat > /etc/collectd-config/collectd.conf", 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/collectd-config/ && bash ./install.sh") |