aboutsummaryrefslogtreecommitdiffstats
path: root/qtip/util/env.py
diff options
context:
space:
mode:
authorzhihui wu <zhihui.wu2006+zte@gmail.com>2017-03-15 01:27:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-15 01:27:02 +0000
commitfef1092cdb5a28d8d39eff94dbbd0dd187a16971 (patch)
tree73326cb8c372b6eff1a917806fa20a61299175f7 /qtip/util/env.py
parent23e60e59ea572d5fb5a30f74d5d41bd9fbd8d31a (diff)
parent855ac41c1220daf85717bb48ce2d4d2828109aa5 (diff)
Merge "env cleanup" into stable/danube
Diffstat (limited to 'qtip/util/env.py')
-rw-r--r--qtip/util/env.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/qtip/util/env.py b/qtip/util/env.py
index 24e08658..830c9b38 100644
--- a/qtip/util/env.py
+++ b/qtip/util/env.py
@@ -16,6 +16,10 @@ import time
import paramiko
+from qtip.util.logger import QtipLogger
+
+logger = QtipLogger('ansible_driver').get
+
SCRIPT_DIR = path.join(path.dirname(__file__), path.pardir, 'scripts')
KEYNAME = 'QtipKey'
PRIVATE_KEY = '{0}/qtip/{1}'.format(os.environ['HOME'], KEYNAME)
@@ -185,3 +189,16 @@ class AnsibleEnvSetup(object):
return False
time.sleep(2)
return False
+
+ def cleanup(self):
+ IF_DEBUG = os.getenv('IF_DEBUG')
+
+ if IF_DEBUG:
+ logger.info("DEBUG Mode: please do cleanup by manual.")
+ else:
+ logger.info("Cleanup hostfile and keypair.")
+ clean_file(self.hostfile, self.keypair, self.keypair + '.pub')
+
+ for ip in self.host_ip_list:
+ logger.info("Cleanup authorized_keys from {0}...".format(ip))
+ os.system('bash %s/cleanup_creds.sh {0}'.format(ip))