release 2.012005
Squashed commit of the following: commit a031e3f388af144cb6d729e4b16b174a7caf6de9 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:50:55 2013 +0100 new version - 2.012005 commit a0215a83fb2cd9f3040cfd04e239a1a40367e056 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:47:28 2013 +0100 set last arpnip timestamp commit 824d311a2503cc91a117d4cc5949b0aca0cabdc9 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:28:14 2013 +0100 test release - 2.012003_001 commit d06316eb1ae6a035a2fefd1edd06bfa6ffe38fa8 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:26:44 2013 +0100 Improved handling of automatic macsuck/arpnip after initial discover commit d7c1e7948f22487c0564a884ce94d109a2cdc13c Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:21:51 2013 +0100 add rev. proxy timeout to suggested config commit 040065a50fec4669740ae48ff18352ef7ff3fde1 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:14:15 2013 +0100 remove done job from local queue regardless of exit status commit d0f1d105459c047cc7156d1b4ef897ad27f965bb Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:12:45 2013 +0100 fix no_auth to work with new Auth::Extensible plugin
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
2.012005 - 2013-08-16
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* Improved handling of automatic macsuck/arpnip after initial discover
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
* Fix no_auth to work with new Auth::Extensible plugin
|
||||
* Remove done job from local queue regardless of exit status
|
||||
* Set last arpnip timestamp
|
||||
|
||||
2.012002 - 2013-08-07
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
@@ -45,7 +45,7 @@ requires:
|
||||
Plack: 1.0023
|
||||
Plack::Middleware::Expires: 0.03
|
||||
Role::Tiny: 1.002005
|
||||
SNMP::Info: 3.01
|
||||
SNMP::Info: 3.05
|
||||
SQL::Translator: 0.11016
|
||||
Socket6: 0.23
|
||||
Starman: 0.3008
|
||||
@@ -61,4 +61,4 @@ resources:
|
||||
homepage: http://netdisco.org/
|
||||
license: http://opensource.org/licenses/bsd-license.php
|
||||
repository: git://git.code.sf.net/p/netdisco/netdisco-ng
|
||||
version: 2.012002
|
||||
version: 2.012005
|
||||
|
||||
@@ -32,7 +32,7 @@ requires 'Plack::Middleware::Expires' => 0.03;
|
||||
requires 'Role::Tiny' => 1.002005;
|
||||
requires 'Socket6' => 0.23;
|
||||
requires 'Starman' => 0.3008;
|
||||
requires 'SNMP::Info' => 3.01;
|
||||
requires 'SNMP::Info' => 3.05;
|
||||
requires 'SQL::Translator' => 0.11016;
|
||||
requires 'Template' => 2.24;
|
||||
requires 'YAML' => 0.84;
|
||||
|
||||
@@ -7,7 +7,7 @@ use 5.010_000;
|
||||
use File::ShareDir 'dist_dir';
|
||||
use Path::Class;
|
||||
|
||||
our $VERSION = '2.012002';
|
||||
our $VERSION = '2.012005';
|
||||
|
||||
BEGIN {
|
||||
if (not ($ENV{DANCER_APPDIR} || '')
|
||||
|
||||
@@ -72,6 +72,8 @@ sub do_arpnip {
|
||||
_store_subnet($_, $now) for @subnets;
|
||||
debug sprintf ' [%s] arpnip - processed %s Subnet entries',
|
||||
$device->ip, scalar @subnets;
|
||||
|
||||
$device->update({last_arpnip => \$now});
|
||||
}
|
||||
|
||||
# get an arp table (v4 or v6)
|
||||
|
||||
@@ -5,7 +5,7 @@ use Dancer::Plugin::DBIC 'schema';
|
||||
|
||||
use base 'Exporter';
|
||||
our @EXPORT = ();
|
||||
our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs /;
|
||||
our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs scrub_jobs /;
|
||||
our %EXPORT_TAGS = ( all => \@EXPORT_OK );
|
||||
|
||||
schema('daemon')->deploy;
|
||||
@@ -69,10 +69,17 @@ sub take_jobs {
|
||||
|
||||
sub reset_jobs {
|
||||
my ($wid) = @_;
|
||||
debug "resetting jobs owned by worked $wid to be available";
|
||||
debug "resetting jobs owned by worker $wid to be available";
|
||||
return unless $wid > 1;
|
||||
$queue->search({wid => $wid})
|
||||
->update({wid => 0});
|
||||
}
|
||||
|
||||
sub scrub_jobs {
|
||||
my ($wid) = @_;
|
||||
debug "deleting jobs owned by worker $wid";
|
||||
return unless $wid > 1;
|
||||
$queue->search({wid => $wid})->delete;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -79,6 +79,9 @@ sub close_job {
|
||||
finished => $now,
|
||||
});
|
||||
}
|
||||
|
||||
# remove job from local queue
|
||||
$self->do('scrub_jobs', $self->wid);
|
||||
}
|
||||
catch { $self->sendto('stderr', "error closing job: $_\n") };
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ sub discoverall {
|
||||
device => $_,
|
||||
action => 'discover',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
}} ($devices->all)
|
||||
]);
|
||||
});
|
||||
@@ -43,12 +45,13 @@ sub discoverall {
|
||||
return job_done("Queued discover job for all devices");
|
||||
}
|
||||
|
||||
# queue a discover job for one device, and its *new* neighbors
|
||||
# run a discover job for one device, and its *new* neighbors
|
||||
sub discover {
|
||||
my ($self, $job) = @_;
|
||||
|
||||
my $host = NetAddr::IP::Lite->new($job->device);
|
||||
my $device = get_device($host->addr);
|
||||
my $jobqueue = schema('netdisco')->resultset('Admin');
|
||||
|
||||
if ($device->ip eq '0.0.0.0') {
|
||||
return job_error("discover failed: no device param (need -d ?)");
|
||||
@@ -72,6 +75,33 @@ sub discover {
|
||||
store_modules($device, $snmp);
|
||||
discover_new_neighbors($device, $snmp);
|
||||
|
||||
# if requested, and the device has not yet been arpniped/macsucked, queue now
|
||||
if ($device->in_storage and $job->subaction and $job->subaction eq 'with-nodes') {
|
||||
if (!defined $device->last_macsuck) {
|
||||
schema('netdisco')->txn_do(sub {
|
||||
$jobqueue->create({
|
||||
device => $device->ip,
|
||||
action => 'macsuck',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!defined $device->last_arpnip) {
|
||||
schema('netdisco')->txn_do(sub {
|
||||
$jobqueue->create({
|
||||
device => $device->ip,
|
||||
action => 'arpnip',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return job_done("Ended discover for ". $host->addr);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ After enabling the C<headers>, C<proxy> and C<proxy_http> modules in Apache, a
|
||||
suitable configuration would be:
|
||||
|
||||
ProxyPreserveHost On
|
||||
ProxyPass / http://localhost:5000/
|
||||
ProxyPass / http://localhost:5000/ retry=0 timeout=5
|
||||
ProxyPassReverse / http://localhost:5000/
|
||||
|
||||
ProxyRequests Off
|
||||
@@ -68,7 +68,7 @@ To combine this with Non-root Hosting as above, simply change the paths
|
||||
referenced in the configuration, and set C<path> in your C<deployment.yml> as
|
||||
discussed above. Note there is no trailing slash in the Apache config:
|
||||
|
||||
ProxyPass /netdisco2 http://localhost:5000/netdisco2
|
||||
ProxyPass /netdisco2 http://localhost:5000/netdisco2 retry=0 timeout=5
|
||||
ProxyPassReverse /netdisco2 http://localhost:5000/netdisco2
|
||||
|
||||
To delegate user authentication to Apache, use the C<trust_remote_user> or
|
||||
|
||||
@@ -8,7 +8,7 @@ use Dancer::Plugin::Auth::Extensible;
|
||||
use Try::Tiny;
|
||||
|
||||
sub add_job {
|
||||
my ($jobtype, $device) = @_;
|
||||
my ($jobtype, $device, $subaction) = @_;
|
||||
|
||||
if ($device) {
|
||||
$device = NetAddr::IP::Lite->new($device);
|
||||
@@ -16,32 +16,16 @@ sub add_job {
|
||||
if ! $device or $device->addr eq '0.0.0.0';
|
||||
}
|
||||
|
||||
# job might already be in the queue, so this could die
|
||||
try {
|
||||
# jobs might already be in the queue, so this could die
|
||||
schema('netdisco')->resultset('Admin')->create({
|
||||
($device ? (device => $device->addr) : ()),
|
||||
action => $jobtype,
|
||||
($subaction ? (subaction => $subaction) : ()),
|
||||
status => 'queued',
|
||||
username => session('logged_in_user'),
|
||||
userip => request->remote_address,
|
||||
});
|
||||
|
||||
if (param('extra') and param('extra') eq 'with-walk') {
|
||||
schema('netdisco')->resultset('Admin')->create({
|
||||
action => 'macwalk',
|
||||
subaction => 'after-discoverall',
|
||||
status => 'queued',
|
||||
username => session('logged_in_user'),
|
||||
userip => request->remote_address,
|
||||
});
|
||||
schema('netdisco')->resultset('Admin')->create({
|
||||
action => 'arpwalk',
|
||||
subaction => 'after-discoverall',
|
||||
status => 'queued',
|
||||
username => session('logged_in_user'),
|
||||
userip => request->remote_address,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,14 +47,14 @@ foreach my $jobtype (keys %jobs_all, keys %jobs) {
|
||||
send_error('Missing device', 400)
|
||||
if exists $jobs{$jobtype} and not param('device');
|
||||
|
||||
add_job($jobtype, param('device'));
|
||||
add_job($jobtype, param('device'), param('extra'));
|
||||
};
|
||||
|
||||
post "/admin/$jobtype" => require_role admin => sub {
|
||||
send_error('Missing device', 400)
|
||||
if exists $jobs{$jobtype} and not param('device');
|
||||
|
||||
add_job($jobtype, param('device'));
|
||||
add_job($jobtype, param('device'), param('extra'));
|
||||
redirect uri_for('/admin/jobqueue')->as_string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ hook 'before' => sub {
|
||||
if (! session('logged_in_user') && request->path ne uri_for('/login')->path) {
|
||||
if (setting('trust_x_remote_user') and scalar request->header('X-REMOTE_USER')) {
|
||||
session(logged_in_user => scalar request->header('X-REMOTE_USER'));
|
||||
session(logged_in_user_realm => 'users');
|
||||
}
|
||||
elsif (setting('trust_remote_user') and $ENV{REMOTE_USER}) {
|
||||
session(logged_in_user => $ENV{REMOTE_USER});
|
||||
session(logged_in_user_realm => 'users');
|
||||
}
|
||||
elsif (setting('no_auth')) {
|
||||
session(logged_in_user => 'guest');
|
||||
session(logged_in_user_realm => 'users');
|
||||
}
|
||||
else {
|
||||
# user has no AuthN - force to handler for '/'
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<form class="nd_login-form" method="post" action="[% uri_for('/admin/discover') %]">
|
||||
<div class="form-horizontal">
|
||||
<input placeholder="Device hostname or IP" class="span4" name="device" type="text"/>
|
||||
<input type="hidden" name="extra" value="with-walk"/>
|
||||
<input type="hidden" name="extra" value="with-nodes"/>
|
||||
<button type="submit" class="btn btn-info">Discover</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user