Files
llb-oracle/rsc_host_refresh.sh
2025-10-15 10:39:19 +01:00

70 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#
# Example RSC API call script
# v0.1 - James Pattinson - September 2025
#
# Perfoms a host refresh in RSC
#
# usage: rsc_host_refresh.sh <targethost>
#
# Options:
# <targethost> : Host to perform refresh job
usage() { log_error "Usage: $0 <host>"; exit 1; }
if [[ -z "$1" ]]; then
usage
fi
MYDIR="$(dirname "$(realpath "$0")")"
# Support -v/--verbose and strip it from positional args
NEWARGS=()
for arg in "$@"; do
case "$arg" in
-v|--verbose)
VERBOSE=1
;;
*)
NEWARGS+=("$arg")
;;
esac
done
set -- "${NEWARGS[@]}"
source $MYDIR/rsc_ops.sh
RBK_HOST=$1
rsc_get_host_id
log_info "Host ID: $targetHostId"
gql_refreshHost='mutation RefreshHost($input: RefreshHostInput!) {
refreshHost(input: $input) {
output {
hostSummary {
name
operatingSystemType
status
}
agentId
}
}
}'
variables="{
\"input\": {
\"id\": \"$targetHostId\"
}
}"
gqlQuery="$(echo $gql_refreshHost)"
gqlVars="$(echo $variables)"
log_info "Refreshing host $RBK_HOST (ID: $targetHostId)"
rsc_gql_query
log_info "Response:"
cat /tmp/rbkresponse.$$ | jq