diff options
author | 2017-03-11 10:19:21 +0800 | |
---|---|---|
committer | 2017-03-11 10:29:13 +0800 | |
commit | d37dad746e504e833abcf2ae058f2b81e2a9d365 (patch) | |
tree | c856652fad879f5719b79efaa8b25136ab890025 /qtip/util/env.py | |
parent | c5f64d5114be98cbe6a74c2078b22b741ae984a4 (diff) |
env cleanup
If IF_DEBUG is True, there is not cleanup step.
If IF_DEBUG is False, host file and keypair will be
deleted on local and public key will be removed from
remote nodes in the end of test.
Change-Id: I4a88acc2d428e41e4abaedacb011e27468b2cb57
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'qtip/util/env.py')
-rw-r--r-- | qtip/util/env.py | 17 |
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)) |