Created
December 1, 2019 04:09
-
-
Save gowatana/1862de67dd3620bcdbb84a52c7becaba to your computer and use it in GitHub Desktop.
ACLIでNIC追加自動化くん(text / bash 編)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HELP='Usage: CVM$ bash ./cli-vnic.create.sh VM_LIST_FILE AHV_NETWORK ' | |
VM_LIST_FILE=$1 | |
AHV_NETWORK=$2 | |
CMD_OUTPUT_ONLY_FLG=$3 | |
if [ "$#" -eq 0 ]; then | |
echo $HELP | |
exit 1 | |
fi | |
if [ ! -f "$VM_LIST_FILE" ]; then | |
echo "file VM_LIST_FILE not found."; exit 1 | |
fi | |
if [ -z "$AHV_NETWORK" ]; then | |
echo "file AHV_NETWORK not found."; exit 1 | |
fi | |
cat $VM_LIST_FILE | grep -v -E "^$|#" | while read VM; | |
do | |
echo "---" | |
echo "Create vNIC: $VM `date`" | |
CMD="acli vm.nic_create $VM network=$AHV_NETWORK" | |
if [ "x$CMD_OUTPUT_ONLY_FLG" == "x" ]; then | |
$CMD | |
acli vm.nic_list $VM | |
else | |
echo $CMD | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記の投稿むけ。
acli で vNIC 追加自動化くん。(Test / Bash 編)
https://blog.ntnx.jp/entry/2019/12/02/000000