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-5-g8ec172d ([email protected])
2. [Netdot - Feature #1714] (Resolved) easier access for adding
a new vlan ([email protected])
3. [Netdot - Support #1718] (Resolved) Cant discovery interfaces
([email protected])
4. [SCM] Netdot branch sqe created. netdot-1.0.4-26-gea030bc
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 2 Jan 2013 12:06:39 -0800
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-5-g8ec172d
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 8ec172d105a9b665e2c823675e43bfa26e81b168 (commit)
via be3730d485d465e3718d45ca7a386275a89cbe7c (commit)
via b9255199c9b8b64cae936e4c6559fb5595c782a6 (commit)
via 42749eb45da01ca3fcc1848ad6933314a061d0f3 (commit)
from 3e55f689ee2417e6cc5c14250cbce7b606e67cc1 (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 8ec172d105a9b665e2c823675e43bfa26e81b168
Author: Carlos Vicente <[email protected]>
Date: Wed Jan 2 15:06:29 2013 -0500
Feature #1714 (easier access for adding a new vlan)
diff --git a/htdocs/management/vlan_tasks.html
b/htdocs/management/vlan_tasks.html
index 8e9c1d5..87b1d2c 100644
--- a/htdocs/management/vlan_tasks.html
+++ b/htdocs/management/vlan_tasks.html
@@ -59,9 +59,13 @@ my $manager = $ui->get_permission_manager($r);
<div class="containerheadright">
% if ( $manager && $manager->can($user, 'access_admin_section',
'vlan_tasks:new') ){
-% if ( $view eq 'search' ){
- <a href="vlan_tasks.html?view=new">[new]</a>
-% }elsif ( $view eq 'new' ){
+% if ( $view ne 'new-vlan' ){
+ <a href="vlan_tasks.html?view=new-vlan">[new vlan]</a>
+% }
+% if ( $view ne 'new-group' ){
+ <a href="vlan_tasks.html?view=new-group">[new group]</a>
+% }
+% if ( $view ne 'search' ){
<a href="vlan_tasks.html?view=search">[search]</a>
% }
% }
@@ -90,8 +94,15 @@ my $manager = $ui->get_permission_manager($r);
</p>
</form>
</fieldset>
-% }elsif ( $view eq 'new' ){
-% unless ( $manager && $manager->can($user, 'access_admin_section',
'vlan_tasks:new') ){
+% }elsif ( $view eq 'new-vlan' ){
+% unless ( $manager && $manager->can($user, 'access_admin_section',
'vlan_tasks:new-vlan') ){
+% $m->comp('/generic/error.mhtml', error=>"You do not have permission
to do this");
+% }
+
+ <& '/generic/edit.html', table=>'Vlan' &>
+
+% }elsif ( $view eq 'new-group' ){
+% unless ( $manager && $manager->can($user, 'access_admin_section',
'vlan_tasks:new-group') ){
% $m->comp('/generic/error.mhtml', error=>"You do not have permission
to do this");
% }
<fieldset class="medium">
commit be3730d485d465e3718d45ca7a386275a89cbe7c
Author: Carlos Vicente <[email protected]>
Date: Wed Jan 2 14:24:28 2013 -0500
Fix for #1716 (REST interface method POST is broken)
diff --git a/lib/Netdot/REST.pm b/lib/Netdot/REST.pm
index 4601a18..0cb9c1c 100644
--- a/lib/Netdot/REST.pm
+++ b/lib/Netdot/REST.pm
@@ -343,10 +343,7 @@ sub post{
unless ( $argv{obj} || ($argv{table} && $argv{id}) ){
$self->throw_fatal("Missing required arguments");
}
- unless ( $argv{data} ){
- $self->throw_fatal("Missing required arguments: data");
- }
-
+
my $obj = $argv{obj} || $argv{table}->retrieve($argv{id});
unless ( $obj ) {
my $msg = sprintf("Netdot::REST::post: %s/%s not found", $argv{table},
$argv{id});
commit b9255199c9b8b64cae936e4c6559fb5595c782a6
Author: Carlos Vicente <[email protected]>
Date: Wed Jan 2 14:12:04 2013 -0500
Fix for #1713. VLAN names will only be set, not updated, when discovering a
device
diff --git a/lib/Netdot/Model/Interface.pm b/lib/Netdot/Model/Interface.pm
index d32238d..b0dfeb0 100644
--- a/lib/Netdot/Model/Interface.pm
+++ b/lib/Netdot/Model/Interface.pm
@@ -503,16 +503,12 @@ sub snmp_update {
$vdata{vid} = $vid;
$vdata{name} = $vname if defined $vname;
if ( $vo = Vlan->search(vid => $vid)->first ){
- # update in case named changed
- # (ignore default vlan 1)
- if ( defined $vdata{name} && $vo->vid ne "1" ){
- if ( !(defined $vo->name) ||
- (defined $vo->name && $vdata{name} ne $vo->name) ){
- my $r = $vo->update(\%vdata);
- $logger->debug(sub{ sprintf("%s: VLAN %s name updated:
%s",
- $label, $vo->vid,
$vo->name) })
- if $r;
- }
+ # update if name wasn't set (ignore default vlan 1)
+ if ( !defined $vo->name && defined $vdata{name} && $vo->vid ne
"1" ){
+ my $r = $vo->update(\%vdata);
+ $logger->debug(sub{ sprintf("%s: VLAN %s name updated: %s",
+ $label, $vo->vid, $vo->name) })
+ if $r;
}
}else{
# create
commit 42749eb45da01ca3fcc1848ad6933314a061d0f3
Author: Carlos Vicente <[email protected]>
Date: Wed Jan 2 13:49:40 2013 -0500
Subnet cannot change status while DHCP scope exists
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index 7fd0178..12e01af 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -1651,6 +1651,11 @@ sub update {
my $scope = ($self->dhcp_scopes)[0];
$scope->update({ipblock=>$self});
}
+ if ( $bak{status} != $self->status ){
+ if ( $self->status->name ne 'Subnet' ){
+ $self->throw_user("Subnet cannot change status while DHCP scope
exists");
+ }
+ }
}
# Update PTR records if needed
-----------------------------------------------------------------------
Summary of changes:
htdocs/management/vlan_tasks.html | 21 ++++++++++++++++-----
lib/Netdot/Model/Interface.pm | 16 ++++++----------
lib/Netdot/Model/Ipblock.pm | 5 +++++
lib/Netdot/REST.pm | 5 +----
4 files changed, 28 insertions(+), 19 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 2
Date: Wed, 2 Jan 2013 12:07:33 -0800
From: [email protected]
Subject: [Netdot-devel] [Netdot - Feature #1714] (Resolved) easier
access for adding a new vlan
To: [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Issue #1714 has been updated by Carlos Vicente.
Category set to UserInterface
Status changed from New to Resolved
Assignee set to Carlos Vicente
Target version set to 1.0.5
Resolution set to fixed
----------------------------------------
Feature #1714: easier access for adding a new vlan
https://osl.uoregon.edu/redmine/issues/1714#change-3031
Author: Wim Vandersmissen
Status: Resolved
Priority: Normal
Assignee: Carlos Vicente
Category: UserInterface
Target version: 1.0.5
Resolution: fixed
The [new] option on management/?page=VLANS wants to add a new vlan group.
If you want to add a new vlan manually you'll have to click on an existing vlan
to get the link for creating a new vlan.
It would be handy to have a link on management/?page=VLANS to
management/edit.html?table=Vlan
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://osl.uoregon.edu/redmine/my/account
------------------------------
Message: 3
Date: Wed, 2 Jan 2013 12:11:47 -0800
From: [email protected]
Subject: [Netdot-devel] [Netdot - Support #1718] (Resolved) Cant
discovery interfaces
To: [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Issue #1718 has been updated by Carlos Vicente.
Tracker changed from Feature to Support
Status changed from New to Resolved
Assignee set to Carlos Vicente
Resolution set to worksforme
Edit the IFRESERVED variable in your Site.conf file to remove the patterns of
interface names that you want Netdot to create.
----------------------------------------
Support #1718: Cant discovery interfaces
https://osl.uoregon.edu/redmine/issues/1718#change-3032
Author: Rizal Nur
Status: Resolved
Priority: Normal
Assignee: Carlos Vicente
Category: Netdot
Target version: 1.0
Resolution: worksforme
I get problem when discover interface on PC router based FreeBSD OS. After
update device, it just show 5 of 7 my interface. I dont know what happened and
how to fix it.
Thanks
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://osl.uoregon.edu/redmine/my/account
------------------------------
Message: 4
Date: Thu, 3 Jan 2013 07:29:38 -0800
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch sqe created.
netdot-1.0.4-26-gea030bc
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, sqe has been created
at ea030bc7e0e6a70c9fcf816ada533fe4200e9ab6 (commit)
- Log -----------------------------------------------------------------
commit ea030bc7e0e6a70c9fcf816ada533fe4200e9ab6
Merge: b57a37f 8ec172d
Author: Carlos Vicente <[email protected]>
Date: Thu Jan 3 10:29:13 2013 -0500
Merge branch 'netdot-1.0' into sqe
commit b57a37f064fdd31da13bc4df3578bb369fa5048c
Merge: d8f2a75 6f4e53d
Author: Carlos Vicente <[email protected]>
Date: Wed Dec 12 15:40:21 2012 -0500
Merge remote-tracking branch 'tobez/master' into sqe
commit 6f4e53d1ecacfccd3ae17b1f6845b900015d9e3d
Author: Anton Berezin <[email protected]>
Date: Wed Dec 12 21:26:53 2012 +0100
Support SNMP::Varbind in SQE GET.
diff --git a/lib/Netdot/FakeSNMPSession.pm b/lib/Netdot/FakeSNMPSession.pm
index 691e810..962e34f 100644
--- a/lib/Netdot/FakeSNMPSession.pm
+++ b/lib/Netdot/FakeSNMPSession.pm
@@ -7,6 +7,7 @@ use Coro;
use AnyEvent;
use Net::SNMP::QueryEngine::AnyEvent;
use Socket;
+use Data::Dump 'pp', 'dd';
use SNMP; # we use that for OID translation
sub new
@@ -36,10 +37,11 @@ sub new
sub _self_check
{
my $me = shift;
+ my $class = ref($me) || $me;
for my $p (qw(sqe DestHost Version)) {
- croak("$class::new: argument \"$p\" must be supplied") unless $me->{$p};
+ croak("$class:\:new: argument \"$p\" must be supplied") unless
$me->{$p};
}
- croak("$class::new: unsupported SNMP version: $me->{Version}")
+ croak("$class:\:new: unsupported SNMP version: $me->{Version}")
unless $me->{Version} == 1 || $me->{Version} == 2;
}
@@ -54,8 +56,15 @@ sub get
{
my ($me, $v, $cb) = @_;
- croak("IMPLEMENT ME: GET var is a reference")
- if ref $v;
+ if (ref($v)) {
+ if (ref($v) eq "SNMP::Varbind") {
+ if (@$v == 1) {
+ $v = $v->[0];
+ }
+ }
+ }
+ croak("IMPLEMENT ME: GET var is a reference we cannot (for now) handle: "
. pp($v))
+ if ref $v;
my $oid = $v;
$oid = SNMP::translateObj($oid) unless $oid =~ /^[\d.]+$/;
commit 4afc730ea80100af7750c39ea0adcd5bea6ac20c
Merge: 46f8193 857acb5
Author: Anton Berezin <[email protected]>
Date: Wed Dec 12 21:24:46 2012 +0100
Merge branch 'master' of git://github.com/cvicente/Netdot
diff --cc lib/Netdot/Model/Device.pm
index 5e7288c,d8e2738..54526ae
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@@ -1435,8 -1442,9 +1447,10 @@@ sub discover
auth_pass =>
$argv{auth_pass},
priv_proto =>
$argv{priv_proto},
priv_pass =>
$argv{priv_pass},
+ sqe => $argv{sqe},
);
+
+ return unless $sinfo;
}
$info = $class->_exec_timeout($name,
sub{ return
$class->get_snmp_info(session => $sinfo,
@@@ -2712,8 -2719,10 +2726,11 @@@ sub snmp_update
auth_pass => $argv{auth_pass},
priv_proto => $argv{priv_proto},
priv_pass => $argv{priv_pass},
+ sqe => $argv{sqe},
);
+
+ return unless $sinfo;
+
}
# Re-bless into appropriate sub-class if needed
commit d8f2a75381fc1b4c14c51fc6e13cb70943b90ad5
Merge: a006b68 46f8193
Author: Carlos Vicente <[email protected]>
Date: Thu Dec 6 10:15:10 2012 -0500
Merge branch 'master' of https://github.com/tobez/Netdot into sqe
diff --cc lib/Netdot/Model/Device.pm
index d8e2738,5e7288c..54526ae
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@@ -1442,9 -1435,8 +1447,10 @@@ sub discover
auth_pass =>
$argv{auth_pass},
priv_proto =>
$argv{priv_proto},
priv_pass =>
$argv{priv_pass},
+ sqe => $argv{sqe},
);
+
+ return unless $sinfo;
}
$info = $class->_exec_timeout($name,
sub{ return
$class->get_snmp_info(session => $sinfo,
@@@ -2719,10 -2712,8 +2726,11 @@@ sub snmp_update
auth_pass => $argv{auth_pass},
priv_proto => $argv{priv_proto},
priv_pass => $argv{priv_pass},
+ sqe => $argv{sqe},
);
+
+ return unless $sinfo;
+
}
# Re-bless into appropriate sub-class if needed
commit 46f8193cb6a015bec25b6c7db8cf212861f6776d
Author: Anton Berezin <[email protected]>
Date: Mon Oct 22 12:43:48 2012 +0200
First shot at using SQE for parallel SNMP updates.
diff --git a/etc/Default.conf b/etc/Default.conf
index cd72928..e87d89b 100644
--- a/etc/Default.conf
+++ b/etc/Default.conf
@@ -222,6 +222,9 @@ SNMP_MIB_DIRS => [ 'allied', 'arista', 'aruba',
'asante',
'hp', 'juniper', 'netscreen', 'net-snmp',
'nortel', 'rfc' ],
+# Experimental: use snmp-query-engine for SNMP queries
+## USE_SNMP_QUERY_ENGINE => "127.0.0.1:7667",
+
# Some versions of the SNMP perl module are broken.
# Enable this flag if you know your module has been patched
IGNORE_BUGGY_SNMP_CHECK => 0,
diff --git a/lib/Netdot/FakeSNMPSession.pm b/lib/Netdot/FakeSNMPSession.pm
new file mode 100644
index 0000000..691e810
--- /dev/null
+++ b/lib/Netdot/FakeSNMPSession.pm
@@ -0,0 +1,126 @@
+package Netdot::FakeSNMPSession;
+
+use strict;
+use warnings;
+use Carp;
+use Coro;
+use AnyEvent;
+use Net::SNMP::QueryEngine::AnyEvent;
+use Socket;
+use SNMP; # we use that for OID translation
+
+sub new
+{
+ my ($class, %p) = @_;
+ my $me = bless \%p, $class;
+ $me->_self_check;
+
+ my %setopt;
+ $setopt{version} = $me->{Version};
+ $setopt{community} = $me->{Community} || "public";
+ $setopt{timeout} = int($me->{Timeout}/1000+0.5) if $me->{Timeout};
+ $setopt{retries} = $me->{Retries} if $me->{Retries};
+ $setopt{max_repetitions} = $me->{BulkRepeaters} if $me->{BulkRepeaters};
+
+ # XXX Handle DestHost name resolution here. Use AnyEvent::DNS for that.
+ # kinda working method: $me->{ip} = inet_ntoa(scalar gethostbyname
$p{DestHost});
+ $me->{ip} = $me->{DestHost};
+
+ my $callback = rouse_cb;
+ $me->{sqe}->setopt($me->{ip}, 161, \%setopt, $callback);
+ rouse_wait $callback; # no reason to check for errors here
+
+ $me;
+}
+
+sub _self_check
+{
+ my $me = shift;
+ for my $p (qw(sqe DestHost Version)) {
+ croak("$class::new: argument \"$p\" must be supplied") unless $me->{$p};
+ }
+ croak("$class::new: unsupported SNMP version: $me->{Version}")
+ unless $me->{Version} == 1 || $me->{Version} == 2;
+}
+
+sub DESTROY {}
+
+sub AUTOLOAD
+{
+ croak("IMPLEMENT ME: called $Netdot::FakeSNMPSession::AUTOLOAD");
+}
+
+sub get
+{
+ my ($me, $v, $cb) = @_;
+
+ croak("IMPLEMENT ME: GET var is a reference")
+ if ref $v;
+
+ my $oid = $v;
+ $oid = SNMP::translateObj($oid) unless $oid =~ /^[\d.]+$/;
+ $oid =~ s/^\.//;
+
+ my $callback = rouse_cb;
+ $me->{sqe}->get($me->{ip}, 161, [$oid], $callback);
+ my ($sqe, $ok, $res) = rouse_wait $callback;
+
+ # XXX error handling MUST be implemented here
+
+ return unless $res && @$res;
+ my $ret = $res->[0][1];
+ $ret = "NOSUCHOBJECT" if ref $ret && $ret->[0] eq "no-such-object";
+ return if ref $ret; # error in reply
+
+ # SNMP::Info expects OIDs in a form ".a.b.c", while
+ # SQE returns OIDSs in "a.b.c" form, account for that:
+ $ret = ".$ret" if $ret =~ /^1\.3\.6(?:\.\d+)+$/;
+
+ return $ret;
+}
+
+sub bulkwalk
+{
+ my ($me, $non_repeaters, $max_repeaters, $vars) = @_;
+ croak "Internal: non-zero non-repeaters value not supported"
+ if $non_repeaters;
+ croak "Vars must be a reference"
+ unless ref $vars;
+ croak "Internal: only SNMP::Varbind vars are supported"
+ unless ref($vars) eq "SNMP::Varbind";
+
+ my $oid = $vars->[0];
+ $oid = SNMP::translateObj($oid) unless $oid =~ /^[\d.]+$/;
+ $oid =~ s/^\.//;
+
+ #print "bulkwalk: $oid, R($max_repeaters)\n";
+ my $callback = rouse_cb;
+ # XXX non-default port
+ $me->{sqe}->gettable($me->{ip}, 161, $oid, $callback);
+ my ($sqe, $ok, $res) = rouse_wait $callback;
+ #print "Ahaha $sqe,$ok\n";
+
+ #my $real = $me->{debug_session}->bulkwalk($non_repeaters,
$max_repeaters, $vars);
+ #print "Real thing:\n";
+ #dd $real;
+
+#print "GOT TABLE from $oid ($vars->[0])\n";
+ # XXX error handling
+ my @r;
+ for my $r (@$res) {
+ my $v = $r->[1];
+ $v = "NOSUCHOBJECT" if ref $v && $v->[0] eq "no-such-object";
+ next if ref $v;
+ my $idx = $r->[0];
+ $idx =~ s/^\.?\Q$oid\E\.//;
+
+ $v = ".$v" if $v =~ /^1\.3\.6(?:\.\d+)+$/;
+ push @r, bless([ $vars->[0], $idx, $v, "OCTETSTR" ],
"SNMP::Varbind");
+ }
+ #print "Unreal thing:\n";
+ #dd [bless(\@r, "SNMP::VarList")];
+
+ return (bless(\@r, "SNMP::VarList"));
+}
+
+1;
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 3b7fdb4..5e7288c 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -3,11 +3,16 @@ package Netdot::Model::Device;
use base 'Netdot::Model';
use warnings;
use strict;
+use Coro;
+use AnyEvent;
+use Coro::AnyEvent;
use SNMP::Info;
use Netdot::Util::DNS;
use Netdot::Topology;
use Parallel::ForkManager;
use Data::Dumper;
+use Netdot::FakeSNMPSession;
+use Net::SNMP::QueryEngine::AnyEvent;
=head1 NAME
@@ -1430,6 +1435,7 @@ sub discover {
auth_pass =>
$argv{auth_pass},
priv_proto =>
$argv{priv_proto},
priv_pass =>
$argv{priv_pass},
+ sqe => $argv{sqe},
);
}
$info = $class->_exec_timeout($name,
@@ -1534,7 +1540,8 @@ sub discover {
my %uargs;
foreach my $field ( qw(communities version timeout retries
sec_name sec_level auth_proto auth_pass priv_proto
priv_pass
- add_subnets subs_inherit bgp_peers pretend do_info
do_fwt do_arp timestamp) ){
+ add_subnets subs_inherit bgp_peers pretend do_info
do_fwt do_arp timestamp
+ sqe) ){
$uargs{$field} = $argv{$field} if defined ($argv{$field});
}
$uargs{session} = $sinfo if $sinfo;
@@ -2705,6 +2712,7 @@ sub snmp_update {
auth_pass => $argv{auth_pass},
priv_proto => $argv{priv_proto},
priv_pass => $argv{priv_pass},
+ sqe => $argv{sqe},
);
}
@@ -3805,6 +3813,16 @@ sub _layer_active {
# 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) = @_;
@@ -3869,10 +3887,11 @@ sub _get_snmp_session {
BulkWalk => (defined $argv{bulkwalk}) ? $argv{bulkwalk} :
$self->config->get('DEFAULT_SNMPBULK'),
BulkRepeaters => $self->config->get('DEFAULT_SNMPBULK_MAX_REPEATERS'),
MibDirs => \@MIBDIRS,
+ sqe => $argv{sqe},
);
# Turn off bulkwalk if we're using Net-SNMP 5.2.3 or 5.3.1.
- if ( $sinfoargs{BulkWalk} == 1 && ($SNMP::VERSION eq '5.0203' ||
$SNMP::VERSION eq '5.0301')
+ if ( !$sinfoargs{sqe} && $sinfoargs{BulkWalk} == 1 && ($SNMP::VERSION eq
'5.0203' || $SNMP::VERSION eq '5.0301')
&& !$self->config->get('IGNORE_BUGGY_SNMP_CHECK')) {
$logger->info("Turning off bulkwalk due to buggy Net-SNMP
$SNMP::VERSION");
$sinfoargs{BulkWalk} = 0;
@@ -3911,7 +3930,7 @@ sub _get_snmp_session {
$logger->debug(sub{ sprintf("Device::get_snmp_session: Trying SNMPv%d
session with %s",
$sinfoargs{Version}, $argv{host})});
- $sinfo = $sclass->new( %sinfoargs );
+ $sinfo = $self->_make_sinfo_object($sclass, %sinfoargs);
if ( defined $sinfo ){
# Check for errors
@@ -3938,14 +3957,14 @@ sub _get_snmp_session {
$logger->debug(sub{ sprintf("Device::_get_snmp_session: Trying
SNMPv%d session with %s, ".
"community %s",
$sinfoargs{Version}, $argv{host},
$sinfoargs{Community})});
- $sinfo = $sclass->new( %sinfoargs );
+ $sinfo = $self->_make_sinfo_object($sclass, %sinfoargs);
# If v2 failed, try v1
if ( !defined $sinfo && $sinfoargs{Version} == 2 ){
$logger->debug(sub{ sprintf("Device::_get_snmp_session: %s:
SNMPv%d failed. Trying SNMPv1",
$argv{host}, $sinfoargs{Version})});
$sinfoargs{Version} = 1;
- $sinfo = $sclass->new( %sinfoargs );
+ $sinfo = $self->_make_sinfo_object($sclass, %sinfoargs);
}
if ( defined $sinfo ){
@@ -4296,6 +4315,45 @@ sub _fork_end {
sub _snmp_update_parallel {
my ($class, %argv) = @_;
$class->isa_class_method('_snmp_update_parallel');
+ my $use_sqe = Netdot->config->get('USE_SNMP_QUERY_ENGINE');
+ my $sqe;
+ if ($use_sqe) {
+ my @conn = split /:/, $use_sqe;
+ my $check_done = AnyEvent->condvar;
+ eval {
+ $sqe = Net::SNMP::QueryEngine::AnyEvent->new(connect => \@conn,
+ on_connect => sub { $check_done->send },
+ on_error => sub { $sqe = undef; $check_done->send },
+ );
+ $check_done->recv;
+ if ($sqe) {
+ $sqe->info(sub { my ($h,$ok,$r) = @_; $sqe = undef unless $ok
});
+ $sqe->wait;
+ }
+ };
+ }
+ if ($sqe) {
+ $logger->info("SQE is requested and available, using it for SNMP
collection");
+ $logger->debug("$class\::_snmp_update_parallel: Loading dummy
SNMP::Info object");
+ my $dummy = SNMP::Info->new( DestHost => 'localhost',
+ Version => 1,
+ AutoSpecify => 0,
+ Debug => ( $logger->is_debug() )? 1
: 0,
+ MibDirs => \@MIBDIRS,
+ );
+ $class->_snmp_update_parallel_sqe(%argv, sqe => $sqe);
+ } else {
+ if ($use_sqe) {
+ $logger->info("SQE is NOT available, using traditional method for
SNMP collection");
+ } else {
+ $logger->info("Using traditional method for SNMP collection");
+ }
+ $class->_snmp_update_parallel_traditional(%argv);
+ }
+}
+
+sub _snmp_update_parallel_args_check {
+ my ($class, %argv) = @_;
my ($hosts, $devs);
if ( defined $argv{hosts} ){
@@ -4310,16 +4368,143 @@ sub _snmp_update_parallel {
$class->throw_fatal("Model::Device::_snmp_update_parallel: Missing
required parameters: ".
"hosts or devs");
}
-
+
my %uargs;
foreach my $field ( qw(version timeout retries sec_name sec_level
auth_proto auth_pass
priv_proto priv_pass add_subnets subs_inherit
bgp_peers pretend
- do_info do_fwt do_arp) ){
+ do_info do_fwt do_arp sqe) ){
$uargs{$field} = $argv{$field} if defined ($argv{$field});
}
$uargs{no_update_tree} = 1;
$uargs{timestamp} = $class->timestamp;
+
+ return ($hosts, $devs, %uargs);
+}
+
+sub _snmp_update_get_device_args {
+ my ($class, $dev, %args) = @_;
+
+ if ( $args{do_info} ){
+ unless ( $dev->canautoupdate ){
+ $logger->debug(sub{ sprintf("%s: Auto Update option off",
$dev->fqdn) });
+ $args{do_info} = 0;
+ }
+ }
+ if ( $args{do_fwt} ){
+ unless ( $dev->collect_fwt ){
+ $logger->debug(sub{ sprintf("%s: Collect FWT option off",
$dev->fqdn) });
+ $args{do_fwt} = 0;
+ }
+ }
+ if ( $args{do_arp} ){
+ unless ( $dev->collect_arp ){
+ $logger->debug(sub{ sprintf("%s: Collect ARP option off",
$dev->fqdn) });
+ $args{do_arp} = 0;
+ }
+ }
+
+ return %args;
+}
+
+sub _snmp_update_parallel_sqe {
+ my ($class, %argv) = @_;
+ $class->isa_class_method('_snmp_update_parallel_sqe');
+
+ my ($hosts, $devs, %uargs) =
$class->_snmp_update_parallel_args_check(%argv);
+
+ my %do_devs;
+
+ my $device_count = 0;
+ my $n_polling_devices = 0;
+ my $start = time;
+
+ if ( $devs ){
+ foreach my $dev ( @$devs ){
+ # Put in list
+ $do_devs{$dev->id} = $dev;
+ }
+ }elsif ( $hosts ){
+ foreach my $host ( keys %$hosts ){
+ # Give preference to the community associated with the host
+ if ( my $commstr = $hosts->{$host} ){
+ $uargs{communities} = [$commstr];
+ }else{
+ $uargs{communities} = $argv{communities};
+ }
+ # If the device exists in the DB, we add it to the list
+ my $dev;
+ if ( $dev = $class->search(name=>$host)->first ){
+ $do_devs{$dev->id} = $dev;
+ $logger->debug(sub{ sprintf("%s exists in DB.", $dev->fqdn) });
+ }else{
+ $device_count++;
+ $n_polling_devices++;
+ async {
+ eval { $class->discover(name=> $host, %uargs); };
+ if ( my $e = $@ ){
+ $logger->error($e);
+ exit 1;
+ }
+ $n_polling_devices--;
+ };
+ }
+ }
+ }
+
+ # Go over list of existing devices
+ while ( my ($id, $dev) = each %do_devs ){
+
+ if ( my $regex = $argv{matching} ){
+ unless ( $dev->fqdn =~ /$regex/o ){
+ next;
+ }
+ }
+ # Make sure we don't launch a process unless necessary
+ if ( $dev->is_in_downtime() ){
+ $logger->debug(sub{
sprintf("Model::Device::_snmp_update_parallel_sqe: %s in downtime. Skipping",
$dev->fqdn) });
+ next;
+ }
+
+ my %args = $class->_snmp_update_get_device_args($dev, %uargs);
+ unless ( $args{do_info} || $args{do_fwt} || $args{do_arp} ){
+ next;
+ }
+
+ $device_count++;
+ $n_polling_devices++;
+ async {
+ eval { $dev->snmp_update(%args); };
+ if ( my $e = $@ ){
+ $logger->error($e);
+ exit 1;
+ }
+ $n_polling_devices--;
+ };
+ }
+
+ while ($n_polling_devices > 0) {
+ Coro::AnyEvent::idle_upto(5);
+ Coro::AnyEvent::sleep(0.05);
+ }
+
+ # Rebuild the IP tree if ARP caches were updated
+ if ( $argv{do_arp} ){
+ Ipblock->build_tree(4);
+ Ipblock->build_tree(6);
+ }
+ my $runtime = time - $start;
+ $class->_update_poll_stats($uargs{timestamp}, $runtime);
+
+ return $device_count;
+}
+
+sub _snmp_update_parallel_traditional {
+ my ($class, %argv) = @_;
+ $class->isa_class_method('_snmp_update_parallel_traditional');
+
+ my ($hosts, $devs, %uargs) =
$class->_snmp_update_parallel_args_check(%argv);
+
my %do_devs;
my $device_count = 0;
@@ -4373,33 +4558,16 @@ sub _snmp_update_parallel {
}
# Make sure we don't launch a process unless necessary
if ( $dev->is_in_downtime() ){
- $logger->debug(sub{ sprintf("Model::Device::_snmp_update_parallel:
%s in downtime. Skipping",
+ $logger->debug(sub{
sprintf("Model::Device::_snmp_update_parallel_traditional: %s in downtime.
Skipping",
$dev->fqdn) });
next;
}
- my %args = %uargs;
- if ( $args{do_info} ){
- unless ( $dev->canautoupdate ){
- $logger->debug(sub{ sprintf("%s: Auto Update option off",
$dev->fqdn) });
- $args{do_info} = 0;
- }
- }
- if ( $args{do_fwt} ){
- unless ( $dev->collect_fwt ){
- $logger->debug(sub{ sprintf("%s: Collect FWT option off",
$dev->fqdn) });
- $args{do_fwt} = 0;
- }
- }
- if ( $args{do_arp} ){
- unless ( $dev->collect_arp ){
- $logger->debug(sub{ sprintf("%s: Collect ARP option off",
$dev->fqdn) });
- $args{do_arp} = 0;
- }
- }
+ my %args = $class->_snmp_update_get_device_args($dev, %uargs);
unless ( $args{do_info} || $args{do_fwt} || $args{do_arp} ){
next;
}
+
$device_count++;
# FORK
$pm->start and next;
-----------------------------------------------------------------------
hooks/post-receive
--
Netdot
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 70, Issue 2
*******************************************