aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhihui wu <zhihui.wu2006+zte@gmail.com>2017-03-21 02:12:01 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-21 02:12:01 +0000
commit8438cfd945a9b5e36656e9833f8982fcd6589049 (patch)
tree8abbb3e98e1c047c1413642322685cdb7e221f2f
parent58e0a7a19c009b3de9fb69a5475cf8e8f6e0e494 (diff)
parenteaa225cf0c9b8b7bc63b35acdeef75dbacb8b905 (diff)
Merge "mistaken delete usefuel public key"
-rwxr-xr-xqtip/scripts/cleanup_creds.sh4
-rw-r--r--qtip/util/env.py18
2 files changed, 14 insertions, 8 deletions
diff --git a/qtip/scripts/cleanup_creds.sh b/qtip/scripts/cleanup_creds.sh
index 1a7ddc1a..ad66ba95 100755
--- a/qtip/scripts/cleanup_creds.sh
+++ b/qtip/scripts/cleanup_creds.sh
@@ -10,11 +10,11 @@
DEST_IP=$1
PRIVATE_KEY=$2
-HOSTNAME=$(hostname)
+PUBLIC_KEY=$3
sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
case "$INSTALLER_TYPE" in
fuel)
- ssh $sshoptions -i $PRIVATE_KEY root@$DEST_IP "sed -i '/root@$HOSTNAME/d' /root/.ssh/authorized_keys"
+ ssh $sshoptions -i $PRIVATE_KEY root@$DEST_IP "sed -i '/$PUBLIC_KEY/d' /root/.ssh/authorized_keys"
;;
esac
diff --git a/qtip/util/env.py b/qtip/util/env.py
index ab9ffa7a..9299f8c0 100644
--- a/qtip/util/env.py
+++ b/qtip/util/env.py
@@ -94,7 +94,8 @@ class AnsibleEnvSetup(object):
if not all_files_exist(PRIVATE_KEY, PUBLIC_KEY):
logger.info("Generate default keypair {0} under "
"{1}".format(KEYNAME, os.environ['HOME']))
- cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048'''.format(PRIVATE_KEY)
+ cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048
+ -C qtip@insecure'''.format(PRIVATE_KEY)
os.system(cmd)
self.keypair['private'] = PRIVATE_KEY
self.keypair['public'] = PUBLIC_KEY
@@ -195,11 +196,16 @@ class AnsibleEnvSetup(object):
if CI_DEBUG is not None and CI_DEBUG.lower() == 'true':
logger.info("DEBUG Mode: please do cleanup by manual.")
else:
- for ip in self.host_ip_list:
- logger.info("Cleanup authorized_keys from {0}...".format(ip))
- cmd = 'bash {0}/cleanup_creds.sh {1} {2}'.format(
- SCRIPT_DIR, ip, self.keypair['private'])
- os.system(cmd)
+ with open(self.keypair['public'], 'r') as f:
+ key = f.read().strip('\n').replace('/', '\/')
+ if key:
+ for ip in self.host_ip_list:
+ logger.info("Cleanup authorized_keys from {0}...".format(ip))
+ cmd = '''bash {0}/cleanup_creds.sh {1} {2} "{3}"'''.format(
+ SCRIPT_DIR, ip, self.keypair['private'], key)
+ os.system(cmd)
+ else:
+ logger.error("Nothing in public key file.")
logger.info("Cleanup hostfile and keypair.")
clean_file(self.hostfile,