From 7898ea8560477046a0d770d94f0f0f2c8f3f3084 Mon Sep 17 00:00:00 2001 From: "wu.zhihui" Date: Wed, 24 Aug 2016 21:09:02 +0800 Subject: Bugfix: some errors in env_setup.py. Change-Id: Ia9ab50f8990659d4657e67f38ece72d5eb47f4d9 Signed-off-by: wu.zhihui --- func/env_setup.py | 14 +++++++------- func/fetch_compute_ips.sh | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'func') diff --git a/func/env_setup.py b/func/env_setup.py index 1f86f0ea..ea49337d 100644 --- a/func/env_setup.py +++ b/func/env_setup.py @@ -124,19 +124,19 @@ class Env_setup: LOG.info("Fetch compute ips through installer") ips = [] - installer_type = os.environ['INSTALLER_TYPE'] - installer_ip = os.environ['INSTALLER_IP'] - if installer_type.down.lower() != "fuel" or "compass": + installer_type = str(os.environ['INSTALLER_TYPE'].lower()) + installer_ip = str(os.environ['INSTALLER_IP']) + if installer_type not in ["fuel", "compass"]: raise RuntimeError("%s is not supported" % installer_type) - if installer_ip: + if not installer_ip: raise RuntimeError("undefine environment variable INSTALLER_IP") - cmd = "bash ./fetch_compute_ip.sh -i %s -a %s" % \ + cmd = "bash ./func/fetch_compute_ips.sh -i %s -a %s" % \ (installer_type, installer_ip) + LOG.info(cmd) os.system(cmd) home = expanduser("~") - os.chdir(home) - with open("ips.log", "r") as file: + with open(home + "/ips.log", "r") as file: data = file.read() if data: ips.extend(data.rstrip('\n').split('\n')) diff --git a/func/fetch_compute_ips.sh b/func/fetch_compute_ips.sh index c1cc4c6e..ebe817a6 100755 --- a/func/fetch_compute_ips.sh +++ b/func/fetch_compute_ips.sh @@ -41,7 +41,7 @@ verify_connectivity(){ :${DEPLOY_TYPE:=''} #Getoptions -whilegetopts ":d:i:a:h:v" optchar; do +while getopts ":i:a:h:v" optchar; do case "${optchar}" in i) installer_type=${OPTARG} ;; a) installer_ip=${OPTARG} ;; @@ -57,7 +57,7 @@ done installer_type=${installer_type:-$INSTALLER_TYPE} installer_ip=${installer_ip:-$INSTALLER_IP} -if[ -z $installer_type ] || [ -z $installer_ip ]; then +if [ -z $installer_type ] || [ -z $installer_ip ]; then usage exit 2 fi @@ -65,7 +65,7 @@ fi ssh_options="-oUserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" #Start fetching compute ip -if[ "$installer_type" == "fuel" ]; then +if [ "$installer_type" == "fuel" ]; then verify_connectivity $installer_ip env=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ @@ -81,11 +81,11 @@ if[ "$installer_type" == "fuel" ]; then sed 's/ //g') &> /dev/null -elif[ "$installer_type" == "apex" ]; then +elif [ "$installer_type" == "apex" ]; then echo "not implement now" exit 1 -elif[ "$installer_type" == "compass" ]; then +elif [ "$installer_type" == "compass" ]; then # need test verify_connectivity $installer_ip IPS=$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \ @@ -93,11 +93,11 @@ elif[ "$installer_type" == "compass" ]; then | awk -F"," '{for(i=1;i