@@ -236,11 +236,11 @@ function take_action_node {
236236 fi
237237 for node in $( $TF state list 2> /dev/null | grep " module.nodes.ibm_pi_instance" | grep " $node_type " ) ; do
238238 instance_name=$( $TF state show " $node " | grep pi_instance_name | awk ' {print $3}' | sed ' s/"//g' )
239- instance_id=$( $CLI_PATH pi instances 2> /dev/null | grep " $instance_name " | awk ' {print $1}' )
239+ instance_id=$( $CLI_PATH pi ins ls 2> /dev/null | grep " $instance_name " | awk ' {print $1}' )
240240 [[ -z $instance_id ]] && continue
241- status=$( $CLI_PATH pi in " $instance_id " 2> /dev/null| grep ' ^Status' | awk ' {print $2}' )
241+ status=$( $CLI_PATH pi ins get " $instance_id " 2> /dev/null| grep ' ^Status' | awk ' {print $2}' )
242242 if [[ $status == " $ALLOWED_STATUS " ]]; then
243- $CLI_PATH pi instance- $instance_action " $instance_id "
243+ $CLI_PATH pi ins action " $instance_id " -o $instance_action
244244 fi
245245 done
246246}
@@ -271,8 +271,8 @@ function reboot_node {
271271 ELAPSED_TIME=$SECONDS
272272 elif [[ $(( SECONDS - ELAPSED_TIME)) -gt $(( REBOOT_TIMEOUT * 60 )) ]]; then
273273 warn " Unable to connect to $NODE . Rebooting the node"
274- instance_id=$( $CLI_PATH pi instances | grep " $NODE " | awk ' {print $1}' )
275- $CLI_PATH pi instance-hard-reboot " $instance_id "
274+ instance_id=$( $CLI_PATH pi ins ls | grep " $NODE " | awk ' {print $1}' )
275+ $CLI_PATH pi ins action " $instance_id " -o hard-reboot
276276 ELAPSED_TIME=$SECONDS
277277 fi
278278}
@@ -378,15 +378,15 @@ function check_bastion {
378378 bothReady=false
379379 fi
380380 instance_name=" ${NAME_PREFIX} bastion-$i "
381- instance_id=$( $CLI_PATH pi instances 2> /dev/null | grep " $instance_name " | awk ' {print $1}' )
382- instance_health_status=$( $CLI_PATH pi instance " $instance_id " 2> /dev/null | grep " ^Health Status" | awk ' {print $3}' )
381+ instance_id=$( $CLI_PATH pi ins ls 2> /dev/null | grep " $instance_name " | awk ' {print $1}' )
382+ instance_health_status=$( $CLI_PATH pi ins get " $instance_id " 2> /dev/null | grep " ^Health Status" | awk ' {print $3}' )
383383 if [[ $instance_health_status == " WARNING" ]]; then
384384 if [[ -z ${BASTION_ELAPSED_TIME[$i]} ]]; then
385385 BASTION_ELAPSED_TIME[$i ]=$SECONDS
386386 PERCENT=$(( PERCENT + 2 ))
387387 elif [[ $(( SECONDS - BASTION_ELAPSED_TIME[i])) -gt $(( REBOOT_TIMEOUT_BASTION * 60 )) ]]; then
388388 warn " Node $instance_name is in WARNING state for more than $REBOOT_TIMEOUT_BASTION mins. Rebooting the node"
389- $CLI_PATH pi instance-hard-reboot " $instance_id "
389+ $CLI_PATH pi ins act " $instance_id " -o hard-reboot
390390 BASTION_ELAPSED_TIME[$i ]=$SECONDS
391391 fi
392392 fi
@@ -494,12 +494,12 @@ function delete_failed_instance {
494494 if ! checkState " module.nodes.ibm_pi_instance.${NODE} [${n} ]" ; then
495495 [[ " $NODE " == " bootstrap" ]] && instance_name=" ${NAME_PREFIX}${NODE} " || instance_name=" ${NAME_PREFIX}${NODE} -$n "
496496 warn " $instance_name : Trying to delete the instance that exist on the cloud when status is not BUILD"
497- instance_id=$( $CLI_PATH pi instances | grep " $instance_name " | awk ' {print $1}' )
498- while [[ $( $CLI_PATH pi instance " $instance_id " | grep " ^Status" | awk ' {print $2}' ) == " BUILD" ]]; do
497+ instance_id=$( $CLI_PATH pi ins ls | grep " $instance_name " | awk ' {print $1}' )
498+ while [[ $( $CLI_PATH pi ins get " $instance_id " | grep " ^Status" | awk ' {print $2}' ) == " BUILD" ]]; do
499499 # Cannot delete instance in BUILD status
500500 sleep 30
501501 done
502- $CLI_PATH pi instance- delete " $instance_id "
502+ $CLI_PATH pi ins delete " $instance_id " --delete-data-volumes
503503 # Some breather for the delete action to complete
504504 sleep 30
505505 fi
@@ -571,8 +571,8 @@ function retry_terraform {
571571 elif grep " ${NAME_PREFIX} pub-net network name already exists for cloud instance" " $LOG_FILE " > /dev/null; then
572572 warn " Trying to delete the existing public network..."
573573 network_name=" ${NAME_PREFIX} pub-net"
574- network_id=$( $CLI_PATH pi networks | grep " $network_name " | awk ' {print $1}' )
575- [[ -n $network_id ]] && $CLI_PATH pi network-delete " $network_id "
574+ network_id=$( $CLI_PATH pi snet ls | grep " $network_name " | awk ' {print $1}' )
575+ [[ -n $network_id ]] && $CLI_PATH pi snet del " $network_id "
576576 fi
577577
578578 # All tries exhausted
@@ -693,10 +693,10 @@ function powervs_login {
693693 debug_switch
694694 $CLI_PATH login --apikey " $IBMCLOUD_API_KEY " -q --no-region > /dev/null
695695 debug_switch
696- CRN=$( $CLI_PATH pi service-list 2> /dev/null | grep " ${SERVICE_INSTANCE_ID} " | awk ' {print $1}' )
696+ CRN=$( $CLI_PATH pi ws ls 2> /dev/null | grep " ${SERVICE_INSTANCE_ID} " | awk ' {print $1}' )
697697 [[ -z $CRN ]] && error " Cannot find PowerVS service instance with ID: $SERVICE_INSTANCE_ID for this account"
698- SVCNAME=$( $CLI_PATH pi service-list | grep " ${SERVICE_INSTANCE_ID} " | awk ' {$1=""; print $0}' | sed ' s/^[ ]*//g' )
699- $CLI_PATH pi service-target " $CRN " 1> /dev/null
698+ SVCNAME=$( $CLI_PATH pi ws ls | grep " ${SERVICE_INSTANCE_ID} " | awk ' {$1=""; print $0}' | sed ' s/^[ ]*//g' )
699+ $CLI_PATH pi ws tg " $CRN " 1> /dev/null
700700 log " Targeting '$SVCNAME ' with Id $CRN "
701701}
702702
@@ -1000,14 +1000,14 @@ function variables {
10001000 $CLI_PATH login --apikey " $IBMCLOUD_API_KEY " -q --no-region > /dev/null
10011001 debug_switch
10021002
1003- ALL_SERVICE_INSTANCE=$( $CLI_PATH pi service-list --json| grep " Name " | cut -f4 -d\" )
1003+ ALL_SERVICE_INSTANCE=$( $CLI_PATH pi ws ls --json| grep " name " | cut -f4 -d\" )
10041004 [ -z " $ALL_SERVICE_INSTANCE " ] && error " No service instance found in your account"
10051005
10061006 question " Select the Service Instance name to use:" " $ALL_SERVICE_INSTANCE "
10071007 service_instance=" $value "
10081008
1009- CRN=$( $CLI_PATH pi service-list 2> /dev/null | grep " ${service_instance} " | awk ' {print $1}' )
1010- $CLI_PATH pi service-target " $CRN "
1009+ CRN=$( $CLI_PATH pi ws ls 2> /dev/null | grep " ${service_instance} " | awk ' {print $1}' )
1010+ $CLI_PATH pi ws tg " $CRN "
10111011
10121012 log " Gathering information from the selected Service Instance... Please wait"
10131013 ZONE=$( echo " $CRN " | cut -f6 -d" :" )
@@ -1016,24 +1016,24 @@ function variables {
10161016
10171017 if [[ $DISPLAY_ALL_IMAGES -eq 1 ]]; then
10181018 # There should be at least 1 RHCOS boot image. Stock CentOS can be used for RHEL/bastion.
1019- BOOT_IMAGES_COUNT=$( $CLI_PATH pi images --json | grep name | cut -f4 -d\" | wc -l)
1019+ BOOT_IMAGES_COUNT=$( $CLI_PATH pi image ls --json | grep name | cut -f4 -d\" | wc -l)
10201020 [[ " $BOOT_IMAGES_COUNT " -lt 1 ]] && error " There should be at least 1 boot image (RHCOS) found 0"
10211021 # Get all catalog and boot images
1022- CATALOG_IMAGES=$( $CLI_PATH pi image-list-catalog --json | grep name | cut -f4 -d\" )
1023- BOOT_IMAGES=$( $CLI_PATH pi images --json | grep name | cut -f4 -d\" )
1022+ CATALOG_IMAGES=$( $CLI_PATH pi image lc --json | grep name | cut -f4 -d\" )
1023+ BOOT_IMAGES=$( $CLI_PATH pi image ls --json | grep name | cut -f4 -d\" )
10241024 RHEL_IMAGES=" ${CATALOG_IMAGES}${IFS}${BOOT_IMAGES} "
10251025 RHCOS_IMAGES=$RHEL_IMAGES
10261026 else
10271027 # Stock CentOS can be used for RHEL/bastion.
1028- CATALOG_RHEL_IMAGES=$( $CLI_PATH pi image-list-catalog --json | grep name | grep -iE ' rhel|centos' | cut -f4 -d\" )
1029- BOOT_IMAGES=$( $CLI_PATH pi images --json | grep name | grep -vi rhcos | cut -f4 -d\" )
1028+ CATALOG_RHEL_IMAGES=$( $CLI_PATH pi image lc --json | grep name | grep -iE ' rhel|centos' | cut -f4 -d\" )
1029+ BOOT_IMAGES=$( $CLI_PATH pi image ls --json | grep name | grep -vi rhcos | cut -f4 -d\" )
10301030 RHEL_IMAGES=" ${CATALOG_RHEL_IMAGES}${IFS}${BOOT_IMAGES} "
1031- RHCOS_IMAGES=$( $CLI_PATH pi images --json | grep name | grep -vi rhel | grep -vi centos | grep -i " rhcos-${RELEASE_VER// .} -" | cut -f4 -d\" )
1031+ RHCOS_IMAGES=$( $CLI_PATH pi image ls --json | grep name | grep -vi rhel | grep -vi centos | grep -i " rhcos-${RELEASE_VER// .} -" | cut -f4 -d\" )
10321032 [[ -z $RHCOS_IMAGES ]] && error " Cannot find RHCOS image for OCP $RELEASE_VER ! Please use option '-all-images' if you have already imported the image"
10331033 fi
10341034
10351035 # FIXME: Filter out only pub-vlan from the list; using grep currently
1036- ALL_NETS=$( $CLI_PATH pi nets --json| grep name | cut -f4 -d\" | grep -v " \-pub-net" || true)
1036+ ALL_NETS=$( $CLI_PATH pi snet ls --json| grep name | cut -f4 -d\" | grep -v " \-pub-net" || true)
10371037 [ -z " $ALL_NETS " ] && error " No private network found"
10381038
10391039 RAW_OCP_VERSIONS=$( curl -skL https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/| grep " $RELEASE_VER " | cut -f2 -d ' >' | cut -f1 -d ' <' | tac)
@@ -1049,7 +1049,7 @@ function variables {
10491049
10501050 [ -z " $ALL_OCP_VERSIONS " ] && error " No OCP versions found for version $RELEASE_VER ... Ensure you have set correct RELEASE_VER"
10511051
1052- ALL_SYSTEM_TYPES=$( $CLI_PATH pi system-pool 2> /dev/null | grep " System Type" | awk ' {print $3}' | sort | uniq)
1052+ ALL_SYSTEM_TYPES=$( $CLI_PATH pi system-pools 2> /dev/null | grep " System Type" | awk ' {print $3}' | sort | uniq)
10531053 [ -z " $ALL_SYSTEM_TYPES " ] && error " Cannot find available System Types... please try again"
10541054
10551055 # TODO: Get region from a map of `zone:region` or any other good way
0 commit comments