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
[BUG FIXES]

View File

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

View File

@@ -18,7 +18,7 @@ name: App-Netdisco
provides:
App::Netdisco:
file: lib/App/Netdisco.pm
version: '2.036007'
version: '2.036009'
App::Netdisco::AnyEvent::Nbtstat:
file: lib/App/Netdisco/AnyEvent/Nbtstat.pm
App::Netdisco::Backend::Job:
@@ -452,5 +452,5 @@ resources:
homepage: http://netdisco.org/
license: http://opensource.org/licenses/bsd-license.php
repository: https://github.com/netdisco/netdisco
version: '2.036007'
version: '2.036009'
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
for (my $i = $db_version; $i < $target_version; $i++) {
my $next = $i + 1;
try {
$schema->upgrade_single_step($i, $i + 1);
$schema->upgrade_single_step($i, $next);
}
catch {
warn "Error: $_"
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,
});
my $actiontext = (
($job->device ? ('['.$job->device->ip.']') : '') .
($job->action eq 'show' ? ('/'.$job->subaction) : '')
);
# do job
my ($status, $log);
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);
}
catch {

View File

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

View File

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

View File

@@ -12,6 +12,12 @@ The LLDP configuration should look like:
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
Netdsico at this time does not support VRFs. In particular, overlapping IP

View File

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

View File

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