summaryrefslogtreecommitdiffstats
path: root/monitor/uninstall.py
diff options
context:
space:
mode:
authorYang Yu <Gabriel.yuyang@huawei.com>2018-05-03 17:12:46 +0800
committerYang Yu <Gabriel.yuyang@huawei.com>2018-05-03 20:13:42 +0800
commit84bcb14fb14401d83e82e00bb13a213f9ecaa923 (patch)
tree9cc60dd135322e9043417c17265b8f4c3a777d35 /monitor/uninstall.py
parentcb67313c1e14b6eca057bdfc7722bc11506b7a2a (diff)
Add unstall script to monitoring
Change-Id: Ia78ede2747fe0be05b4421d67fd1dae022afc30f Signed-off-by: Yang Yu <Gabriel.yuyang@huawei.com>
Diffstat (limited to 'monitor/uninstall.py')
-rw-r--r--monitor/uninstall.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/monitor/uninstall.py b/monitor/uninstall.py
new file mode 100644
index 00000000..3a9cf0c7
--- /dev/null
+++ b/monitor/uninstall.py
@@ -0,0 +1,52 @@
+##############################################################################
+# Copyright (c) 2018 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 yaml
+import os
+import utils.infra_setup.passwordless_SSH.ssh as ssh
+
+LOG = logging.getLogger(__name__)
+DEL_DOCKER_SCRIPT = "/home/opnfv/bottlenecks/docker/docker_cleanup.sh"
+
+
+def ssh_del_docker(docker_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"
+ )
+ with open(DEL_DOCKER_SCRIPT) as stdin_file:
+ ssh_d.run("cat > /etc/docker_cleanup.sh",
+ stdin=stdin_file)
+
+ ssh_d.run("cd /etc/ && bash ./docker_cleanup.sh -d " +
+ docker_name)
+
+
+def local_del_docker(docker_name):
+ os.system('bash ' + DEL_DOCKER_SCRIPT + ' -d ' + docker_name)
+
+
+ssh_del_docker('cadvisor')
+ssh_del_docker('barometer')
+
+local_del_docker('prometheus')
+local_del_docker('cadvisor')
+local_del_docker('barometer')
+local_del_docker('grafana')
+local_del_docker('collectd')