Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
acli で VM 削除自動化くん。(Bash)
#!/bin/bash
KEEP_VM_LIST=$1
DELETE_FLAG=$2
if [ ! -f "$KEEP_VM_LIST" ]; then
echo "KEEP_VM_LIST $KEEP_VM_LIST not found."
exit 1
fi
acli vm.list | grep -E -v "^VM name|^$" | awk '{print $1}' | while read VM
do
grep $VM $KEEP_VM_LIST > /dev/null && echo "$VM => keep"
grep $VM $KEEP_VM_LIST > /dev/null || echo "$VM => delete"
if [ "$DELETE_FLAG" == "delete" ]; then
grep $VM $KEEP_VM_LIST > /dev/null || acli -y vm.delete $VM
fi
done
@gowatana

This comment has been minimized.

Copy link
Owner Author

@gowatana gowatana commented Jan 29, 2020

下記の投稿むけ。

acli で VM 削除自動化くん。(Bash スクリプト編)
https://blog.ntnx.jp/entry/2020/01/30/082317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.