Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active January 29, 2020 23:47
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/c84f2df74415515c57ea5cc971917818 to your computer and use it in GitHub Desktop.
Save gowatana/c84f2df74415515c57ea5cc971917818 to your computer and use it in GitHub Desktop.
Nutanix ストレージ コンテナ削除自動化くん
#!/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