X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?p=bottlenecks.git;a=blobdiff_plain;f=monitor%2Fautomate_collectd_client.py;h=8358cfc5c0068620afc66f4b12f314ac5518f214;hp=6dd70676f6bb709a314916ecbc02cb06c38f74d7;hb=14add4c9ee3c3114a92ee6c8cf6a6f677ec386a8;hpb=bb0af04f78e264c2500a574e2c48f249a2fa5bd2 diff --git a/monitor/automate_collectd_client.py b/monitor/automate_collectd_client.py index 6dd70676..8358cfc5 100644 --- a/monitor/automate_collectd_client.py +++ b/monitor/automate_collectd_client.py @@ -8,31 +8,40 @@ ############################################################################## import logging -import sys import yaml -sys.path.insert(0, '/home/opnfv/bottlenecks/utils/infra_setup/passwordless_SSH/') -import ssh +import utils.infra_setup.passwordless_SSH.ssh as ssh logger = logging.getLogger(__name__) +collectd_client_install_sh =\ + "/home/opnfv/bottlenecks/monitor/install_collectd_client.sh" +collectd_client_install_conf =\ + "/home/opnfv/bottlenecks/monitor/config/collectd_client.conf" + 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'): + 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") + 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") + with open(collectd_client_install_sh) as stdin_file: + ssh_d.run("cat > /etc/collectd_config/install.sh", + stdin=stdin_file) + with open(collectd_client_install_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") + ssh_d.run("cd /etc/collectd_config/ && bash ./install.sh")