Monday, February 8, 2021

OCI CLI to List all the Boot Volumes and its LifeCycle State in the Tenancy

OCI CLI to List all the Boot Volumes and its LifeCycle State in the Tenancy

This bash scripts needs the tenancy ID to be updated. It loops through all the compartments and then it all availability-domain ,  then fetches the boot volume details.


ociCompartmentList=$(oci iam compartment list --compartment-id ocid1.tenancy.oc1..aaaa1111222334)
for c in $(echo "$ociCompartmentList" | jq '.data | keys | .[]')
do
 compartment_ocid=$(echo "$ociCompartmentList" | jq -r ".data[$c].\"id\"")
 ociadList=$(oci iam availability-domain list)
 for a in $(echo "$ociadList" | jq '.data | keys | .[]')
 do
  ociAD=$(echo "$ociadList" | jq -r ".data[$a].\"name\"")
  ocibootvList=$(oci bv boot-volume list -c $compartment_ocid --availability-domain $ociAD)
  for i in $(echo "$ocibootvList" | jq '.data | keys | .[]')
  do
  bvName=$(echo "$ocibootvList" | jq -r ".data[$i].\"display-name\"")
  lifecycle=$(echo "$ocibootvList" | jq -r ".data[$i].\"lifecycle-state\"")
  echo "BootVolume : $bvName | LifeCycle: $lifecycle"
  done
 done
done

Boot Volume: ebstestserver-001(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-002(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-003(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-004(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-005(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-006(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-007(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-008(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-009(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-010(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-011(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-012(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-013(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-014(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-015(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-016(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-017(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-018(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-019(Boot Volume)| LifeCycle: RUNNING
Boot Volume: ebstestserver-020(Boot Volume)| LifeCycle: RUNNING
 

Popular Posts