diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-07-07 10:59:00 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-07-07 10:59:00 -0700 |
commit | c37bf36c2a8493dc0c1bee3fc3b78deaaf143b90 (patch) | |
tree | 01048f6bb5fb04826127665789a1a8fd4fc6c287 | |
parent | c5c6a358db1d88d7064f01ab0813e6d1799a300f (diff) | |
download | vyatta-op-c37bf36c2a8493dc0c1bee3fc3b78deaaf143b90.tar.gz vyatta-op-c37bf36c2a8493dc0c1bee3fc3b78deaaf143b90.zip |
Cleanup show bonding script
Use existing Vyatta::Misc module to find interfaces
-rwxr-xr-x | scripts/vyatta-show-bonding.pl | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/scripts/vyatta-show-bonding.pl b/scripts/vyatta-show-bonding.pl index 62d503e..c34a89e 100755 --- a/scripts/vyatta-show-bonding.pl +++ b/scripts/vyatta-show-bonding.pl @@ -22,7 +22,11 @@ # # **** End License **** # + +use lib "/opt/vyatta/share/perl5/"; use Getopt::Long; +use Vyatta::Misc; +use Vyatta::Interface; use strict; use warnings; @@ -33,18 +37,6 @@ sub usage { exit 1; } -sub get_sysfs_value { - my ( $intf, $name ) = @_; - - open( my $statf, '<', "/sys/class/net/$intf/$name" ) - or die "Can't open file /sys/class/net/$intf/$name"; - - my $value = <$statf>; - chomp $value if defined $value; - close $statf; - return $value; -} - sub get_state_link { my $intf = shift; my $state; @@ -76,7 +68,7 @@ my @modes = ( "round-robin", ); sub show_brief { - my @interfaces = @_; + my @interfaces = grep { /^bond[\d]+$/ } getInterfaces(); my $format = "%-12s %-22s %-8s %-6s %s\n"; printf $format, 'Interface', 'Mode', 'State', 'Link', 'Slaves'; @@ -93,6 +85,7 @@ sub show_brief { printf $format, $intf, $mode, $state, $link, $slaves ? $slaves : ''; } + exit 0; } sub show { @@ -125,25 +118,6 @@ sub show { my $brief; GetOptions( 'brief' => \$brief, ) or usage(); -my @bond_intf = (); +show_brief() if ($brief); +show(@ARGV); -if ( $#ARGV == -1 ) { - my $sysfs = '/sys/class/net'; - opendir( my $sysdir, $sysfs ) || die "can't opendir $sysfs"; - foreach my $intf ( readdir($sysdir) ) { - if ( -d "$sysfs/$intf/bonding" ) { - unshift @bond_intf, $intf; - } - } - close $sysdir; -} -else { - @bond_intf = @ARGV; -} - -if ($brief) { - show_brief(@bond_intf); -} -else { - show(@bond_intf); -} |