Changeset 242 for trunk/klask


Ignore:
Timestamp:
Sep 7, 2017, 10:35:53 PM (3 years ago)
Author:
g7moreau
Message:
  • Add aggregator code for Comware where num port and index are not equal !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r241 r242  
    800800#---------------------------------------------------------------
    801801sub snmp_get_switchport_hr {
    802    my ($snmp_session, $swport) = @_;
    803 
    804    my $research_index = $OID_NUMBER{ifIndex} .'.'. $swport;
    805    my $result_index = $snmp_session->get_request(
    806       -varbindlist => [$research_index]
    807       );
    808    my $swifindex = $swport;
    809    $swifindex = $result_index->{$research_index} if defined $result_index;
    810 
    811    my $research_hr = $OID_NUMBER{ifName} .'.'. $swifindex;
     802   my ($snmp_session, $swport_num, $flag) = @_;
     803
     804   # On H3C, port number and port index are not the same
     805   # Double SNMP request to get the name
     806   my $swport_index = $swport_num;
     807
     808   if ($flag ne 'index') {
     809      my $research_index = $OID_NUMBER{ifIndex} .'.'. $swport_num;
     810      my $result_index = $snmp_session->get_request(
     811         -varbindlist => [$research_index]
     812         );
     813      $swport_index = $result_index->{$research_index} if defined $result_index;
     814      }
     815
     816   my $research_hr = $OID_NUMBER{ifName} .'.'. $swport_index;
    812817   my $result_hr = $snmp_session->get_request(
    813818      -varbindlist => [$research_hr]
    814819      );
    815    my $swport_hr = $swport;
     820   my $swport_hr = $swport_index;
    816821   $swport_hr = normalize_port_human_readable($result_hr->{$research_hr}) if defined $result_hr;
    817822
     
    827832         # IEEE8023-LAG-MIB::dot3adAggPortSelectedAggID.28 = INTEGER: 337
    828833         # IEEE8023-LAG-MIB::dot3adAggPortAttachedAggID.28 = INTEGER: 337
    829          my $port_aggregator = $snmp_session->var_bind_list->{$oid_current};
    830          my ($port_index) = reverse split /\./, $oid_current; # last number
     834         my $port_aggregator_index = $snmp_session->var_bind_list->{$oid_current};
     835         my ($current_port_index) = reverse split /\./, $oid_current; # last number
    831836
    832837         # prepare next loop item
    833838         @args = (-varbindlist => [$oid_current]);
    834839
    835          next LOOP_ON_OID_PORT if $port_aggregator == 0;
    836          next LOOP_ON_OID_PORT if not $port_aggregator == $swport;
    837 
    838          my $port_name = snmp_get_switchport_hr($snmp_session, $port_index);
    839          $swport_hr .= ":$port_name";
     840         next LOOP_ON_OID_PORT if $port_aggregator_index == 0;
     841         next LOOP_ON_OID_PORT if not $port_aggregator_index == $swport_index;
     842
     843         my $current_port_name = snmp_get_switchport_hr($snmp_session, $current_port_index, 'index');
     844         $swport_hr .= ":$current_port_name";
    840845         }
    841846      }
Note: See TracChangeset for help on using the changeset viewer.