From 6492a37e76a82f09b9d34b88d914a91cc6cda59d Mon Sep 17 00:00:00 2001 From: Marcus Furlong Date: Wed, 17 Feb 2016 18:20:05 +1100 Subject: [PATCH] add dryrun and quiet options Change-Id: I95bebc532389208e9e3bbd952095d75bf0dac763 --- nova/auto-fix-quota-all-tenants.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/nova/auto-fix-quota-all-tenants.sh b/nova/auto-fix-quota-all-tenants.sh index 58efb2c..cd0bf5b 100755 --- a/nova/auto-fix-quota-all-tenants.sh +++ b/nova/auto-fix-quota-all-tenants.sh @@ -1,11 +1,35 @@ #!/bin/bash +usage() { + echo "Usage: $0 [-n] [-q]" + echo "-n: Dry Run. Don't update the database" + echo "-q: Quiet mode. Only show incorrect quotas" + exit 1 +} + +while getopts ":nq" opt ; do + case ${opt} in + n) + base_msg="[DRY RUN] " + args="${args} -n" + ;; + q) + args="${args} -q" + ;; + *) + usage + ;; + esac +done + + echo "$(date): Tenant quota correction - started" for x in $(keystone --insecure tenant-list | awk -F' |\ ' '!/^\+/ && !/\ id\ / {print $2}'); do - echo "Correcting quota for tenant $x" - python /root/scripts/auto-fix-quota.py --tenant $x + msg="${base_msg}Correcting quota for tenant ${x}" + echo ${msg} + python ./auto-fix-quota.py ${args} --tenant ${x} done echo "$(date): Tenant quota correction - finished"