Merge branch 'master' into og-coreplugins

This commit is contained in:
Oliver Gorwits
2017-08-14 18:10:29 +01:00
10 changed files with 70 additions and 38 deletions

23
Changes
View File

@@ -1,3 +1,26 @@
2.036010 -
[ENHANCEMENTS]
* Add note on D-Link LLDP config (H. Erasmus)
2.036009 - 2017-08-01
[ENHANCEMENTS]
* #333 Show netdisco-do target device in log message at start
[BUG FIXES]
* #334 DB schema is not upgraded past v40
* #335 No such device when clicking on device in netmap
2.036008 - 2017-07-14
[BUG FIXES]
* revert change to Device ResultSet which breaks search_for_device()
2.036007 - 2017-07-12 2.036007 - 2017-07-12
[BUG FIXES] [BUG FIXES]

View File

@@ -99,7 +99,7 @@
"provides" : { "provides" : {
"App::Netdisco" : { "App::Netdisco" : {
"file" : "lib/App/Netdisco.pm", "file" : "lib/App/Netdisco.pm",
"version" : "2.036007" "version" : "2.036009"
}, },
"App::Netdisco::AnyEvent::Nbtstat" : { "App::Netdisco::AnyEvent::Nbtstat" : {
"file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm"
@@ -658,6 +658,6 @@
"x_IRC" : "irc://irc.freenode.org/#netdisco", "x_IRC" : "irc://irc.freenode.org/#netdisco",
"x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users"
}, },
"version" : "2.036007", "version" : "2.036009",
"x_serialization_backend" : "JSON::PP version 2.94" "x_serialization_backend" : "JSON::PP version 2.94"
} }

View File

@@ -18,7 +18,7 @@ name: App-Netdisco
provides: provides:
App::Netdisco: App::Netdisco:
file: lib/App/Netdisco.pm file: lib/App/Netdisco.pm
version: '2.036007' version: '2.036009'
App::Netdisco::AnyEvent::Nbtstat: App::Netdisco::AnyEvent::Nbtstat:
file: lib/App/Netdisco/AnyEvent/Nbtstat.pm file: lib/App/Netdisco/AnyEvent/Nbtstat.pm
App::Netdisco::Backend::Job: App::Netdisco::Backend::Job:
@@ -452,5 +452,5 @@ resources:
homepage: http://netdisco.org/ homepage: http://netdisco.org/
license: http://opensource.org/licenses/bsd-license.php license: http://opensource.org/licenses/bsd-license.php
repository: https://github.com/netdisco/netdisco repository: https://github.com/netdisco/netdisco
version: '2.036007' version: '2.036009'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

View File

@@ -126,12 +126,17 @@ my $target_version = $schema->schema_version;
# one step at a time, in case user has applied local changes already # one step at a time, in case user has applied local changes already
for (my $i = $db_version; $i < $target_version; $i++) { for (my $i = $db_version; $i < $target_version; $i++) {
my $next = $i + 1;
try { try {
$schema->upgrade_single_step($i, $i + 1); $schema->upgrade_single_step($i, $next);
} }
catch { catch {
warn "Error: $_" warn "Error: $_"
if $_ !~ m/(does not exist|already exists)/; if $_ !~ m/(does not exist|already exists)/;
# set row in dbix_class_schema_versions table
$schema->_set_db_version({version => $next})
if $schema->get_db_version < $next;
}; };
} }

View File

@@ -241,10 +241,17 @@ foreach my $host (@hostlist) {
subaction => $extra, subaction => $extra,
}); });
my $actiontext = (
($job->device ? ('['.$job->device->ip.']') : '') .
($job->action eq 'show' ? ('/'.$job->subaction) : '')
);
# do job # do job
my ($status, $log); my ($status, $log);
try { try {
info sprintf '%s: started at %s', $action, scalar localtime;
info sprintf '%s: %s started at %s',
$action, $actiontext, scalar localtime;
($status, $log) = $worker->$action($job); ($status, $log) = $worker->$action($job);
} }
catch { catch {

View File

@@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use 5.010_000; use 5.010_000;
our $VERSION = '2.036007'; our $VERSION = '2.036009';
use App::Netdisco::Configuration; use App::Netdisco::Configuration;
=head1 NAME =head1 NAME

View File

@@ -96,7 +96,7 @@ sub search_aliases {
{ {
order_by => [qw/ me.dns me.ip /], order_by => [qw/ me.dns me.ip /],
join => 'device_ips', join => 'device_ips',
group_by => 'me.ip', distinct => 1,
} }
); );
} }

View File

@@ -12,6 +12,12 @@ The LLDP configuration should look like:
interface all; interface all;
} }
=head1 Neighbor Relations on D-Link
Add the following to your devices (changing the port numbers appropriately):
config lldp ports 1-28 mgt_addr ipv4 enable
=head1 VRFs and NXOS =head1 VRFs and NXOS
Netdsico at this time does not support VRFs. In particular, overlapping IP Netdsico at this time does not support VRFs. In particular, overlapping IP

View File

@@ -34,9 +34,8 @@ sub _add_children {
var('seen')->{$c}++; var('seen')->{$c}++;
push @legit, $c; push @legit, $c;
push @{$ptr}, { push @{$ptr}, {
name => _get_name($c),
fullname => (var('devices')->{$c} || $c),
ip => $c, ip => $c,
name => _get_name($c),
}; };
} }
@@ -93,8 +92,7 @@ get '/ajax/data/device/netmap' => require_login sub {
my %tree = ( my %tree = (
ip => $start, ip => $start,
name => _get_name($start), name => _get_name($start), # dns or sysname or ip
fullname => (var('devices')->{$start} || $start),
children => [], children => [],
); );
@@ -107,20 +105,13 @@ get '/ajax/data/device/netmap' => require_login sub {
}; };
ajax '/ajax/data/device/alldevicelinks' => require_login sub { ajax '/ajax/data/device/alldevicelinks' => require_login sub {
my @devices = schema('netdisco')->resultset('Device')->search({}, {
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
columns => ['ip', 'dns'],
})->all;
var(devices => { map { $_->{ip} => $_->{dns} } @devices });
my $rs = schema('netdisco')->resultset('Virtual::DeviceLinks')->search({}, { my $rs = schema('netdisco')->resultset('Virtual::DeviceLinks')->search({}, {
result_class => 'DBIx::Class::ResultClass::HashRefInflator', result_class => 'DBIx::Class::ResultClass::HashRefInflator',
}); });
my %tree = (); my %tree = ();
while (my $l = $rs->next) { while (my $l = $rs->next) {
push @{ $tree{ _get_name($l->{left_ip} )} }, push @{ $tree{ $l->{left_ip} } }, $l->{right_ip};
_get_name($l->{right_ip});
} }
content_type('application/json'); content_type('application/json');

View File

@@ -45,19 +45,19 @@ function redraw() {
// save the x,y of an element into the loc dictionary // save the x,y of an element into the loc dictionary
function recordLocation(d,i) { function recordLocation(d,i) {
var rect = this.getBoundingClientRect(); var rect = this.getBoundingClientRect();
loc[d.name] = { loc[d.ip] = {
'x': (rect.left + ((rect.right - rect.left) / 2)) 'x': (rect.left + ((rect.right - rect.left) / 2))
,'y': (rect.top + ((rect.bottom - rect.top) / 2)) ,'y': (rect.top + ((rect.bottom - rect.top) / 2))
}; };
} }
// convert a device name to a valid CSS class name // convert a device ip to a valid CSS class name
function to_class(name) { return 'nd_' + name.replace(/\./g, "_") } function to_class(ip) { return 'nd_' + ip.replace(/[:.]/g, "_") }
// handler for clicking on a circle - redirect to that device's netmap // handler for clicking on a circle - redirect to that device's netmap
function circleClick(d) { function circleClick(d) {
window.location = '[% uri_for('/device') %]?tab=netmap' window.location = '[% uri_for('/device') %]?tab=netmap'
+ '&q=' + d.fullname + '&q=' + d.ip
+ '&depth=[% params.depth | uri %]' + '&depth=[% params.depth | uri %]'
+ '&vlan=[% params.vlan | uri %]'; + '&vlan=[% params.vlan | uri %]';
} }
@@ -65,10 +65,10 @@ function circleClick(d) {
// handler for mouseover on a circle - show that device's real neighbors // handler for mouseover on a circle - show that device's real neighbors
function circleOver(d) { function circleOver(d) {
$('.link').hide(); $('.link').hide();
$('path.' + to_class(d.name)).show(); $('path.' + to_class(d.ip)).show();
$(this).css('cursor', 'pointer'); $(this).css('cursor', 'pointer');
$.each(neighbors_data[d.name], function(idx, target) { $.each(neighbors_data[d.ip], function(idx, target) {
if (! (target in loc)) { return true } if (! (target in loc)) { return true }
$('circle.' + to_class(target)).css('fill', '#e96cfa'); $('circle.' + to_class(target)).css('fill', '#e96cfa');
}); });
@@ -76,13 +76,13 @@ function circleOver(d) {
// handler for mouseout on a circle - hide real neighbours and show treeLinks // handler for mouseout on a circle - hide real neighbours and show treeLinks
function circleOut(d) { function circleOut(d) {
$.each(neighbors_data[d.name], function(idx, target) { $.each(neighbors_data[d.ip], function(idx, target) {
if (! (target in loc)) { return true } if (! (target in loc)) { return true }
$('circle.' + to_class(target)).css('fill', '#fff'); $('circle.' + to_class(target)).css('fill', '#fff');
}); });
$(this).css('cursor', 'auto'); $(this).css('cursor', 'auto');
$('path.' + to_class(d.name)).hide(); $('path.' + to_class(d.ip)).hide();
$('.link').show(); $('.link').show();
} }
@@ -121,7 +121,7 @@ $.getJSON('[% uri_for('/ajax/data/device/alldevicelinks') %]', function(data) {
node.append("circle") node.append("circle")
.attr("r", 4.5) .attr("r", 4.5)
// circle has class name of its device, so we can show/hide it // circle has class name of its device, so we can show/hide it
.attr("class", function(d) { return to_class(d.name) }) .attr("class", function(d) { return to_class(d.ip) })
// store the x,y of every circle we've just drawn // store the x,y of every circle we've just drawn
.each(recordLocation) .each(recordLocation)
// handlers for mouse interaction with the circles // handlers for mouse interaction with the circles
@@ -140,8 +140,8 @@ $.getJSON('[% uri_for('/ajax/data/device/alldevicelinks') %]', function(data) {
.attr("transform", function(d) { .attr("transform", function(d) {
return d.x < 180 ? "rotate(0)translate(0)" : "rotate(180)translate(0)"; }); return d.x < 180 ? "rotate(0)translate(0)" : "rotate(180)translate(0)"; });
// key (name) of the root node in our locations store // key (ip) of the root node in our locations store
var rootname = svg.select(".node").data()[0].name; var rootname = svg.select(".node").data()[0].ip;
// reformatted neighbors_data for the real neighbor links // reformatted neighbors_data for the real neighbor links
var neighbors = []; var neighbors = [];
@@ -150,19 +150,19 @@ $.getJSON('[% uri_for('/ajax/data/device/alldevicelinks') %]', function(data) {
$.each(neighbors_data, function(key, val) { $.each(neighbors_data, function(key, val) {
if (! (key in loc)) { return true } if (! (key in loc)) { return true }
$.each(val, function(idx, name) { $.each(val, function(idx, ip) {
if (! (name in loc)) { return true } if (! (ip in loc)) { return true }
neighbors.push({ neighbors.push({
'source': { 'source': {
'name': key 'ip': key
,'x': loc[key]['x'] ,'x': loc[key]['x']
,'y': loc[key]['y'] ,'y': loc[key]['y']
} }
,'target': { ,'target': {
'name': name 'ip': ip
,'x': loc[name]['x'] ,'x': loc[ip]['x']
,'y': loc[name]['y'] ,'y': loc[ip]['y']
} }
}); });
}); });
@@ -174,7 +174,7 @@ $.getJSON('[% uri_for('/ajax/data/device/alldevicelinks') %]', function(data) {
.enter().insert("path", ".node") .enter().insert("path", ".node")
// add class name of source device, so we can show/hide the link // add class name of source device, so we can show/hide the link
// (also "neighbor" class) // (also "neighbor" class)
.attr("class", function(d) { return ("neighbor " + to_class( d.source.name )) }) .attr("class", function(d) { return ("neighbor " + to_class( d.source.ip )) })
.attr("d", neighLink) .attr("d", neighLink)
.attr("transform", "translate(-" + loc[rootname]['x'] + ",-" + loc[rootname]['y'] + ")"); .attr("transform", "translate(-" + loc[rootname]['x'] + ",-" + loc[rootname]['y'] + ")");
}); });