Last active
January 29, 2020 23:47
-
-
Save gowatana/c84f2df74415515c57ea5cc971917818 to your computer and use it in GitHub Desktop.
Nutanix ストレージ コンテナ削除自動化くん
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 | |
LIST_FILE=$1 | |
DELETE_FLAG=$2 | |
if [ ! -f "$LIST_FILE" ]; then | |
echo "LIST_FILE $LIST_FILE not found." | |
exit 1 | |
fi | |
ncli container list | grep "^\ *Name" | awk '{print $3}' | while read CTR | |
do | |
grep $CTR $LIST_FILE > /dev/null && echo "$CTR => keep" | |
grep $CTR $LIST_FILE > /dev/null || echo "$CTR => delete" | |
if [ "$DELETE_FLAG" == "delete" ]; then | |
grep $CTR $LIST_FILE > /dev/null || ncli container remove name=$CTR | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment