From 00733861ccd6a85da3b0f93b2702dbfb702e466c Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 26 Aug 2025 10:09:07 +0200 Subject: [PATCH 1/2] VPC VR: return UNKNOWN redundant state if no guest nics --- systemvm/debian/opt/cloud/bin/checkrouter.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/checkrouter.sh b/systemvm/debian/opt/cloud/bin/checkrouter.sh index c3a73e9e5e32..79fe0473fc50 100755 --- a/systemvm/debian/opt/cloud/bin/checkrouter.sh +++ b/systemvm/debian/opt/cloud/bin/checkrouter.sh @@ -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') From 866f2b8cfa301cde7e85f9dac86b6c4c580d43f6 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 27 Aug 2025 08:34:34 +0200 Subject: [PATCH 2/2] Update 11518 --- systemvm/debian/opt/cloud/bin/checkrouter.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/checkrouter.sh b/systemvm/debian/opt/cloud/bin/checkrouter.sh index 79fe0473fc50..f127187ceb48 100755 --- a/systemvm/debian/opt/cloud/bin/checkrouter.sh +++ b/systemvm/debian/opt/cloud/bin/checkrouter.sh @@ -18,17 +18,21 @@ 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 " +get_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 isinstance(objs, list): + for obj in objs: + if obj.get('nw_type') == 'guest' and obj.get('add'): + print(nic) + " +} + +ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g') +if [ "$ROUTER_TYPE" = "vpcrouter" ];then + GUEST_NICS=$(get_guest_nics) if [ "$GUEST_NICS" = "" ];then echo "Status: ${STATUS}" exit