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 --- .../interface-route/node.tag/next-hop-interface/node.def | 11 ++--------- .../interface-route6/node.tag/next-hop-interface/node.def | 10 ++-------- templates/protocols/static/route/node.tag/next-hop/node.def | 13 ++----------- .../protocols/static/route6/node.tag/next-hop/node.def | 13 ++----------- 4 files changed, 8 insertions(+), 39 deletions(-) (limited to 'templates/protocols/static') diff --git a/templates/protocols/static/interface-route/node.tag/next-hop-interface/node.def b/templates/protocols/static/interface-route/node.tag/next-hop-interface/node.def index 7e31ef40..019978f9 100644 --- a/templates/protocols/static/interface-route/node.tag/next-hop-interface/node.def +++ b/templates/protocols/static/interface-route/node.tag/next-hop-interface/node.def @@ -11,16 +11,9 @@ end: then if [[ ${COMMIT_ACTION} = 'DELETE' ]] 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 $VAR(../@) next-hop-interface) ) - cli-shell-api exists protocols static interface-route $VAR(../@) - RETVAL_PARENT=$? - if [ ${#ARR} -eq 0 ] && [ $RETVAL_PARENT -eq 0 ] - then - echo "Must add a next-hop-interface for route $VAR(../@)" - exit 1 + if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv4 interface; then + exit 1; fi - vtysh -c "configure terminal" \ -c "no ip route $VAR(../@) $VAR(@)" else diff --git a/templates/protocols/static/interface-route6/node.tag/next-hop-interface/node.def b/templates/protocols/static/interface-route6/node.tag/next-hop-interface/node.def index 84e619cc..279329d6 100644 --- a/templates/protocols/static/interface-route6/node.tag/next-hop-interface/node.def +++ b/templates/protocols/static/interface-route6/node.tag/next-hop-interface/node.def @@ -10,14 +10,8 @@ end: then if [[ ${COMMIT_ACTION} = 'DELETE' ]] then - # Check that there is still a next-hop-interface if the parent is not deleted - ARR=( $(cli-shell-api listNodes protocols static interface-route6 $VAR(../@) next-hop-interface) ) - cli-shell-api exists protocols static interface-route6 $VAR(../@) - RETVAL_PARENT=$? - if [ ${#ARR} -eq 0 ] && [ $RETVAL_PARENT -eq 0 ] - then - echo "Must add a next-hop-interface for route $VAR(../@)" - exit 1 + if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv6 interface; then + exit 1; fi vtysh -c "configure terminal" \ diff --git a/templates/protocols/static/route/node.tag/next-hop/node.def b/templates/protocols/static/route/node.tag/next-hop/node.def index 9160dd8d..eb41b4e4 100644 --- a/templates/protocols/static/route/node.tag/next-hop/node.def +++ b/templates/protocols/static/route/node.tag/next-hop/node.def @@ -6,18 +6,9 @@ end: then if [[ ${COMMIT_ACTION} = 'DELETE' ]] 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 $VAR(../@) next-hop) ) - cli-shell-api exists protocols static route $VAR(../@) blackhole - RETVAL_BH=$? - cli-shell-api exists protocols static route $VAR(../@) - 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 $VAR(../@)" - exit 1 + if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv4 address; then + exit 1; fi - if ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl \ "$VAR(../@)" "$VAR(@)" then diff --git a/templates/protocols/static/route6/node.tag/next-hop/node.def b/templates/protocols/static/route6/node.tag/next-hop/node.def index 28b6ec00..e3a668b7 100644 --- a/templates/protocols/static/route6/node.tag/next-hop/node.def +++ b/templates/protocols/static/route6/node.tag/next-hop/node.def @@ -9,18 +9,9 @@ end: then if [[ ${COMMIT_ACTION} = 'DELETE' ]] then - # Check that there is still a next-hop or blackhole if the parent is not deleted - ARR=( $(cli-shell-api listNodes protocols static route6 $VAR(../@) next-hop) ) - cli-shell-api exists protocols static route6 $VAR(../@) blackhole - RETVAL_BH=$? - cli-shell-api exists protocols static route6 $VAR(../@) - 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 $VAR(../@)" - exit 1 + if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv6 address; then + exit 1; fi - if ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl \ "$VAR(../@)" "$VAR(@)" then -- cgit v1.2.3