diff options
-rw-r--r-- | func/env_setup.py | 14 | ||||
-rwxr-xr-x | func/fetch_compute_ips.sh | 18 |
2 files changed, 16 insertions, 16 deletions
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<NF;i++)if($i~/\"host[4-5]\"/) {print $(i+1);}}' \ | grep -oP "\d+.\d+.\d+.\d+") -elif[ "$installer_type" == "joid" ]; then +elif [ "$installer_type" == "joid" ]; then echo "not implement now" exit 1 -elif[ "$installer_type" == "foreman" ]; then +elif [ "$installer_type" == "foreman" ]; then echo "not implement now" exit 1 @@ -105,7 +105,7 @@ else error "Installer $installer is not supported by this script" fi -if[ -z $IPS ]; then +if [ -z "$IPS" ]; then error "The compute node $IPS are not up. Please check that the POD is correctly deployed." else echo "-------- all compute node ips: --------" @@ -114,4 +114,4 @@ else echo $IPS fi -exit0 +exit 0 |