Linux下调用govc挂起ESXI并关机的脚本。

#!/bin/bash
export GOVC_URL="https://192.168.1.1"
export GOVC_DATASTORE="NVME"
export GOVC_INSECURE=1
export GOVC_USERNAME="root"
export GOVC_PASSWORD='112233!@#'

# suspend all vms
govc find . -type m -runtime.powerState poweredOn | awk -F '/' '{print $NF}' | xargs -L1 -I {} govc vm.power -suspend {}

# wait all vm exit
for((i=0;i<20;i++)); do
    if ! govc host.esxcli vm process list | grep UUID; then
        break
    fi
    sleep 10
done

govc host.shutdown -f -host.ip 192.168.3.1

#govc host.esxcli system shutdown

https://gitbook.curiouser.top/origin/vsphere-govc.html

原创文学 2022-05-16 15:37:02 通过 网页 浏览(1142)

共有1条评论!

  1. 𓅂𓅂𓅂𓅂𓅂 2022-06-09 20:50:47 1#

    𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂𓅂

发表评论

更换一道题!