Changeset 276


Ignore:
Timestamp:
Sep 23, 2017, 10:26:52 AM (7 years ago)
Author:
g7moreau
Message:
  • Clean some code variable $port -> $port_hr
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r275 r276  
    18351835         }
    18361836
    1837       my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS Switch and low port number
     1837      my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS switch and low port number
    18381838
    18391839      my $sw = $SWITCH_DB{$sw_name};
     
    18731873         }
    18741874
    1875       my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS Switch and low port number
     1875      my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS switch and low port number
    18761876
    18771877      my $sw = $SWITCH_DB{$sw_name};
     
    19111911         }
    19121912
    1913       my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS Switch and low port number
     1913      my $search = $OID_NUMBER{'NApoeState'} . ".$switch_port"; # Only NEXANS switch and low port number
    19141914
    19151915      my $sw = $SWITCH_DB{$sw_name};
     
    19221922
    19231923      if (defined $result and $result->{$search} ne 'noSuchInstance') {
    1924          my $poe = $result->{$search} || 'empty';
    1925          $poe =~ s/8/enable/;
    1926          $poe =~ s/2/disable/;
    1927          printf "%s  %s poe %s\n", $sw_name, $switch_port, $poe;
     1924         my $poe_status = $result->{$search} || 'empty';
     1925         $poe_status =~ s/8/enable/;
     1926         $poe_status =~ s/2/disable/;
     1927         printf "%s  %s poe %s\n", $sw_name, $switch_port, $poe_status;
    19281928         }
    19291929      else {
    1930          print "Klask do not find PoE Status on switch $sw_name on port $switch_port\n";
     1930         print "Klask do not find PoE status on switch $sw_name on port $switch_port\n";
    19311931         }
    19321932
     
    23152315
    23162316   my $switch_name = shift @ARGV || q{};
    2317    my $port        = shift @ARGV || q{};
    2318 
    2319    if ($switch_name eq q{} or $port eq q{}) {
     2317   my $port_hr     = shift @ARGV || q{};
     2318
     2319   if ($switch_name eq q{} or $port_hr eq q{}) {
    23202320      die "Usage: klask disable SWITCH_NAME PORT\n";
    23212321      }
     
    23302330
    23312331   # Retrieve numeric port value
    2332    my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');
    2333    die "Error : Port $port does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
     2332   my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port_hr), $verbose ? 'yes' : '');
     2333   die "Error : Port $port_hr does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
    23342334
    23352335   my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_id;
    2336    print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;
     2336   print "Info: switch $switch_name port $port_hr SNMP OID $search_portstatus\n" if $verbose;
    23372337
    23382338   my $result = $session->set_request(
     
    23602360
    23612361   my $switch_name = shift @ARGV || q{};
    2362    my $port        = shift @ARGV || q{};
    2363 
    2364    if ($switch_name eq q{} or $port eq q{}) {
     2362   my $port_hr     = shift @ARGV || q{};
     2363
     2364   if ($switch_name eq q{} or $port_hr eq q{}) {
    23652365      die "Usage: klask disable SWITCH_NAME PORT\n";
    23662366      }
     
    23752375
    23762376   # Retrieve numeric port value
    2377    my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');
    2378    die "Error : Port $port does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
     2377   my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port_hr), $verbose ? 'yes' : '');
     2378   die "Error : Port $port_hr does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
    23792379
    23802380   my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_id;
    2381    print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose;
     2381   print "Info: switch $switch_name port $port_hr SNMP OID $search_portstatus\n" if $verbose;
    23822382
    23832383   my $result = $session->set_request(
     
    24032403
    24042404   my $switch_name = shift @ARGV || q{};
    2405    my $port        = shift @ARGV || q{};
    2406 
    2407    if ($switch_name eq q{} or $port eq q{}) {
     2405   my $port_hr     = shift @ARGV || q{};
     2406
     2407   if ($switch_name eq q{} or $port_hr eq q{}) {
    24082408      die "Usage: klask status SWITCH_NAME PORT\n";
    24092409      }
     
    24182418
    24192419   # Retrieve numeric port value
    2420    my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');
    2421    die "Error : Port $port does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
     2420   my $port_id = snmp_get_switchport_hr2id($session, normalize_port_human_readable($port_hr), $verbose ? 'yes' : '');
     2421   die "Error : Port $port_hr does not exist on switch $switch_name\n" if not $port_id =~ m/^\d+$/;
    24222422
    24232423   my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port_id;
    2424    print "Info: switch $switch_name port $port ($port_id) SNMP OID $search_portstatus\n" if $verbose;
     2424   print "Info: switch $switch_name port $port_hr ($port_id) SNMP OID $search_portstatus\n" if $verbose;
    24252425
    24262426   my $result = $session->get_request(
Note: See TracChangeset for help on using the changeset viewer.