From 78a2d0d47a493ef7845c86d4a1ba3e9a77a071ff Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Aug 2017 19:36:43 +0100 Subject: proxy support and ILOv2 support --- inf.pl | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'inf.pl') diff --git a/inf.pl b/inf.pl index 4861240..fe9d4a1 100755 --- a/inf.pl +++ b/inf.pl @@ -16,6 +16,15 @@ sub view($$) { exit(0); } + +sub media($$) { + my ( $inf, $port ) = @_; + + $inf->media($port); + + exit(0); +} + sub thing($$$$) { my ( $inf, $port, $thing, $force ) = @_; @@ -28,8 +37,11 @@ sub thing($$$$) { my $name = $inf->name_get(); my $port_name = $inf->port_name_get($port); + view( $inf, $port ) if $thing eq 'view'; + media( $inf, $port ) if $thing eq 'media'; + unless ( $force == 1 ) { print "Are you sure you want to $thing\n"; print "$port_name, port $port on PDU $host($name)\n"; @@ -104,6 +116,7 @@ sub thing_search($$$$) { my $n = $inf->port_count(); + for ( my $i = 1 ; $i <= $n ; ++$i ) { my $port = $inf->port_id_get_by_number($i); my $o = $inf->port_name_get($port); @@ -199,10 +212,10 @@ sub usage() { print "Usage:\n"; print "inf -s hostname [-p port] -n name\n"; print " set name or switch, or port of switch to name\n"; - print "inf -s hostname -p port {-c|-o|-f|-v}\n"; + print "inf -s hostname -p port {-c|-o|-f|-v|-m}\n"; print " cycle -c, turn on -o or turn off -f or view -v,\n"; print " port on switch\n"; - print "inf [-s hostname] [-F] {-c|-o|-f|-v} regexp\n"; + print "inf [-s hostname] [-F] {-c|-o|-f|-v|-m} regexp\n"; print " cycle -c, turn on -o or turn off -f or view -v,\n"; print " the first thing found which matches regex.\n"; print " -s limits search to only one switch, -F doesn't\n"; @@ -217,7 +230,7 @@ sub usage() { my $options = {}; -getopts( "Fv:c:o:f:s:n:p:lh", $options ); +getopts( "Fv:m:c:o:f:s:n:p:lh", $options ); my $infs = []; my $port = undef; @@ -295,6 +308,16 @@ if ( exists $options->{v} ) { } } +if ( exists $options->{m} ) { + if ( defined $port ) { + thing( INF->new( $infs->[0] ), $port, 'media', $force ); + exit(0); + } + else { + thing_search( $infs, $options->{v}, 'media', $force ); + } +} + if ( $options->{n} ) { if ( scalar(@$infs) != 1 ) { print "Use of -n requires use of -s\n"; -- cgit v1.2.3