useful_scripts/get_all_relation_info.sh

26 lines
810 B
Bash
Raw Normal View History

2021-10-12 19:24:31 +00:00
#!/bin/bash
# JP on Feb 11 2021
# 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
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 --unit ${APP}/${UNIT} "relation-ids ${r}" | awk -F\: '{print $2}' | sort`
do
echo "==========================================="
echo "RELATION INFO FOR ${APP}/${UNIT} - ${r}:${i}"
echo ""
juju run --unit ${APP}/${UNIT} "relation-get -r ${r}:${i} - ${APP}/${UNIT}"
echo "==========================================="
done
done
exit 0