-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quotas.sh
More file actions
28 lines (19 loc) · 832 Bytes
/
test_quotas.sh
File metadata and controls
28 lines (19 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
if [ $# -ne 1 ]; then echo "Usage: $0 flavor_name"; exit 1; fi
set -e
. ENV # load openstack environment variables
flavor_cores=`openstack flavor list | grep $1 | awk '{ print $12 }'`
limits=`nova limits 2>/dev/null | grep 'Cores\|Instances'`
all_cores=`echo $limits | awk '{ print $6 }'`
used_cores=`echo $limits | awk '{ print $4 }'`
all_instances=`echo $limits | awk '{ print $13 }'`
used_instances=`echo $limits | awk '{ print $11 }'`
if (( $used_cores + $flavor_cores >= $all_cores )); then
echo "The core limit was reached! Your need to fire $(expr $all_cores - $used_cores + $flavor_cores ) cores. Canceling ...";
exit 0
fi
if (( $used_instances + 1 >= $all_instances )); then
echo "The instance limit was reached. Canceling ...";
exit 0
fi
echo "Everything is fine, the limit is not reached"