めもぶろぐ

お勉強したこと、趣味なんかを適当に書いてます。。。

ESXi CLIから仮想マシンの起動 ~シェル編~

またへぼいシェルつくりました。

まじで適当です。まえ投稿したCLIからの起動さがしてたらなんだか面倒になったのでシェルを作っておきました。

 

 

chiita01.hatenablog.com

 

~/vmpow.sh

#!/bin/bash
echo "++++++++++++++++++++++++++++++++++++"
echo "+++     Show Virtual Machines    +++"
echo "++++++++++++++++++++++++++++++++++++"
vim-cmd vmsvc/getallvms

echo ""
echo ""
echo "++++++++++++++++++++++++++++++++++++"
echo "+++ You wanna power on or off ?  +++"
echo "++++++++++++++++++++++++++++++++++++"
echo "Input Value on/off"

read selected

echo ""
echo "++++++++++++++++++++++++++++++++++++"
echo "+++ You wanna power on or off ?  +++"
echo "++++++++++++++++++++++++++++++++++++"
echo ""

case $selected in
        "on" )
                echo "Selected Power ON VM !!"
                echo "Input number of VMID above list. "
                read num
                echo "++++++++++++++++++++++++++++++++++++"
                echo "+++   Power ON Target Machine    +++"
                echo "++++++++++++++++++++++++++++++++++++"
                vim-cmd vmsvc/power.on $num
                echo "++++++++++++++++++++++++++++++++++++"
                echo "+++  Target Machine State        +++"
                echo "++++++++++++++++++++++++++++++++++++"
                vim-cmd vmsvc/power.getstate $num;;
        "off" )
                echo "Selected Power OFF VM !!"
                echo "Input number of VMID above list. "
                read num
                echo "++++++++++++++++++++++++++++++++++++"
                echo "+++   Power OFF Target Machine   +++"
                echo "++++++++++++++++++++++++++++++++++++"
                vim-cmd vmsvc/power.off $num
                echo "++++++++++++++++++++++++++++++++++++"
                echo "+++  Target Machine State        +++"
                echo "++++++++++++++++++++++++++++++++++++"

                vim-cmd vmsvc/power.getstate $num
                break;;
esac

echo "++++++++++++++++++++++++++++++++++++"
echo "+++   FINISHED THIS SHELL        +++"
echo "++++++++++++++++++++++++++++++++++++"

 

 

 

manage vm power

 

お、次回のお題決まった

CLIでスナップショットの作成、スナップショット戻しについてですかね

これもシェルを作ります。まあコマンド羅列レベルですけど

 

 

広告を非表示にする