Fix fail_if_empty invocation with pipes
* Since $@ parameter may have pipe '|' it should be processed correctly.
Currenly the part before pipe is assigned as $@ so bash runs pipe with
commands after it after execution of function. However, we want to assign
command with pipe to $@ thus "" around command with pipe are required.
* replace $() with eval as $() doesn't work correctly with pipe as it tries to
escape pipe so output variable contains wrong data.
* This patch adds tonumber to first invocation
Change-Id: I958e14c0a4ea4b5782d2c74dc895471b0f70b875
(cherry picked from commit 9a37e5ac42
)
This commit is contained in:
parent
1e14183aa7
commit
85a7c2bea4
@ -59,7 +59,7 @@ function with_backoff {
|
|||||||
# Return 1 if empty output received
|
# Return 1 if empty output received
|
||||||
#######################################
|
#######################################
|
||||||
function fail_if_empty {
|
function fail_if_empty {
|
||||||
local output="$(${@})"
|
local output="$(eval "${@}")"
|
||||||
if [ -z "${output}" ]; then
|
if [ -z "${output}" ]; then
|
||||||
echo "Warning! Empty output for ($@)" 1>&2
|
echo "Warning! Empty output for ($@)" 1>&2
|
||||||
return 1
|
return 1
|
||||||
@ -103,7 +103,11 @@ for role in $OVERCLOUD_ROLES; do
|
|||||||
rg_stack=$(with_backoff fail_if_empty openstack stack resource show $STACK_NAME $role -c physical_resource_id -f value)
|
rg_stack=$(with_backoff fail_if_empty openstack stack resource show $STACK_NAME $role -c physical_resource_id -f value)
|
||||||
done
|
done
|
||||||
|
|
||||||
stacks=$(openstack stack resource list $rg_stack -c resource_name -c physical_resource_id -f json | jq -r "sort_by(.resource_name | tonumber) | .[] | .physical_resource_id")
|
stacks=$(with_backoff fail_if_empty "openstack stack resource list $rg_stack -c resource_name -c physical_resource_id -f json | jq -r 'sort_by(.resource_name | tonumber ) | .[] | .physical_resource_id'")
|
||||||
|
rc=${?}
|
||||||
|
while [ ${rc} -ne 0 ]; do
|
||||||
|
stacks=$(with_backoff fail_if_empty "openstack stack resource list $rg_stack -c resource_name -c physical_resource_id -f json | jq -r 'sort_by(.resource_name | tonumber) | .[] | .physical_resource_id'")
|
||||||
|
done
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user