Skip to content

Commit 0073386

Browse files
committed
VPC VR: return UNKNOWN redundant state if no guest nics
1 parent 25f93b1 commit 0073386

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

systemvm/debian/opt/cloud/bin/checkrouter.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,29 @@
1818

1919
STATUS=UNKNOWN
2020

21+
ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
22+
if [ "$ROUTER_TYPE" = "vpcrouter" ];then
23+
GUEST_NICS=$(python3 -c "
24+
import json
25+
data = json.load(open('/etc/cloudstack/ips.json'))
26+
for nic, objs in data.items():
27+
if isinstance(objs, list):
28+
for obj in objs:
29+
if obj.get('nw_type') == 'guest' and obj.get('add'):
30+
print(nic)
31+
")
32+
if [ "$GUEST_NICS" = "" ];then
33+
echo "Status: ${STATUS}"
34+
exit
35+
fi
36+
fi
37+
2138
if [ "$(systemctl is-active keepalived)" != "active" ]
2239
then
2340
echo "Status: FAULT"
2441
exit
2542
fi
2643

27-
ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
2844
if [ "$ROUTER_TYPE" = "router" ]
2945
then
3046
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')

0 commit comments

Comments
 (0)