Use openstack resource provider inventory show to get inventory

Under python3, the output of the openstack resource provider
inventory list command is random which breaks how the
_get_inventory_value function is used to store and verify
inventory before and after the upgrade.

This change uses the "openstack resource provider inventory show"
command to target the specific resource class and column value (total)
so we don't have to worry about sort order.

While in here, a comment is left about why we can't do the
same for getting the resource class allocation value.

Change-Id: I1e8dadae631bee87628c5b5390609deb8a1a71e5
Closes-Bug: #1803312
This commit is contained in:
Matt Riedemann 2018-11-14 04:07:59 -05:00
parent db3eef8db9
commit 8afd7beb07
1 changed files with 4 additions and 2 deletions

View File

@ -57,7 +57,7 @@ function _get_inventory_value() {
provider=$(openstack resource provider list -f value | head -n1 | cut -d ' ' -f 1)
# Return the inventory total for $uuid and resource class $key
openstack resource provider inventory list -f value $provider | grep "^$key" | cut -d ' ' -f 3
openstack resource provider inventory show $provider $key -f value -c total
}
function _get_allocation_value() {
@ -67,7 +67,9 @@ function _get_allocation_value() {
consumer="$1"
key="$2"
# Return the allocated amount for $consumer and resource class $key
# Return the allocated amount for $consumer and resource class $key;
# we can't use -c $key here because the resource class amounts are
# dumped in a json blob.
openstack resource provider allocation show -f value $consumer | grep -o ".${key}.: [0-9]*" | cut -d ' ' -f 2
}