Skip to content

Commit e5001a1

Browse files
committed
Fixed an issue when the link can't been connected yet.
1 parent 8e836bd commit e5001a1

File tree

1 file changed

+3
-3
lines changed
  • Management-Utilities/Workload-Factory-API-Samples

1 file changed

+3
-3
lines changed

Management-Utilities/Workload-Factory-API-Samples/list_links

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ EOF
4242
tmpout=$(mktemp /tmp/list_filesystems-out.XXXXXX)
4343
tmpout2=$(mktemp /tmp/list_filesystems-out2.XXXXXX)
4444
tmperr=$(mktemp /tmp/list_filesystems-err.XXXXXX)
45-
trap 'rm -f $tmpout $tmpout2 $tmperr' exit
45+
#trap 'rm -f $tmpout $tmpout2 $tmperr' exit
4646

4747
while getopts "ht:a:" opt; do
4848
case $opt in
@@ -109,7 +109,7 @@ if [ -z "$token" ]; then
109109
fi
110110

111111
run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/links/v1/links?filter=type%20eq%20%27lambda%27&include=associatedTargets,state,features" $tmpout $tmperr
112-
if jq -r '.items[] | "\(.name);\(.id);\(.state.status);\(.region);\(.vpcId);\(.cloudResourceId | split(":") | .[6]);\(.associatedTargets.items)"' $tmpout > $tmpout2 2> $tmperr; then
112+
if jq -r '.items[] | if(.cloudResourceId == null) then "\(.name);\(.id);\(.state.status);\(.region);\(.vpcId);N/A;\(.associatedTargets.items)" else "\(.name);\(.id);\(.state.status);\(.region);\(.vpcId);\(.cloudResourceId | split(":") | .[6]);\(.associatedTargets.items)" end' $tmpout > $tmpout2 2> $tmperr; then
113113
:
114114
else
115115
echo "Failed to parse the response from the API." >&2
@@ -121,7 +121,7 @@ fi
121121
nextToken=$(jq -r '.nextToken' $tmpout)
122122
while [ "$nextToken" != "null" ]; do
123123
run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/links/v1/links?filter=type%20eq%20%27lambda%27&include=associatedTargets,state,features" $tmpout $tmperr
124-
if jq -r '.items[] | "\(.name);\(.id);\(.state.status);\(.state.status);\(.region);\(.vpcId);\(.cloudResourceId | split(":") | .[6]);\(.associatedTargets.items)"' $tmpout > $tmpout2 2> $tmperr; then
124+
if jq -r '.items[] | if(.cloudResourceId == null) then "\(.name);\(.id);\(.state.status);\(.region);\(.vpcId);N/A;\(.associatedTargets.items)" else "\(.name);\(.id);\(.state.status);\(.region);\(.vpcId);\(.cloudResourceId | split(":") | .[6]);\(.associatedTargets.items)" end' $tmpout > $tmpout2 2> $tmperr; then
125125
:
126126
else
127127
echo "Failed to parse the response from the API." >&2

0 commit comments

Comments
 (0)