Skip to content

Commit 05e7a25

Browse files
VPC VR: return UNKNOWN redundant state if no guest nics (apache#11518)
* VPC VR: return UNKNOWN redundant state if no guest nics
1 parent f80a9ca commit 05e7a25

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

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

1919
STATUS=UNKNOWN
2020

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

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