Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion systemvm/debian/opt/cloud/bin/checkrouter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,29 @@

STATUS=UNKNOWN

ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
if [ "$ROUTER_TYPE" = "vpcrouter" ];then
GUEST_NICS=$(python3 -c "
import json
data = json.load(open('/etc/cloudstack/ips.json'))
for nic, objs in data.items():
if isinstance(objs, list):
for obj in objs:
if obj.get('nw_type') == 'guest' and obj.get('add'):
print(nic)
")
if [ "$GUEST_NICS" = "" ];then
echo "Status: ${STATUS}"
exit
fi
fi

if [ "$(systemctl is-active keepalived)" != "active" ]
then
echo "Status: FAULT"
exit
fi

ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
if [ "$ROUTER_TYPE" = "router" ]
then
ROUTER_STATE=$(ip -4 addr show dev eth0 | grep inet | wc -l | xargs bash -c 'if [ $0 == 2 ]; then echo "PRIMARY"; else echo "BACKUP"; fi')
Expand Down