From 2a58e65ed3d4368e8ed084df331a0e1e31eec3b5 Mon Sep 17 00:00:00 2001 From: John Southworth Date: Fri, 17 Jun 2011 16:45:00 -0500 Subject: Bugfix 6816: Make previous bugfix more maintainable by moving check to a script instead of defining it in multiple node.defs --- scripts/vyatta-next-hop-check | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 scripts/vyatta-next-hop-check (limited to 'scripts') 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 -- cgit v1.2.3