Skip to content

Instantly share code, notes, and snippets.

@gowatana
Created December 1, 2019 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/1862de67dd3620bcdbb84a52c7becaba to your computer and use it in GitHub Desktop.
Save gowatana/1862de67dd3620bcdbb84a52c7becaba to your computer and use it in GitHub Desktop.
ACLIでNIC追加自動化くん(text / bash 編)
#!/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
@gowatana
Copy link
Author

gowatana commented Dec 2, 2019

下記の投稿むけ。

acli で vNIC 追加自動化くん。(Test / Bash 編)
https://blog.ntnx.jp/entry/2019/12/02/000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment