summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-16 09:58:58 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-16 09:58:58 -0700
commitf9ab046eddd19417c0b2bbe4c5afed2d4516b53f (patch)
treed563f2cb1b9d869ada58d94a4bf1e0b5181c8b21
parent8b782b88bd535d739166d21a4cbb95931fff2ce0 (diff)
downloadvyatta-cfg-quagga-f9ab046eddd19417c0b2bbe4c5afed2d4516b53f.tar.gz
vyatta-cfg-quagga-f9ab046eddd19417c0b2bbe4c5afed2d4516b53f.zip
Reindent perl code
Make it look nice and tidy
-rwxr-xr-xscripts/vyatta-gateway-static_route-check.pl51
-rwxr-xr-xscripts/vyatta-policy-action-verify.pl27
-rwxr-xr-xscripts/vyatta_quagga_utils.pl71
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";