#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# no_rpl - 
#           remove unused policis "no_rpl -U 0x0 "
#           remove all rpl        "no_rpl"
#
# Jun 2013, Rajasekhar Lekkala
#
# Copyright (c) 2013-2014 by cisco Systems, Inc.
# All rights reserved.
# --------------------------------------------------------------------

if [ $# -eq 0 ]
then
    nvgen -c -q gl/policy_lang/*/*/*/bag | grep -e "^tag-set" -e"policy-global" -e "^route-policy" -e "^prefix-set" -e "^as-path-set" -e "^community-set" -e "^extcommunity-set" | prepend_text no >temp_rpl.txt
else
    while getopts "U:Z:" opt; do
        case $opt in 
            U  ) show_opt="-U" 
                 if [ $OPTARG -eq 0 ]
                 then
                    show_type="route-policy"
                 fi
                 pr_show $show_opt $OPTARG -z "no $show_type" | grep -e "route-policy" >temp_rpl.txt ;;
            \? ) print 'usage: $0 [-U]  args'
                  return 1
        esac
    done
fi
config -V -f temp_rpl.txt
