useful_scripts/get_all_relation_info.sh

30 lines
887 B
Bash
Raw Permalink Normal View History

2021-10-12 19:24:31 +00:00
#!/bin/bash
2021-10-12 19:34:08 +00:00
# Created: JP on Feb 11 2021
# Updated: AA on Oct 12 2021
2021-10-12 19:24:31 +00:00
# Usage: ./get_all_relations_info.sh <app_or_app/unit>
# Example: ./get_all_relations_info.sh mysql # This will default to "mysql/0"
# Example: ./get_all_relations_info.sh keystone/1
. functions.sh
check_juju_version
2021-10-12 19:24:31 +00:00
APP=`echo ${1} | awk -F\/+ '{print $1}'`
UNIT=`echo ${1} | awk -F\/+ '{print $2}'`
[ -z "$UNIT" ] && UNIT=0
for r in `juju show-application ${APP} | grep endpoint-bindings -A999 | tail -n +3 | awk -F\: '{print $1}' | sort`
do
for i in `${juju_run} -u ${APP}/${UNIT} -- "relation-ids ${r}" | awk -F\: '{print $2}' | sort`
2021-10-12 19:24:31 +00:00
do
echo "==========================================="
echo "RELATION INFO FOR ${APP}/${UNIT} - ${r}:${i}"
echo ""
${juju_run} -u ${APP}/${UNIT} -- "relation-get -r ${r}:${i} - ${APP}/${UNIT}"
2021-10-12 19:24:31 +00:00
echo "==========================================="
done
done
exit 0