summaryrefslogtreecommitdiff
path: root/scripts/vyatta-next-hop-check
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-06-17 16:45:00 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-06-17 16:45:00 -0500
commit2a58e65ed3d4368e8ed084df331a0e1e31eec3b5 (patch)
tree09cb7c8903e67f4499ec92640314342c249c3fd0 /scripts/vyatta-next-hop-check
parentf6433b4e2cc5891e08d6666de53aea2a8c8ed12f (diff)
downloadvyatta-cfg-quagga-2a58e65ed3d4368e8ed084df331a0e1e31eec3b5.tar.gz
vyatta-cfg-quagga-2a58e65ed3d4368e8ed084df331a0e1e31eec3b5.zip
Bugfix 6816: Make previous bugfix more maintainable by moving check to a script instead of defining it in multiple node.defs
Diffstat (limited to 'scripts/vyatta-next-hop-check')
-rw-r--r--scripts/vyatta-next-hop-check35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/vyatta-next-hop-check b/scripts/vyatta-next-hop-check
new file mode 100644
index 00000000..bd81284d
--- /dev/null
+++ b/scripts/vyatta-next-hop-check
@@ -0,0 +1,35 @@
+#!/bin/bash
+if [ $# -ne 3 ]; then
+ echo 1>&2 Usage: $0 prefix family type
+ exit 127
+fi
+ROUTE=$1
+FAM=$2
+TYPE=$3
+SUFFIX=''
+if [[ ${FAM} = 'ipv6' ]]; then
+ SUFFIX='6'
+fi
+if [[ ${TYPE} = 'address' ]]; then
+ # Check that there is still a next-hop or blackhole if the parent is not deleted
+ ARR=( $(cli-shell-api listNodes protocols static route${SUFFIX} ${ROUTE} next-hop) )
+ cli-shell-api exists protocols static route${SUFFIX} ${ROUTE} blackhole
+ RETVAL_BH=$?
+ cli-shell-api exists protocols static route${SUFFIX} ${ROUTE}
+ RETVAL_PARENT=$?
+ if [ ${#ARR} -eq 0 ] && [ $RETVAL_BH -eq 1 ] && [ $RETVAL_PARENT -eq 0 ]
+ then
+ echo "Must add either a next-hop or blackhole for route ${ROUTE}"
+ exit 1
+ fi
+elif [[ ${TYPE} = 'interface' ]];then
+ # Check that there is still a next-hop-interface if the parent is not deleted
+ ARR=( $(cli-shell-api listNodes protocols static interface-route${SUFFIX} ${ROUTE} next-hop-interface) )
+ cli-shell-api exists protocols static interface-route${SUFFIX} ${ROUTE}
+ RETVAL_PARENT=$?
+ if [ ${#ARR} -eq 0 ] && [ $RETVAL_PARENT -eq 0 ]
+ then
+ echo "Must add a next-hop-interface for route ${ROUTE}"
+ exit 1
+ fi
+fi