Add host refresh

This commit is contained in:
2025-09-04 17:10:56 +01:00
parent b5d849d029
commit 5f137a957e
2 changed files with 87 additions and 0 deletions

View File

@@ -112,6 +112,36 @@ EOF
}
rsc_get_host_id() {
gql_list_targets='query PhysicalHosts($hostRoot: HostRoot!, $filter: [Filter!]) {
physicalHosts(hostRoot: $hostRoot, filter: $filter) {
nodes {
id
name
}
}
}'
variables="{\"hostRoot\":\"LINUX_HOST_ROOT\",\"first\":50,\"filter\":[{\"field\":\"NAME_EXACT_MATCH\",\"texts\":[\"$RBK_HOST\"]},{\"field\":\"IS_RELIC\",\"texts\":[\"false\"]},{\"field\":\"IS_REPLICATED\",\"texts\":[\"false\"]},{\"field\":\"IS_KUPR_HOST\",\"texts\":[\"false\"]}],\"sortBy\":\"NAME\",\"sortOrder\":\"ASC\",\"childFilter\":[{\"field\":\"IS_GHOST\",\"texts\":[\"false\"]},{\"field\":\"IS_RELIC\",\"texts\":[\"false\"]}]}"
gqlQuery="$(echo $gql_list_targets)"
gqlVars="$(echo $variables)"
rsc_gql_query
# Get all matching host IDs (portable, no mapfile)
host_ids=$(cat /tmp/rbkresponse.$$ | jq -r '.data.physicalHosts.nodes[] | .id')
host_count=$(echo "$host_ids" | grep -c .)
if [[ $host_count -ne 1 ]]; then
echo "ERROR: Multiple hosts found for '$1':"
cat /tmp/rbkresponse.$$ | jq -r '.data.physicalHosts.nodes[] | "\(.name) \(.id)"'
exit_with_error
fi
# Set the first match (or empty if none)
targetHostId=$(echo "$host_ids" | head -n 1)
#cat /tmp/rbkresponse.$$ | jq -r
}
rsc_find_database () {
# if cluster_uuid is not set, get it