2121# ###############################################################################
2222usage () {
2323cat 1>&2 << EOF
24- Usage: $( basename $0 ) -i svmID -n volumeName [-r region] [-s size]
24+ Usage: $( basename $0 ) -i svmID -n volumeName [-r region] [-s size] [-w]
2525where
2626 svmID: is the SVM ID in the filesystem you want to create the volume.
2727 volumeName: is the name you want to assign the volume.
2828 region: is the AWS region where the FSxN filesystem resides.
2929 size: is size, in megabytes, you want the filesystem. Default is 20.
30+ -w : wait for the volume to be created before returning.
3031EOF
3132 exit 1
3233}
@@ -42,7 +43,7 @@ size=20
4243region=$( aws configure list | egrep ' ^.*egion ' | awk ' {print $2}' )
4344#
4445# Process command line arguments.
45- while getopts " hi:n:r:s:" option; do
46+ while getopts " hi:n:r:s:w " option; do
4647 case $option in
4748 i) svmId=$OPTARG
4849 ;;
@@ -52,6 +53,8 @@ while getopts "hi:n:r:s:" option; do
5253 ;;
5354 s) size=$OPTARG
5455 ;;
56+ w) wait=1
57+ ;;
5558 * ) usage
5659 ;;
5760 esac
@@ -80,7 +83,18 @@ if [ $? != "0" ]; then
8083else
8184 status=$( jq -r .Volume.Lifecycle $tmpout 2> /dev/null)
8285 if [ " $status " == " CREATING" -o " $status " == " PENDING" ]; then
83- echo " FSxN volume '$volumeName '($( jq -r .Volume.VolumeId $tmpout ) ) is being created."
86+ volumeId=$( jq -r .Volume.VolumeId $tmpout )
87+ echo " FSxN volume '$volumeName '($volumeId ) is being created."
88+ if [ ! -z " $wait " ]; then
89+ echo -n " Waiting for volume to be created."
90+ while [ $status == " CREATING" -o $status == " PENDING" ]; do
91+ sleep 4
92+ aws fsx describe-volumes --volume-ids $volumeId --region=$region --output=json > $tmpout 2>&1
93+ status=$( jq -r .Volumes[0].Lifecycle $tmpout 2> /dev/null)
94+ echo -n " ."
95+ done
96+ printf " \nVolume as been $status .\n"
97+ fi
8498 exit 0
8599 else
86100 echo " Unknown status '$status '. Complete output returned from the AWS api:" 1>&2
0 commit comments