When linking to devices, use the DNS name in preference to the IP
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
2.005000_002 -
|
2.005000_002 -
|
||||||
|
|
||||||
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
* When linking to devices, use the DNS name in preference to the IP
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
* Minor fixes to POD
|
* Minor fixes to POD
|
||||||
|
|||||||
@@ -4,17 +4,19 @@ use Dancer ':syntax';
|
|||||||
use Dancer::Plugin::Ajax;
|
use Dancer::Plugin::Ajax;
|
||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
|
use NetAddr::IP::Lite ':lower';
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
register_device_tab({ id => 'addresses', label => 'Addresses' });
|
register_device_tab({ id => 'addresses', label => 'Addresses' });
|
||||||
|
|
||||||
# device interface addresses
|
# device interface addresses
|
||||||
ajax '/ajax/content/device/addresses' => sub {
|
ajax '/ajax/content/device/addresses' => sub {
|
||||||
my $ip = param('q');
|
my $ip = NetAddr::IP::Lite->new(param('q'));
|
||||||
return unless $ip;
|
return unless $ip;
|
||||||
|
|
||||||
my $set = schema('netdisco')->resultset('DeviceIp')
|
my $set = schema('netdisco')->resultset('DeviceIp')
|
||||||
->search({ip => $ip}, {order_by => 'alias'});
|
->search({ip => $ip->addr}, {order_by => 'alias'});
|
||||||
return unless $set->count;
|
return unless $set->count;
|
||||||
|
|
||||||
content_type('text/html');
|
content_type('text/html');
|
||||||
|
|||||||
@@ -4,17 +4,19 @@ use Dancer ':syntax';
|
|||||||
use Dancer::Plugin::Ajax;
|
use Dancer::Plugin::Ajax;
|
||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
|
use NetAddr::IP::Lite ':lower';
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
register_device_tab({ id => 'details', label => 'Details' });
|
register_device_tab({ id => 'details', label => 'Details' });
|
||||||
|
|
||||||
# device details table
|
# device details table
|
||||||
ajax '/ajax/content/device/details' => sub {
|
ajax '/ajax/content/device/details' => sub {
|
||||||
my $ip = param('q');
|
my $ip = NetAddr::IP::Lite->new(param('q'));
|
||||||
return unless $ip;
|
return unless $ip;
|
||||||
|
|
||||||
my $device = schema('netdisco')->resultset('Device')
|
my $device = schema('netdisco')->resultset('Device')
|
||||||
->with_times()->find($ip);
|
->with_times()->find($ip->addr);
|
||||||
return unless $device;
|
return unless $device;
|
||||||
|
|
||||||
content_type('text/html');
|
content_type('text/html');
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ use Dancer ':syntax';
|
|||||||
use Dancer::Plugin::Ajax;
|
use Dancer::Plugin::Ajax;
|
||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
|
use NetAddr::IP::Lite ':lower';
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
register_device_tab({ id => 'netmap', label => 'Neighbors' });
|
register_device_tab({ id => 'netmap', label => 'Neighbors' });
|
||||||
@@ -40,8 +42,9 @@ sub _add_children {
|
|||||||
|
|
||||||
# d3 seems not to use proper ajax semantics, so get instead of ajax
|
# d3 seems not to use proper ajax semantics, so get instead of ajax
|
||||||
get '/ajax/data/device/netmap' => sub {
|
get '/ajax/data/device/netmap' => sub {
|
||||||
my $start = param('q');
|
my $ip = NetAddr::IP::Lite->new(param('q'));
|
||||||
return unless $start;
|
return unless $ip;
|
||||||
|
my $start = $ip->addr;
|
||||||
|
|
||||||
my @devices = schema('netdisco')->resultset('Device')->search({}, {
|
my @devices = schema('netdisco')->resultset('Device')->search({}, {
|
||||||
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
|
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use Dancer ':syntax';
|
|||||||
use Dancer::Plugin::Ajax;
|
use Dancer::Plugin::Ajax;
|
||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
|
use NetAddr::IP::Lite ':lower';
|
||||||
use App::Netdisco::Util::Web (); # for sort_port
|
use App::Netdisco::Util::Web (); # for sort_port
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
@@ -12,11 +13,11 @@ register_device_tab({ id => 'ports', label => 'Ports' });
|
|||||||
|
|
||||||
# device ports with a description (er, name) matching
|
# device ports with a description (er, name) matching
|
||||||
ajax '/ajax/content/device/ports' => sub {
|
ajax '/ajax/content/device/ports' => sub {
|
||||||
my $ip = param('q');
|
my $ip = NetAddr::IP::Lite->new(param('q'));
|
||||||
return unless $ip;
|
return unless $ip;
|
||||||
|
|
||||||
my $set = schema('netdisco')->resultset('DevicePort')
|
my $set = schema('netdisco')->resultset('DevicePort')
|
||||||
->search({'me.ip' => $ip});
|
->search({'me.ip' => $ip->addr});
|
||||||
|
|
||||||
# refine by ports if requested
|
# refine by ports if requested
|
||||||
my $q = param('f');
|
my $q = param('f');
|
||||||
@@ -78,7 +79,7 @@ ajax '/ajax/content/device/ports' => sub {
|
|||||||
template 'ajax/device/ports.tt', {
|
template 'ajax/device/ports.tt', {
|
||||||
results => $results,
|
results => $results,
|
||||||
nodes => $nodes_name,
|
nodes => $nodes_name,
|
||||||
device => $ip,
|
device => $ip->addr,
|
||||||
}, { layout => undef };
|
}, { layout => undef };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ get '/search' => sub {
|
|||||||
if ($nd->count == 1) {
|
if ($nd->count == 1) {
|
||||||
# redirect to device details for the one device
|
# redirect to device details for the one device
|
||||||
redirect uri_for('/device',
|
redirect uri_for('/device',
|
||||||
{tab => 'details', q => $nd->first->ip, f => ''});
|
{tab => 'details', q => $nd->first->dns, f => ''});
|
||||||
}
|
}
|
||||||
params->{'tab'} = 'device';
|
params->{'tab'} = 'device';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
<td>[% row.alias %]</a>
|
<td>[% row.alias %]</a>
|
||||||
<td>[% row.dns.remove(settings.domain_suffix) %]</a>
|
<td>[% row.dns.remove(settings.domain_suffix) %]</a>
|
||||||
<td class="center_cell"><a class="nd_linkcell"
|
<td class="center_cell"><a class="nd_linkcell"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.port %]">[% row.port %]</a></td>
|
href="[% device_ports %]&q=[% params.q | uri %]&f=[% row.port | uri %]">[% row.port %]</a></td>
|
||||||
<td>[% row.device_port.name %]</td>
|
<td>[% row.device_port.name %]</td>
|
||||||
<td><a class="nd_linkcell"
|
<td><a class="nd_linkcell"
|
||||||
href="[% search_device %]&ip=[% row.subnet %]">[% row.subnet %]</a></td>
|
href="[% search_device %]&ip=[% row.subnet | uri %]">[% row.subnet %]</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function to_class(name) { return 'nd_' + name.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&q=' + d.ip;
|
window.location = '[% uri_for('/device') %]?tab=netmap&q=' + (d.name || d.ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handler for mouseover on a circle - show that device's real neighbors
|
// handler for mouseover on a circle - show that device's real neighbors
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
[% IF params.c_neighbors AND row.remote_ip %]
|
[% IF params.c_neighbors AND row.remote_ip %]
|
||||||
[% IF row.neighbor %]
|
[% IF row.neighbor %]
|
||||||
<a href="[% uri_for('/device',
|
<a href="[% uri_for('/device',
|
||||||
self_options) %]&q=[% row.neighbor.ip | uri %]&f=[% row.remote_port | uri %]">
|
self_options) %]&q=[% row.neighbor.dns || row.neighbor.ip | uri %]&f=[% row.remote_port | uri %]">
|
||||||
[% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip %]
|
[% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip %]
|
||||||
([% row.remote_port | html_entity %])</a>
|
([% row.remote_port | html_entity %])</a>
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
[% WHILE (row = results.next) %]
|
[% WHILE (row = results.next) %]
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="[% uri_for('/device') %]?q=[% row.ip %]">[% row.dns.remove(settings.domain_suffix) || row.ip %]</a></td>
|
<td><a href="[% uri_for('/device') %]?q=[% row.dns || row.ip %]">[% row.dns || row.ip %]</a></td>
|
||||||
<td>[% row.contact %]</td>
|
<td>[% row.contact %]</td>
|
||||||
<td>[% row.location %]</td>
|
<td>[% row.location %]</td>
|
||||||
<td>[% row.name %]</td>
|
<td>[% row.name %]</td>
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
[% END %]
|
[% END %]
|
||||||
<td>Switch Port</td>
|
<td>Switch Port</td>
|
||||||
<td><a href="[% device_ports %]&q=[% node.switch | url %]&f=[% node.port | url %]&c_nodes=on&c_neighbor=on">[% node.switch %] [ [% node.port %] ]</a>
|
<td><a href="[% device_ports %]&q=[% node.device.dns || node.switch %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on">[% node.switch %] [ [% node.port %] ]</a>
|
||||||
[% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %]
|
[% ' (' _ node.device.dns _ ')' IF node.device.dns %]
|
||||||
[% ' <span class="label label-warning">A</span>' IF NOT node.active %]
|
[% ' <span class="label label-warning">A</span>' IF NOT node.active %]
|
||||||
</td>
|
</td>
|
||||||
[% IF params.stamps %]
|
[% IF params.stamps %]
|
||||||
|
|||||||
@@ -66,8 +66,8 @@
|
|||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
<td>Switch Port</td>
|
<td>Switch Port</td>
|
||||||
<td><a href="[% device_ports %]&q=[% node.switch | url %]&f=[% node.port | url %]&c_nodes=on&c_neighbor=on">[% node.switch %] [ [% node.port %] ]</a>
|
<td><a href="[% device_ports %]&q=[% node.device.dns || node.switch %]&f=[% node.port %]&c_nodes=on&c_neighbors=on">[% node.switch %] [ [% node.port %] ]</a>
|
||||||
[% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %]
|
[% ' (' _ node.device.dns _ ')' IF node.device.dns %]
|
||||||
[% ' <span class="label label-warning">A</span>' IF NOT node.active %]
|
[% ' <span class="label label-warning">A</span>' IF NOT node.active %]
|
||||||
</td>
|
</td>
|
||||||
[% IF params.stamps %]
|
[% IF params.stamps %]
|
||||||
@@ -97,8 +97,8 @@
|
|||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
<td>Switch Port</td>
|
<td>Switch Port</td>
|
||||||
<td><a href="[% device_ports %]&q=[% port.ip | url %]&f=[% port.port | url %]&c_nodes=on&c_neighbor=on">[% port.ip %] [ [% port.port %] ]</a>
|
<td><a href="[% device_ports %]&q=[% port.device.dns || port.ip %]&f=[% port.port %]&c_mac=on&c_nodes=on&c_neighbors=on">[% port.ip %] [ [% port.port %] ]</a>
|
||||||
[% ' (' _ port.device.dns.remove(settings.domain_suffix) _ ')' IF port.device.dns %]
|
[% ' (' _ port.device.dns _ ')' IF port.device.dns %]
|
||||||
</td>
|
</td>
|
||||||
[% IF params.stamps %]
|
[% IF params.stamps %]
|
||||||
<td>[% port.creation %]</td>
|
<td>[% port.creation %]</td>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
[% WHILE (row = results.next) %]
|
[% WHILE (row = results.next) %]
|
||||||
<tr>
|
<tr>
|
||||||
<td>[% row.name %]</td>
|
<td>[% row.name %]</td>
|
||||||
<td><a href="[% device_ports %]&q=[% row.ip %]&f=[% row.port %]">[% row.ip %] [ [% row.port %] ]</a>
|
<td><a href="[% device_ports %]&q=[% row.device.dns || row.ip %]&f=[% row.port %]">[% row.ip %] [ [% row.port %] ]</a>
|
||||||
[% ' (' _ row.device.dns.remove(settings.domain_suffix) _ ')' IF row.device.dns %]
|
[% ' (' _ row.device.dns _ ')' IF row.device.dns %]
|
||||||
</td>
|
</td>
|
||||||
<td>[% row.descr %]</td>
|
<td>[% row.descr %]</td>
|
||||||
<td>[% row.vlan %]</td>
|
<td>[% row.vlan %]</td>
|
||||||
|
|||||||
@@ -13,17 +13,17 @@
|
|||||||
[% WHILE (row = results.next) %]
|
[% WHILE (row = results.next) %]
|
||||||
<tr>
|
<tr>
|
||||||
<td><a class="nd_linkcell nd_stealthlink"
|
<td><a class="nd_linkcell nd_stealthlink"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.vlan.vlan %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.vlan.vlan %]</a></td>
|
||||||
<td><a class="nd_linkcell"
|
<td><a class="nd_linkcell"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.dns.remove(settings.domain_suffix) || row.ip %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.dns || row.ip %]</a></td>
|
||||||
<td><a class="nd_linkcell nd_stealthlink"
|
<td><a class="nd_linkcell nd_stealthlink"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.vlan.description %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.vlan.description %]</a></td>
|
||||||
<td><a class="nd_linkcell nd_stealthlink"
|
<td><a class="nd_linkcell nd_stealthlink"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.model %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.model %]</a></td>
|
||||||
<td><a class="nd_linkcell nd_stealthlink"
|
<td><a class="nd_linkcell nd_stealthlink"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.os %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.os %]</a></td>
|
||||||
<td><a class="nd_linkcell nd_stealthlink"
|
<td><a class="nd_linkcell nd_stealthlink"
|
||||||
href="[% device_ports %]&q=[% row.ip %]&f=[% row.vlan.vlan %]">[% row.vendor %]</a></td>
|
href="[% device_ports %]&q=[% row.dns || row.ip %]&f=[% row.vlan.vlan %]">[% row.vendor %]</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user