diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-gateway-static_route-check.pl | 51 | ||||
-rwxr-xr-x | scripts/vyatta-policy-action-verify.pl | 27 | ||||
-rwxr-xr-x | scripts/vyatta_quagga_utils.pl | 71 |
3 files changed, 77 insertions, 72 deletions
diff --git a/scripts/vyatta-gateway-static_route-check.pl b/scripts/vyatta-gateway-static_route-check.pl index 51de1604..f550180d 100755 --- a/scripts/vyatta-gateway-static_route-check.pl +++ b/scripts/vyatta-gateway-static_route-check.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Module: vyatta-gateway-static_route-check.pl +# Module: vyatta-gateway-static_route-check.pl # # **** License **** # This program is free software; you can redistribute it and/or modify @@ -35,37 +35,40 @@ use lib "/opt/vyatta/share/perl5/"; use NetAddr::IP; use Vyatta::Config; +if ( ( $#ARGV == 1 ) && ( $ARGV[0] eq '0.0.0.0/0' ) ) { -if (($#ARGV == 1) && ($ARGV[0] eq '0.0.0.0/0')) { # check when deleting static-route my $vcCHECK_GATEWAY = new Vyatta::Config(); $vcCHECK_GATEWAY->setLevel('system'); if ( $vcCHECK_GATEWAY->exists('.') ) { - my $gateway_ip = $vcCHECK_GATEWAY->returnValue('gateway-address'); - if ( defined($gateway_ip) && $gateway_ip eq $ARGV[1] ) { - exit 1; - } + my $gateway_ip = $vcCHECK_GATEWAY->returnValue('gateway-address'); + if ( defined($gateway_ip) && $gateway_ip eq $ARGV[1] ) { + exit 1; + } } - -} elsif ($#ARGV == 0) { - # check when deleting gateway-address + +} +elsif ( $#ARGV == 0 ) { + + # check when deleting gateway-address my $vcCHECK_STATIC_ROUTE = new Vyatta::Config(); $vcCHECK_STATIC_ROUTE->setLevel('protocols static'); if ( $vcCHECK_STATIC_ROUTE->exists('.') ) { - my @routes = $vcCHECK_STATIC_ROUTE->listNodes("route"); - if (@routes > 0) { - foreach my $route (@routes) { - if ($route eq '0.0.0.0/0') { - my @next_hops = $vcCHECK_STATIC_ROUTE->listNodes("route $route next-hop"); - foreach my $next_hop (@next_hops) { - if ($next_hop eq $ARGV[0]) { - exit 1; - } - } - } - } - } + my @routes = $vcCHECK_STATIC_ROUTE->listNodes("route"); + if ( @routes > 0 ) { + foreach my $route (@routes) { + if ( $route eq '0.0.0.0/0' ) { + my @next_hops = + $vcCHECK_STATIC_ROUTE->listNodes("route $route next-hop"); + foreach my $next_hop (@next_hops) { + if ( $next_hop eq $ARGV[0] ) { + exit 1; + } + } + } + } + } } } - -exit 0; + +exit 0; diff --git a/scripts/vyatta-policy-action-verify.pl b/scripts/vyatta-policy-action-verify.pl index d426dfd2..b914837e 100755 --- a/scripts/vyatta-policy-action-verify.pl +++ b/scripts/vyatta-policy-action-verify.pl @@ -1,21 +1,21 @@ #!/usr/bin/perl -w # # Module: vyatta-policy-action-verify.pl -# +# # **** License **** # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -# +# # This code was originally developed by Vyatta, Inc. # Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. # All Rights Reserved. -# +# # **** End License **** # use lib "/opt/vyatta/share/perl5/"; @@ -30,26 +30,27 @@ use File::Copy; #solution: put a commit statement in the rule node that does the action test and squirt out delete hook in rule node on a delete. my $route_map = shift; -my $rule = shift; -my $action = shift; +my $rule = shift; +my $action = shift; -if (!defined($rule) || !defined($route_map)) { - exit 1; +if ( !defined($rule) || !defined($route_map) ) { + exit 1; } my $config = new Vyatta::Config; $config->setLevel('policy route-map $route_map rule $rule'); -if ($config->exists("action")) { +if ( $config->exists("action") ) { exit 0; } my @qualifiers = $config->listNodes(); foreach my $qualifiers (@qualifiers) { - exit 1; #error! + exit 1; #error! } #need to get a count of what's left and if action is deleted, but other nodes are present then reject - -if (-e "/tmp/delete-policy-route-map-$route_map-rule-$rule") { - system "/usr/bin/vyatta-vtysh -c \"configure terminal\" -c \"no route-map $route_map $action $rule\""; + +if ( -e "/tmp/delete-policy-route-map-$route_map-rule-$rule" ) { + system +"/usr/bin/vyatta-vtysh -c \"configure terminal\" -c \"no route-map $route_map $action $rule\""; } diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl index 55254cbb..1d85b431 100755 --- a/scripts/vyatta_quagga_utils.pl +++ b/scripts/vyatta_quagga_utils.pl @@ -6,12 +6,13 @@ use Vyatta::Misc; use NetAddr::IP; use Getopt::Long; -my ($prefix, $exists, $not_exists, $area); +my ( $prefix, $exists, $not_exists, $area ); -GetOptions("check-prefix-boundry=s" => \$prefix, - "not-exists=s" => \$not_exists, - "exists=s" => \$exists, - "check-ospf-area=s" => \$area, +GetOptions( + "check-prefix-boundry=s" => \$prefix, + "not-exists=s" => \$not_exists, + "exists=s" => \$exists, + "check-ospf-area=s" => \$area, ); check_prefix_boundry($prefix) if ($prefix); @@ -22,52 +23,52 @@ check_ospf_area($area) if ($area); exit 0; sub check_prefix_boundry { - my $prefix = shift; - my ($net, $network, $cidr); - - $net = new NetAddr::IP $prefix; - $network = $net->network()->cidr(); - $cidr = $net->cidr(); - - die "Your prefix must fall on a natural network boundry. ", - "Did you mean $network?\n" - if ($cidr ne $network); - - exit 0; + my $prefix = shift; + my ( $net, $network, $cidr ); + + $net = new NetAddr::IP $prefix; + $network = $net->network()->cidr(); + $cidr = $net->cidr(); + + die "Your prefix must fall on a natural network boundry. ", + "Did you mean $network?\n" + if ( $cidr ne $network ); + + exit 0; } sub check_exists { - my $node = shift; - my $config = new Vyatta::Config; + my $node = shift; + my $config = new Vyatta::Config; - exit 0 if $config->exists($node); - exit 1; + exit 0 if $config->exists($node); + exit 1; } sub check_not_exists { - my $node = shift; - my $config = new Vyatta::Config; + my $node = shift; + my $config = new Vyatta::Config; - exit 0 if ! $config->exists($node); - exit 1; + exit 0 if !$config->exists($node); + exit 1; } sub check_ospf_area { my $area = shift; # - # allow both decimal or dotted decimal + # allow both decimal or dotted decimal # - if ($area =~ m/^\d+$/) { - if ($area >= 0 && $area <= 4294967295) { - exit 0; - } + if ( $area =~ m/^\d+$/ ) { + if ( $area >= 0 && $area <= 4294967295 ) { + exit 0; + } } - if ($area =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { - foreach my $octet ($1, $2, $3, $4) { - if (($octet < 0) || ($octet > 255)) { exit 1; } - } - exit 0 + if ( $area =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) { + foreach my $octet ( $1, $2, $3, $4 ) { + if ( ( $octet < 0 ) || ( $octet > 255 ) ) { exit 1; } + } + exit 0; } die "Invalid OSPF area: $area\n"; |