From 0a0fac4ddbc53445634f20e2f9551023c7fc8071 Mon Sep 17 00:00:00 2001 From: Eric Miller <> Date: Thu, 3 Jul 2008 02:33:22 +0000 Subject: [PATCH] Remove VLAN set methods, not working consistently across devices --- Info/Layer2/HP.pm | 211 ---------------------------------------------- 1 file changed, 211 deletions(-) diff --git a/Info/Layer2/HP.pm b/Info/Layer2/HP.pm index c4097328..9b6082ca 100644 --- a/Info/Layer2/HP.pm +++ b/Info/Layer2/HP.pm @@ -468,167 +468,6 @@ sub i_vlan_membership { return $i_vlan_membership; } -sub set_i_vlan { - my $hp = shift; - my ($vlan, $ifindex) = @_; - - unless ( defined $vlan and defined $ifindex and - $vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { - $hp->error_throw("Invalid parameter"); - return undef; - } - - # Newer devices use Q-BRIDGE-MIB - my $qb_i_vlan = $hp->qb_i_vlan_t(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ - return $hp->SUPER::set_i_vlan($vlan, $ifindex); - } # We're done here if the device supports the Q-BRIDGE-MIB - - # Older HP switches use the HP-VLAN MIB - # Thanks to Jeroen van Ingen - my $hp_v_index = $hp->hp_v_index(); - my $hp_v_if_tag = $hp->hp_v_if_tag(); - if (defined $hp_v_index and scalar(keys %$hp_v_index)){ - my $old_untagged; - # Hash to lookup VLAN index of the VID (dot1q tag) - my %vl_trans = reverse %$hp_v_index; - - foreach my $row (keys %$hp_v_if_tag){ - # Loop through table to determine current untagged vlan for the port we're about to change - my ($index,$if) = split(/\./,$row); - if ($if == $ifindex and $hp_v_if_tag->{$row} =~ /untagged/) { - # Store the row information of the current untagged VLAN and temporarily set it to tagged - $old_untagged = $row; - my $rv = $hp->set_hp_v_if_tag(1, $row); - warn "Unexpected error changing native/untagged VLAN into tagged.\n" unless $rv; - last; - } - } - - # Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB - my $vlan_index = $vl_trans{$vlan}; - if (defined $vlan_index) { - # Set our port untagged in the desired VLAN - my $rv = $hp->set_hp_v_if_tag(2, "$vlan_index.$ifindex"); - if ($rv) { - # If port change is successful, remove VLAN that used to be untagged from the port - $hp->set_hp_v_if_tag(3, $old_untagged) if defined $old_untagged; - return $rv; - } else { - # If not, try to revert to the old situation. - $hp->set_hp_v_if_tag(2, $old_untagged) if defined $old_untagged; - } - } - else { - warn "Requested VLAN (VLAN ID: $vlan) not found!\n"; - } - } - print "Error: Unable to change VLAN: $vlan on IfIndex: $ifindex list\n" if $hp->debug(); - return undef; -} - -sub set_i_pvid { - my $hp = shift; - my ($vlan, $ifindex) = @_; - - unless ( defined $vlan and defined $ifindex and - $vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { - $hp->error_throw("Invalid parameter"); - return undef; - } - - # Newer devices use Q-BRIDGE-MIB - my $qb_i_vlan = $hp->qb_i_vlan_t(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ - return $hp->SUPER::set_i_pvid($vlan, $ifindex); - } - - # HP method same as set_i_vlan() - return $hp->set_i_vlan($vlan, $ifindex); -} - -sub set_add_i_vlan_tagged { - my $hp = shift; - my ($vlan, $ifindex) = @_; - - unless ( defined $vlan and defined $ifindex and - $vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { - $hp->error_throw("Invalid parameter"); - return undef; - } - - # Newer devices use Q-BRIDGE-MIB - my $qb_i_vlan = $hp->qb_i_vlan(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ - return $hp->SUPER::set_add_i_vlan_tagged($vlan, $ifindex); - } # We're done here if the device supports the Q-BRIDGE-MIB - - # Older HP switches use the HP-VLAN MIB - my $hp_v_index = $hp->hp_v_index(); - my $hp_v_if_tag = $hp->hp_v_if_tag(); - if (defined $hp_v_index and scalar(keys %$hp_v_index)){ - # Hash to lookup VLAN index of the VID (dot1q tag) - my %vl_trans = reverse %$hp_v_index; - - # Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB - my $vlan_index = $vl_trans{$vlan}; - if (defined $vlan_index) { - # Add port to egress list for VLAN - my $rv = ($hp->set_hp_v_if_tag(1, "$vlan_index.$ifindex")); - if ($rv) { - print "Successfully added IfIndex: $ifindex to VLAN: $vlan list\n" if $hp->debug(); - return 1; - } - } - else { - $hp->error_throw("Requested VLAN (VLAN ID: $vlan) not found!\n"); - } - } - print "Error: Unable to add VLAN: $vlan to IfIndex: $ifindex list\n" if $hp->debug(); - return undef; -} - -sub set_remove_i_vlan_tagged { - my $hp = shift; - my ($vlan, $ifindex) = @_; - - unless ( defined $vlan and defined $ifindex and - $vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { - $hp->error_throw("Invalid parameter"); - return undef; - } - - # Newer devices use Q-BRIDGE-MIB - my $qb_i_vlan = $hp->qb_i_vlan(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ - return $hp->SUPER::set_remove_i_vlan_tagged($vlan, $ifindex); - } # We're done here if the device supports the Q-BRIDGE-MIB - - # Older HP switches use the HP-VLAN MIB - my $hp_v_index = $hp->hp_v_index(); - my $hp_v_if_tag = $hp->hp_v_if_tag(); - if (defined $hp_v_index and scalar(keys %$hp_v_index)){ - # Hash to lookup VLAN index of the VID (dot1q tag) - my %vl_trans = reverse %$hp_v_index; - - # Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB - my $vlan_index = $vl_trans{$vlan}; - if (defined $vlan_index) { - # Add port to egress list for VLAN - my $rv = ($hp->set_hp_v_if_tag(3, "$vlan_index.$ifindex")); - if ($rv) { - print "Successfully added IfIndex: $ifindex to VLAN: $vlan list\n" if $hp->debug(); - return 1; - } - } - else { - $hp->error_throw("Requested VLAN (VLAN ID: $vlan) not found!\n"); - } - } - print "Error: Unable to remove VLAN: $vlan to IfIndex: $ifindex list\n" if $hp->debug(); - return undef; -} - # Use CDP and/or LLDP sub hasCDP { @@ -1094,54 +933,4 @@ See documentation in L for details. See documentation in L for details. -=head1 SET METHODS - -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. - -=over - -=item $hp->set_i_vlan(vlan, ifIndex) - -Changes an untagged port VLAN, must be supplied with the numeric VLAN -ID and port ifIndex. This method will modify the port's VLAN membership. -This method should only be used on end station (non-trunk) ports. - - Example: - my %if_map = reverse %{$hp->interfaces()}; - $hp->set_i_vlan('2', $if_map{'1.1'}) - or die "Couldn't change port VLAN. ",$hp->error(1); - -=item $hp->set_i_pvid(pvid, ifIndex) - -Sets port PVID or default VLAN, must be supplied with the numeric VLAN ID and -port ifIndex. This method only changes the PVID, to modify an access (untagged) -port use set_i_vlan() instead. - - Example: - my %if_map = reverse %{$hp->interfaces()}; - $hp->set_i_pvid('2', $if_map{'1.1'}) - or die "Couldn't change port PVID. ",$hp->error(1); - -=item $hp->set_add_i_vlan_tagged(vlan, ifIndex) - -Adds the port to the egress list of the VLAN, must be supplied with the numeric -VLAN ID and port ifIndex. - - Example: - my %if_map = reverse %{$hp->interfaces()}; - $hp->set_add_i_vlan_tagged('2', $if_map{'1.1'}) - or die "Couldn't add port to egress list. ",$hp->error(1); - -=item $hp->set_remove_i_vlan_tagged(vlan, ifIndex) - -Removes the port from the egress list of the VLAN, must be supplied with the -numeric VLAN ID and port ifIndex. - - Example: - my %if_map = reverse %{$hp->interfaces()}; - $hp->set_remove_i_vlan_tagged('2', $if_map{'1.1'}) - or die "Couldn't add port to egress list. ",$hp->error(1); - =cut