stephb9959
2022-08-23 09:26:41 -07:00
parent 1a0b00e989
commit 667f8bc4bd
7 changed files with 1022 additions and 6 deletions

View File

@@ -97,7 +97,7 @@ if [ -z ${OWPROV_OVERRIDE+x} ]; then
port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
path="$(echo $url | grep / | cut -d/ -f2-)"
export OWPROV=${url}
echo "Using ${OWPROV}..."
echo "Using PROV=${OWPROV}..."
else
echo "OWPROV endpoint is not found:"
jq < ${result_file}
@@ -108,6 +108,33 @@ else
fi
}
setrrm() {
if [ -z ${OWRRM_OVERRIDE+x} ]; then
curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemEndpoints" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
rawurl="$(cat ${result_file} | jq -r '.endpoints[] | select( .type == "owrrm" ) | .uri')"
if [[ ! -z "${rawurl}" ]]; then
proto="$(echo $rawurl | grep :// | sed -e's,^\(.*://\).*,\1,g')"
url="$(echo ${rawurl/$proto/})"
user="$(echo $url | grep @ | cut -d@ -f1)"
hostport="$(echo ${url/$user@/} | cut -d/ -f1)"
host="$(echo $hostport | sed -e 's,:.*,,g')"
port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
path="$(echo $url | grep / | cut -d/ -f2-)"
export OWRRM=${url}
echo "Using RRM=${OWRRM}..."
else
echo "OWRRM endpoint is not found:"
jq < ${result_file}
exit 1
fi
else
export OWRRM=${OWRRM_OVERRIDE}
fi
}
logout() {
curl ${FLAGS} -X DELETE "https://${OWSEC}/api/v1/oauth2/${token}" \
-H "Content-Type: application/json" \
@@ -507,6 +534,24 @@ getvenuedevices() {
jq < ${result_file}
}
listrrmalgos() {
setrrm
curl ${FLAGS} -X GET "http://${OWRRM}/api/v1/algorithms" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "Accept: application/json" > ${result_file}
jq < ${result_file}
}
rrmprovider() {
setrrm
curl ${FLAGS} -X GET "http://${OWRRM}/api/v1/provider" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "Accept: application/json" > ${result_file}
jq < ${result_file}
}
shopt -s nocasematch
case "$1" in
"login") login; echo "You are logged in..." ; logout ;;
@@ -555,6 +600,8 @@ case "$1" in
"getsubdevs") login; getsubdevs $2; logout;;
"listvenues") login; listvenues $2; logout;;
"getvenuedevices") login; getvenuedevices $2; logout;;
"listrrmalgos") login; listrrmalgos; logout;;
"rrmprovider") login; rrmprovider; logout;;
*) help ;;
esac