From ff703eb15618b2ebcc1ed85563a73de944d59664 Mon Sep 17 00:00:00 2001 From: Robert Bays Date: Thu, 29 Sep 2011 12:00:10 -0700 Subject: bgp: Bug 6033 - There is no auto completion for "bgp <> neighbor <> peer-group" --- scripts/bgp/vyatta-bgp.pl | 15 +++++++++++++-- .../address-family/ipv6-unicast/peer-group/node.def | 4 ++++ .../bgp/node.tag/neighbor/node.tag/peer-group/node.def | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 4f4ac40e..d10a37af 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -1072,7 +1072,7 @@ my %qcom = ( my $qconfig = new Vyatta::Quagga::Config('protocols', \%qcom); my ( $pg, $as, $neighbor ); -my ( $main, $peername, $isneighbor, $checkpeergroups, $checksource, $isiBGPpeer, $wasiBGPpeer, $confedibgpasn); +my ( $main, $peername, $isneighbor, $checkpeergroups, $checksource, $isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups); GetOptions( "peergroup=s" => \$pg, @@ -1085,6 +1085,7 @@ GetOptions( "is-iBGP" => \$isiBGPpeer, "was-iBGP" => \$wasiBGPpeer, "confed-iBGP-ASN-check=s" => \$confedibgpasn, + "list-peer-groups" => \$listpeergroups, "main" => \$main, ); @@ -1096,10 +1097,20 @@ check_source($checksource) if ($checksource); confed_iBGP_ASN($as, $confedibgpasn) if ($confedibgpasn); is_iBGP_peer($neighbor, $as) if ($isiBGPpeer); was_iBGP_peer($neighbor, $as) if ($wasiBGPpeer); - +list_peer_groups($as) if ($listpeergroups); exit 0; +sub list_peer_groups { + my $as = shift; + my $config = new Vyatta::Config; + + $config->setLevel("protocols bgp $as peer-group"); + my @nodes = $config->listNodes(); + foreach my $node (@nodes) { print "$node "; } + return; +} + # Make sure the peer IP isn't a local system IP sub check_neighbor_ip { my $neighbor = shift; diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/address-family/ipv6-unicast/peer-group/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/address-family/ipv6-unicast/peer-group/node.def index a6e2f658..49b99a60 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.tag/address-family/ipv6-unicast/peer-group/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/address-family/ipv6-unicast/peer-group/node.def @@ -1,2 +1,6 @@ type: txt help: IPv6 peer group for this peer +allowed: local -a params + params=$( /opt/vyatta/sbin/vyatta-bgp.pl --list-peer-groups --as ${COMP_WORDS[3]} ) + echo -n ${params[@]##*/} +commit:expression: exec "/opt/vyatta/sbin/vyatta_quagga_utils.pl --exists \"protocols bgp $VAR(../../../../@) peer-group $VAR(@)\" "; "protocols bgp $VAR(../../../../@) peer-group $VAR(@) doesn't exist" diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/peer-group/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/peer-group/node.def index e407b561..83985e10 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.tag/peer-group/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/peer-group/node.def @@ -1,2 +1,6 @@ type: txt help: IPv4 peer group for this peer +allowed: local -a params + params=$( /opt/vyatta/sbin/vyatta-bgp.pl --list-peer-groups --as ${COMP_WORDS[3]} ) + echo -n ${params[@]##*/} +commit:expression: exec "/opt/vyatta/sbin/vyatta_quagga_utils.pl --exists \"protocols bgp $VAR(../../@) peer-group $VAR(@)\" "; "protocols bgp $VAR(../../@) peer-group $VAR(@) doesn't exist" -- cgit v1.2.3