First commit

This commit is contained in:
2025-10-14 09:16:37 -04:00
parent ab09e775d1
commit 481fc3e02e
5 changed files with 866 additions and 0 deletions

48
refresh_host.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/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