Adapt monitor to apex 11/60411/2
authorYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
Tue, 31 Jul 2018 03:18:15 +0000 (11:18 +0800)
committerYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
Wed, 1 Aug 2018 09:07:00 +0000 (17:07 +0800)
JIRA:BOTTLENECK-241

Change-Id: Ia44cbb72daaeff51189c182b042bbf4cc76aa02a
Signed-off-by: Yang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
monitor/dispatch/install_clients.py
monitor/monitoring.sh

index ab7d0f5..2617413 100644 (file)
@@ -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
                     )
 
 
index 758f77e..5442d33 100644 (file)
@@ -149,14 +149,13 @@ python ${DISPATCH}/server_ip_configure.py ${MONITOR_CONFIG}/barometer_server.con
 set +e
 # Install on jumpserver
 docker pull opnfv/barometer
-sudo docker run  --name bottlenecks-barometer -d --net=host \
+sudo docker run  --name bottlenecks-barometer -d \
   -v ${MONITOR_CONFIG}/barometer_server.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
   -v ${MONITOR_CONFIG}/barometer_server.conf:/opt/collectd/etc/collectd.conf \
   -v /var/run:/var/run \
   -v /tmp:/tmp \
   --privileged opnfv/barometer /run_collectd.sh
 
-set -e
 # INSTALL BAROMETER + CADVISOR (+ COLLECTD) CLIENTS on COMPUTE/CONTROL NODES
 # Configure IP Address in barometer client configuration
 python ${DISPATCH}/client_ip_configure.py ${MONITOR_CONFIG}/barometer_client.conf