Send Netdot-devel mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."
Today's Topics:
1. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-110-g8c60869 ([email protected])
2. [SCM] Netdot branch master updated. netdot-1.0.4-110-g8c60869
([email protected])
3. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-111-gc486014 ([email protected])
4. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-112-g520f2bb ([email protected])
5. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-113-g092ea13 ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Thu, 31 Oct 2013 19:53:46 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-110-g8c60869
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via 8c6086906774d88398120343f629a87c40608243 (commit)
from 771bab9602a9284af6980e7c6846ddd76b288541 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8c6086906774d88398120343f629a87c40608243
Author: Carlos Vicente <[email protected]>
Date: Wed Oct 30 11:34:06 2013 -0400
Fix broken collection of forwarding tables from Cisco devices switches when
using SNMPv3
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 9d92fb1..6e2d426 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -834,15 +834,12 @@ sub get_snmp_info {
next if ( exists $seen_inst{$mst_inst} );
next unless $vlan_status{$vid} eq 'operational';
next if ( exists $IGNOREDVLANS{$vid} );
- my $comm = $sinfo->snmp_comm . '@' . $vid;
my $stp_p_info;
my $i_stp_info;
eval {
- my $vsinfo =
$class->_get_snmp_session('host' => $args{host},
-
'communities' => [$comm],
-
'version' => $sinfo->snmp_ver,
-
'sclass' => $sinfo->class);
-
+ my $vsinfo =
$class->_get_cisco_snmp_context_session(sinfo => $sinfo,
+
vlan => $vid);
+
return unless $vsinfo;
$stp_p_info = $class->_exec_timeout(
@@ -855,9 +852,7 @@ sub get_snmp_info {
sub{ return
$self->_get_i_stp_info(sinfo=>$vsinfo) } );
};
if ( my $e = $@ ){
- $logger->error(sprintf("Could not get SNMP
session for %s with ".
- "community %s",
- $args{host}, $comm));
+ $logger->error("$args{host}: SNMP error for
VLAN $vid: $e");
next;
}
foreach my $method ( keys %$stp_p_info ){
@@ -884,13 +879,10 @@ sub get_snmp_info {
foreach my $vid ( keys %vlans ){
next if ( exists $IGNOREDVLANS{$vid} );
next unless $vlan_status{$vid} eq 'operational';
- my $comm = $sinfo->snmp_comm . '@' . $vid;
eval {
- my $vsinfo = $class->_get_snmp_session('host'
=> $args{host},
-
'communities' => [$comm],
-
'version' => $sinfo->snmp_ver,
- 'sclass'
=> $sinfo->class);
-
+ my $vsinfo =
$class->_get_cisco_snmp_context_session(sinfo => $sinfo,
+
vlan => $vid);
+
return unless $vsinfo;
my $stp_p_info = $class->_exec_timeout(
@@ -912,8 +904,7 @@ sub get_snmp_info {
}
};
if ( my $e = $@ ){
- $logger->error(sprintf("Could not get SNMP
session for %s with community %s",
- $args{host}, $comm));
+ $logger->error("$args{host}: SNMP error for
VLAN $vid: $e");
next;
}
}
@@ -3831,7 +3822,18 @@ sub _layer_active {
return substr($layers,8-$layer, 1);
}
-# ############################################################################
+#############################################################################
+sub _make_sinfo_object
+{
+ my ($self, $sclass, %sinfoargs) = @_;
+ if ( $sinfoargs{sqe} ) {
+ $sinfoargs{Session} = Netdot::FakeSNMPSession->new(%sinfoargs);
+ $logger->debug(sub{"Device::_make_sinfo_object: with SQE" });
+ }
+ return $sclass->new( %sinfoargs );
+}
+
+#############################################################################
# _get_snmp_session - Establish a SNMP session. Tries to reuse sessions.
#
# Arguments:
@@ -3856,22 +3858,12 @@ sub _layer_active {
# Examples:
#
# Instance call:
-# my $session = $device->get_snmp_session();
+# my $session = $device->_get_snmp_session();
#
# Class call:
-# my $session = Device->get_snmp_session(host=>$hostname,
communities=>['public']);
+# my $session = Device->_get_snmp_session(host=>$hostname,
communities=>['public']);
#
-sub _make_sinfo_object
-{
- my ($self, $sclass, %sinfoargs) = @_;
- if ($sinfoargs{sqe}) {
- $sinfoargs{Session} = Netdot::FakeSNMPSession->new(%sinfoargs);
- $logger->debug(sub{"Device::_make_sinfo_object: with SQE" });
- }
- return $sclass->new( %sinfoargs );
-}
-
sub _get_snmp_session {
my ($self, %argv) = @_;
@@ -3926,23 +3918,28 @@ sub _get_snmp_session {
$self->throw_fatal("Model::Device::_get_snmp_session: Missing required
arguments: host")
unless $argv{host};
}
-
- $sclass ||= 'SNMP::Info';
# Set defaults
my %sinfoargs = (
- DestHost => $argv{host},
- Version => $argv{version} || $self->config->get('DEFAULT_SNMPVERSION'),
- Timeout => (defined $argv{timeout})? $argv{timeout} :
$self->config->get('DEFAULT_SNMPTIMEOUT'),
- Retries => (defined $argv{retries}) ? $argv{retries} :
$self->config->get('DEFAULT_SNMPRETRIES'),
- AutoSpecify => 1,
- Debug => ( $logger->is_debug() )? 1 : 0,
- BulkWalk => (defined $argv{bulkwalk}) ? $argv{bulkwalk} :
$self->config->get('DEFAULT_SNMPBULK'),
+ DestHost => $argv{host},
+ Version => $argv{version} ||
$self->config->get('DEFAULT_SNMPVERSION'),
+ Timeout => (defined $argv{timeout})? $argv{timeout} :
$self->config->get('DEFAULT_SNMPTIMEOUT'),
+ Retries => (defined $argv{retries}) ? $argv{retries} :
$self->config->get('DEFAULT_SNMPRETRIES'),
+ Debug => ( $logger->is_debug() )? 1 : 0,
+ BulkWalk => (defined $argv{bulkwalk}) ? $argv{bulkwalk} :
$self->config->get('DEFAULT_SNMPBULK'),
BulkRepeaters => $self->config->get('DEFAULT_SNMPBULK_MAX_REPEATERS'),
MibDirs => \@MIBDIRS,
sqe => $argv{sqe},
);
+ if ( defined $sclass ) {
+ $sinfoargs{AutoSpecify} = 0;
+ }else{
+ $sinfoargs{AutoSpecify} = 1;
+ $sclass = 'SNMP::Info';
+ }
+
+
# Turn off bulkwalk if we're using Net-SNMP 5.2.3 or 5.3.1.
if ( !$sinfoargs{sqe} && $sinfoargs{BulkWalk} == 1 && ($SNMP::VERSION eq
'5.0203' || $SNMP::VERSION eq '5.0301')
&& !$self->config->get('IGNORE_BUGGY_SNMP_CHECK')) {
@@ -3979,6 +3976,7 @@ sub _get_snmp_session {
$sinfoargs{AuthPass} = $argv{auth_pass} if $argv{auth_pass};
$sinfoargs{PrivProto} = $argv{priv_proto} if $argv{priv_proto};
$sinfoargs{PrivPass} = $argv{priv_pass} if $argv{priv_pass};
+ $sinfoargs{Context} = $argv{context} if $argv{context};
$logger->debug(sub{ sprintf("Device::get_snmp_session: Trying SNMPv%d
session with %s",
$sinfoargs{Version}, $argv{host})});
@@ -4980,6 +4978,67 @@ sub _validate_arp {
}
############################################################################
+# _get_cisco_snmp_context_session
+#
+# Use the session information to connect to the VLAN-based "context"
+# that provides forwarding table and STP information for that VLAN
+# In SNMPv2, the context is specified by adding @vlan to the community
+# whereas in SNMPv3, the "Context" parameter is used as "vlan-$vlan"
+sub _get_cisco_snmp_context_session {
+ my ($self, %argv) = @_;
+ my $class = ref($self) || $self;
+
+ my $sinfo = $argv{sinfo};
+ my $vlan = $argv{vlan};
+
+ # Grab the existing SNMP session parameters
+ my $sargs = $sinfo->args();
+ my %args = ('host' => $sargs->{DestHost},
+ 'version' => $sargs->{Version},
+ 'retries' => $sargs->{Retries},
+ 'snmpbulk' => $sargs->{BulkWalk},
+ 'sclass' => $sinfo->class,
+ );
+
+ if ( $args{version} == 3 ){
+ $args{sec_name} = $sargs->{SecName};
+ $args{sec_level} = $sargs->{SecLevel};
+ $args{auth_proto} = $sargs->{AuthProto};
+ $args{auth_pass} = $sargs->{AuthPass};
+ $args{priv_proto} = $sargs->{PrivProto};
+ $args{priv_pass} = $sargs->{PrivPass};
+ $args{context} = "vlan-$vlan";
+ }else{
+ $args{communities} = [$self->community . '@' . $vlan];
+ }
+
+ return $class->_get_snmp_session(%args);
+}
+
+############################################################################
+# Get list of all active VLANS on this device
+sub _get_active_vlans {
+ my ($self, %argv) = @_;
+
+ my $sinfo = $argv{sinfo};
+ my %vlans;
+ map { $vlans{$_}++ } values %{$sinfo->i_vlan()};
+ my $v_state = $sinfo->v_state();
+ foreach my $vid ( keys %vlans ){
+ my $key = '1.'.$vid;
+ delete $vlans{$vid} unless ( exists $v_state->{$key}
+ && $v_state->{$key} eq 'operational' );
+ }
+ my @res;
+ foreach my $vlan ( sort { $a <=> $b } keys %vlans ){
+ next if ( exists $IGNOREDVLANS{$vlan} );
+ push @res, $vlan;
+ }
+ return @res;
+}
+
+
+############################################################################
#_get_fwt_from_snmp - Fetch fowarding tables via SNMP
#
# Performs some validation and abstracts snmp::info logic
@@ -5014,7 +5073,6 @@ sub _get_fwt_from_snmp {
my $start = time;
my $sinfo = $argv{session} || $self->_get_snmp_session();
-
return unless $sinfo;
my $sints = $sinfo->interfaces();
@@ -5037,47 +5095,25 @@ sub _get_fwt_from_snmp {
);
});
- # For certain Cisco switches you have to connect to each
- # VLAN and get the forwarding table out of it.
- # Notably the Catalyst 5k, 6k, and 3500 series
+ # On most Cisco switches you have to connect to each
+ # VLAN to get the forwarding table
my $cisco_comm_indexing = $sinfo->cisco_comm_indexing();
if ( $cisco_comm_indexing ){
$logger->debug(sub{"$host supports Cisco community string indexing.
Connecting to each VLAN" });
- my $sclass = $sinfo->class();
-
- # Get list of all active VLANS on this device
- my %vlans;
- foreach my $int ( $self->interfaces ){
- map { $vlans{$_->vlan->vid}++ } $int->vlans;
- }
- my $v_state = $sinfo->v_state();
- foreach my $vid ( keys %vlans ){
- my $key = '1.'.$vid;
- delete $vlans{$vid} unless ( exists $v_state->{$key}
- && $v_state->{$key} eq 'operational'
);
- }
-
- foreach my $vlan ( sort { $a <=> $b } keys %vlans ){
+
+ foreach my $vlan ( $self->_get_active_vlans(sinfo=>$sinfo) ){
next if ( $argv{vlan} && $argv{vlan} ne $vlan );
- next if ( $vlan == 0 || $vlan == 1 ); # Ignore vlans 0 and 1
- my $target = (scalar($self->snmp_target))?
$self->snmp_target->address : $host;
- my %args = ('host' => $target,
- 'communities' => [$self->community . '@' . $vlan],
- 'version' => $self->snmp_version,
- 'sclass' => $sclass,
- );
-
my $vlan_sinfo;
eval {
- $vlan_sinfo = $class->_get_snmp_session(%args);
+ $vlan_sinfo =
$class->_get_cisco_snmp_context_session(sinfo=>$sinfo, vlan=>$vlan);
};
if ( my $e = $@ ){
$logger->error("$host: SNMP error for VLAN $vlan: $e");
next;
}
-
+
return unless $vlan_sinfo;
-
+
$class->_exec_timeout($host, sub{ return $self->_walk_fwt(sinfo
=> $vlan_sinfo,
sints
=> $sints,
devints
=> \%devints,
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Device.pm | 174 ++++++++++++++++++++++++++-----------------
1 files changed, 105 insertions(+), 69 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 2
Date: Thu, 31 Oct 2013 19:54:41 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch master updated.
netdot-1.0.4-110-g8c60869
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, master has been updated
via 8c6086906774d88398120343f629a87c40608243 (commit)
from 771bab9602a9284af6980e7c6846ddd76b288541 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Device.pm | 174 ++++++++++++++++++++++++++-----------------
1 files changed, 105 insertions(+), 69 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 3
Date: Fri, 1 Nov 2013 09:38:34 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-111-gc486014
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via c486014bdfa723e6cd7c90aab0df8a93f9e53290 (commit)
from 8c6086906774d88398120343f629a87c40608243 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c486014bdfa723e6cd7c90aab0df8a93f9e53290
Author: Carlos Vicente <[email protected]>
Date: Wed Oct 30 15:18:02 2013 -0400
Avoid issues with duplicate assets (one with S/N, one with MAC) for the
same device while updating
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 6e2d426..3ae3aea 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -2938,13 +2938,37 @@ sub info_update {
reserved_for => "", # needs to be cleared when device gets installed
);
- # This is an OR (notice the arrayref)
- my @where;
- push(@where, { serial_number => $asset_args{serial_number} })
+ # Search for an asset based on either serial number or base MAC
+ # If two different assets are found, we will have to pick one and
+ # delete the other, as this leads to errors
+ my $asset_sn =
Asset->search(serial_number=>$asset_args{serial_number})->first
if $asset_args{serial_number};
- push(@where, { physaddr => $asset_args{physaddr} })
+ my $asset_phy = Asset->search(physaddr=>$asset_args{physaddr})->first
if $asset_args{physaddr};
- my $asset = Asset->search_where(\@where)->first if @where;
+
+ my $asset;
+ if ( $asset_sn && $asset_phy ){
+ if ($asset_sn->id != $asset_phy->id ){
+ # Not the same. We'll just choose the one
+ # with the serial number
+ # Reassign any devices or device_modules' assets
+ foreach my $dev ( $asset_phy->devices ){
+ $dev->update({asset_id=>$asset_sn});
+ }
+ foreach my $mod ( $asset_phy->device_modules ){
+ $mod->update({asset_id=>$asset_sn});
+ }
+ $logger->debug(sub{ sprintf("%s: Deleting duplicate asset %s",
+ $host, $asset_phy->get_label)});
+ $asset_phy->delete();
+ }
+ $asset = $asset_sn;
+ }elsif ( $asset_sn ){
+ $asset = $asset_sn;
+ }elsif ( $asset_phy ){
+ $asset = $asset_phy;
+ }
+
my $dev_product;
if ( $asset ){
# Make sure that the data is complete with the latest info we got
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Device.pm | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 4
Date: Fri, 1 Nov 2013 10:15:15 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-112-g520f2bb
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via 520f2bbada1c1560c519657dd5851b5effaaa516 (commit)
from c486014bdfa723e6cd7c90aab0df8a93f9e53290 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 520f2bbada1c1560c519657dd5851b5effaaa516
Author: Carlos Vicente <[email protected]>
Date: Wed Oct 30 15:54:34 2013 -0400
Correction
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 3ae3aea..28d5a8c 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -837,7 +837,7 @@ sub get_snmp_info {
my $stp_p_info;
my $i_stp_info;
eval {
- my $vsinfo =
$class->_get_cisco_snmp_context_session(sinfo => $sinfo,
+ my $vsinfo =
$self->_get_cisco_snmp_context_session(sinfo => $sinfo,
vlan => $vid);
return unless $vsinfo;
@@ -880,7 +880,7 @@ sub get_snmp_info {
next if ( exists $IGNOREDVLANS{$vid} );
next unless $vlan_status{$vid} eq 'operational';
eval {
- my $vsinfo =
$class->_get_cisco_snmp_context_session(sinfo => $sinfo,
+ my $vsinfo =
$self->_get_cisco_snmp_context_session(sinfo => $sinfo,
vlan => $vid);
return unless $vsinfo;
@@ -5129,7 +5129,7 @@ sub _get_fwt_from_snmp {
next if ( $argv{vlan} && $argv{vlan} ne $vlan );
my $vlan_sinfo;
eval {
- $vlan_sinfo =
$class->_get_cisco_snmp_context_session(sinfo=>$sinfo, vlan=>$vlan);
+ $vlan_sinfo =
$self->_get_cisco_snmp_context_session(sinfo=>$sinfo, vlan=>$vlan);
};
if ( my $e = $@ ){
$logger->error("$host: SNMP error for VLAN $vlan: $e");
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Device.pm | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 5
Date: Fri, 1 Nov 2013 11:15:01 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-113-g092ea13
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via 092ea13de800caf5c02128c7e261f8c4224a94d1 (commit)
from 520f2bbada1c1560c519657dd5851b5effaaa516 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 092ea13de800caf5c02128c7e261f8c4224a94d1
Author: Carlos Vicente <[email protected]>
Date: Wed Oct 30 16:44:58 2013 -0400
Added some minor checks
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index f2c21d2..7d741db 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -1544,6 +1544,8 @@ sub is_address {
my $self = shift;
$self->isa_object_method('is_address');
+ return unless ($self->version && $self->prefix);
+
if ( ($self->version == 4 && $self->prefix == 32)
|| ($self->version == 6 && $self->prefix == 128) ){
return 1;
@@ -3550,6 +3552,7 @@ sub _obj_int2ip {
return unless ( $self->id );
my $decimal = $self->address;
+ return 0 unless $decimal;
unless ( $decimal =~ /\D/o ){
my $ip = $self->int2ip($decimal, $self->version);
$self->_attribute_store({address => $ip, decimal => $decimal});
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Ipblock.pm | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 80, Issue 1
*******************************************