49 lines
1019 B
Bash
Executable File
49 lines
1019 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Example API call script for Die Mobiliar
|
|
# v0.2 - James Pattinson - August 2021
|
|
#
|
|
# usage: refresh_host.sh <HOSTNAME>
|
|
|
|
MYDIR="$(dirname "$(realpath "$0")")"
|
|
# source $MYDIR/rbk_api.conf
|
|
source $MYDIR/oracle_funcs.sh
|
|
|
|
if [ $# -ne 1 ]; then
|
|
echo "Usage: $0 <dbhost>"
|
|
exit 1
|
|
fi
|
|
|
|
RBK_HOST=$1
|
|
|
|
echo Connecting to Rubrik with IP $RUBRIK_IP
|
|
|
|
# API call to get host details
|
|
ENDPOINT="https://$RUBRIK_IP/api/v1/host?name=$RBK_HOST"
|
|
rest_api_get
|
|
|
|
total=$(cat /tmp/rbkresponse.$$ | jq -r .total)
|
|
if [ $total -ne 1 ]; then
|
|
echo Host name of $RBK_HOST does not map to a single host:
|
|
cat /tmp/rbkresponse.$$ | jq -r '.data[].name'
|
|
exit_with_error
|
|
fi
|
|
|
|
host_id=$(cat /tmp/rbkresponse.$$ | jq -r '.data[0].id')
|
|
|
|
if [ -z $host_id ]; then
|
|
echo FATAL: Unable to map host name to ID
|
|
exit_with_error
|
|
fi
|
|
|
|
# API call to assign SLA
|
|
ENDPOINT="https://$RUBRIK_IP/api/v1/host/$host_id/refresh"
|
|
|
|
echo Requesting host refresh for $RBK_HOST
|
|
|
|
rest_api_post_empty
|
|
|
|
echo Refreshed host details for $RBK_HOST
|
|
|
|
cleanup
|