diff --git a/Netdisco/Changes b/Netdisco/Changes
index eeab1a21..d631908d 100644
--- a/Netdisco/Changes
+++ b/Netdisco/Changes
@@ -10,6 +10,9 @@
* [#69] Add search by layers to device search
* [#77] Log user access
+ [BUG FIXES]
+
+ * [#84] No longer use dns as a key into devices; cope with dupe dns (LT)
2.022000 - 2014-01-26
diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm
index 9eb0b61c..add52c7c 100644
--- a/Netdisco/lib/App/Netdisco/Web/Device.pm
+++ b/Netdisco/lib/App/Netdisco/Web/Device.pm
@@ -154,20 +154,29 @@ hook 'before_template' => sub {
get '/device' => require_login sub {
my $q = param('q');
- my $dev = schema('netdisco')->resultset('Device')->single({
+ my $schema = schema('netdisco')->resultset('Device');
+
+ # we are passed either dns or ip
+ my $dev = $schema->search({
-or => [
\[ 'host(me.ip) = ?' => [ bind_value => $q ] ],
'me.dns' => $q,
],
});
- if (!defined $dev) {
+ if ($dev->count == 0) {
return redirect uri_for('/', {nosuchdevice => 1})->path_query;
}
+ # if passed dns, need to check for duplicates
+ # and use only ip for q param, if there are duplicates.
+ my $first = $dev->first;
+ my $others = ($schema->search({dns => $first->dns})->count() - 1);
+
params->{'tab'} ||= 'details';
template 'device', {
d => $dev,
+ display_name => ($others ? $first->ip : $first->dns),
device => params->{'tab'},
};
};
diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm
index 596b83dd..9442ec31 100644
--- a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm
+++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm
@@ -19,13 +19,15 @@ get '/ajax/content/search/device' => require_login sub {
my $set;
if ($has_opt) {
- $set = schema('netdisco')->resultset('Device')->search_by_field(scalar params);
+ $set = schema('netdisco')->resultset('Device')
+ ->with_times->search_by_field(scalar params);
}
else {
my $q = param('q');
send_error('Missing query', 400) unless $q;
- $set = schema('netdisco')->resultset('Device')->search_fuzzy($q);
+ $set = schema('netdisco')->resultset('Device')
+ ->with_times->search_fuzzy($q);
}
return unless $set->count;
diff --git a/Netdisco/lib/App/Netdisco/Web/Search.pm b/Netdisco/lib/App/Netdisco/Web/Search.pm
index 92f48675..511f1452 100644
--- a/Netdisco/lib/App/Netdisco/Web/Search.pm
+++ b/Netdisco/lib/App/Netdisco/Web/Search.pm
@@ -81,7 +81,7 @@ get '/search' => require_login sub {
# redirect to device details for the one device
return redirect uri_for('/device', {
tab => 'details',
- q => ($nd->first->dns || $nd->first->ip),
+ q => $nd->first->ip,
f => '',
})->path_query;
}
diff --git a/Netdisco/share/views/ajax/admintask/orphaned.tt b/Netdisco/share/views/ajax/admintask/orphaned.tt
index b87ebeec..d0a9bda2 100644
--- a/Netdisco/share/views/ajax/admintask/orphaned.tt
+++ b/Netdisco/share/views/ajax/admintask/orphaned.tt
@@ -22,7 +22,7 @@
[% FOREACH row IN orphans %]
-
+
[% row.dns || row.name || row.ip | html_entity %]
[% IF row.location %]
@@ -75,7 +75,7 @@
[% FOREACH row IN network %]
-
+
[% row.dns || row.name || row.ip | html_entity %]
[% IF row.location %]
diff --git a/Netdisco/share/views/ajax/admintask/pseudodevice.tt b/Netdisco/share/views/ajax/admintask/pseudodevice.tt
index 38b63c93..86bfeee4 100644
--- a/Netdisco/share/views/ajax/admintask/pseudodevice.tt
+++ b/Netdisco/share/views/ajax/admintask/pseudodevice.tt
@@ -21,7 +21,7 @@
[% SET count = count + 1 %]
[% row.dns | html_entity %]
+ href="[% uri_for('/device') %]?q=[% row.ip | uri %]">[% row.dns | html_entity %]
[% row.ip | html_entity %]
diff --git a/Netdisco/share/views/ajax/admintask/topology.tt b/Netdisco/share/views/ajax/admintask/topology.tt
index 22ce1746..e311518a 100644
--- a/Netdisco/share/views/ajax/admintask/topology.tt
+++ b/Netdisco/share/views/ajax/admintask/topology.tt
@@ -42,11 +42,11 @@
[% WHILE (row = results.next) %]
[% SET count = count + 1 %]
-
+
[% (row.device1.dns || row.device1.name || row.device1.ip) | html_entity %]
[% row.port1 | html_entity %]
-
+
[% (row.device2.dns || row.device2.name || row.device2.ip) | html_entity %]
[% row.port2 | html_entity %]
diff --git a/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt b/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt
index e3322589..0d1b4d37 100644
--- a/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt
+++ b/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt
@@ -10,7 +10,7 @@
[% FOREACH row IN results %]
-
+
[% row.dns || row.name || row.ip | html_entity %] ( [% row.port | html_entity %] )
[% row.remote_ip | html_entity %]
diff --git a/Netdisco/share/views/ajax/device/details.tt b/Netdisco/share/views/ajax/device/details.tt
index 76e5d329..1990aab1 100644
--- a/Netdisco/share/views/ajax/device/details.tt
+++ b/Netdisco/share/views/ajax/device/details.tt
@@ -136,7 +136,7 @@
[% d.vtp_domain | html_entity %]
[% IF user_has_role('admin') %]
-
+
Admin Tasks
diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt
index 5d952fb7..e6bc1f24 100644
--- a/Netdisco/share/views/ajax/device/ports.tt
+++ b/Netdisco/share/views/ajax/device/ports.tt
@@ -67,7 +67,7 @@
data-animation="" data-title="Click to Enable">
[% END %]
+ href="[% uri_for('/admin/portlog') %]?q=[% device.ip | uri %]&f=[% row.port | uri %]">
@@ -240,7 +240,7 @@
[% END %]
+ self_options) %]&q=[% row.neighbor.ip | uri %]&f=[% row.remote_port | uri %]&prefer=port">
[% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip | html_entity %]
[% ' - ' IF row.remote_port %][% row.remote_port | html_entity %]
[% IF params.neigh_id and (row.remote_id or row.remote_type) %]
diff --git a/Netdisco/share/views/ajax/report/apradiochannelpower.tt b/Netdisco/share/views/ajax/report/apradiochannelpower.tt
index f8890ef5..92ee8171 100644
--- a/Netdisco/share/views/ajax/report/apradiochannelpower.tt
+++ b/Netdisco/share/views/ajax/report/apradiochannelpower.tt
@@ -30,7 +30,7 @@
[% NEXT UNLESS p.channel # No channel port is admin down %]
-
+
[% p.port | html_entity %]
[% p.name %]
[% p.descr %]
diff --git a/Netdisco/share/views/ajax/report/deviceaddrnodns.tt b/Netdisco/share/views/ajax/report/deviceaddrnodns.tt
index f572ccc0..2e674aea 100644
--- a/Netdisco/share/views/ajax/report/deviceaddrnodns.tt
+++ b/Netdisco/share/views/ajax/report/deviceaddrnodns.tt
@@ -10,7 +10,7 @@
[% FOREACH row IN results %]
-
+
[% row.dns || row.name || row.ip | html_entity %]
[% row.alias | html_entity %]
[% row.contact | html_entity %]
@@ -18,4 +18,4 @@
[% END %]
-
\ No newline at end of file
+
diff --git a/Netdisco/share/views/ajax/report/devicebylocation.tt b/Netdisco/share/views/ajax/report/devicebylocation.tt
index d7aa3b67..ab662cf2 100644
--- a/Netdisco/share/views/ajax/report/devicebylocation.tt
+++ b/Netdisco/share/views/ajax/report/devicebylocation.tt
@@ -20,7 +20,7 @@
[Not Set]
[% END %]
- [% row.dns || row.ip | html_entity %]
+ [% row.dns || row.ip | html_entity %]
[% row.name | html_entity %]
diff --git a/Netdisco/share/views/ajax/report/devicednsmismatch.tt b/Netdisco/share/views/ajax/report/devicednsmismatch.tt
index 07aeaa27..0945f24d 100644
--- a/Netdisco/share/views/ajax/report/devicednsmismatch.tt
+++ b/Netdisco/share/views/ajax/report/devicednsmismatch.tt
@@ -11,7 +11,7 @@
[% WHILE (row = results.next) %]
-
+
[% row.name | html_entity %]
[% row.dns | html_entity %]
[% row.ip | html_entity %]
@@ -20,4 +20,4 @@
[% END %]
-
\ No newline at end of file
+
diff --git a/Netdisco/share/views/ajax/report/halfduplex.tt b/Netdisco/share/views/ajax/report/halfduplex.tt
index f5594292..5436fd6b 100644
--- a/Netdisco/share/views/ajax/report/halfduplex.tt
+++ b/Netdisco/share/views/ajax/report/halfduplex.tt
@@ -12,7 +12,7 @@
[% row.device.dns || row.device.ip | html_entity %]
+ href="[% device_ports %]&q=[% row.device.ip | uri %]&f=[% row.port | uri %]&c_duplex=on">
[% row.port | html_entity %]
[% row.name | html_entity %]
[% row.duplex.ucfirst | html_entity %]
diff --git a/Netdisco/share/views/ajax/report/nodemultiips.tt b/Netdisco/share/views/ajax/report/nodemultiips.tt
index e810a8f1..a35872fb 100644
--- a/Netdisco/share/views/ajax/report/nodemultiips.tt
+++ b/Netdisco/share/views/ajax/report/nodemultiips.tt
@@ -14,7 +14,7 @@
[% row.mac.upper | html_entity %]
[% row.vendor | html_entity %]
-
+
[% row.dns || row.name || row.switch | html_entity %] ([% row.port | html_entity %])
[% row.ip_count | format_number %]
diff --git a/Netdisco/share/views/ajax/report/phonesdiscovered.tt b/Netdisco/share/views/ajax/report/phonesdiscovered.tt
index 73992a35..f7d5b6e3 100644
--- a/Netdisco/share/views/ajax/report/phonesdiscovered.tt
+++ b/Netdisco/share/views/ajax/report/phonesdiscovered.tt
@@ -14,7 +14,7 @@
[% row.dns || row.name || row.ip | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
[% row.port | html_entity %]
[% row.remote_id | html_entity %]
[% row.dns || row.name || row.ip | html_entity %]
-
+
[% row.port | html_entity %]
[% row.description | html_entity %]
[% row.up_admin | html_entity %]
diff --git a/Netdisco/share/views/ajax/report/portblocking.tt b/Netdisco/share/views/ajax/report/portblocking.tt
index bd0e53e7..08aa1428 100644
--- a/Netdisco/share/views/ajax/report/portblocking.tt
+++ b/Netdisco/share/views/ajax/report/portblocking.tt
@@ -12,7 +12,7 @@
[% FOREACH row IN results %]
[% row.dns || row.name || row.ip | html_entity %]
-
+
[% row.port | html_entity %]
[% row.description | html_entity %]
[% row.stp | html_entity %]
diff --git a/Netdisco/share/views/ajax/report/portmultinodes.tt b/Netdisco/share/views/ajax/report/portmultinodes.tt
index a0c8cf9a..3a962c31 100644
--- a/Netdisco/share/views/ajax/report/portmultinodes.tt
+++ b/Netdisco/share/views/ajax/report/portmultinodes.tt
@@ -12,7 +12,7 @@
[% FOREACH row IN results %]
[% row.dns || row.name || row.ip | html_entity %]
-
+
[% row.port | html_entity %]
[% row.description | html_entity %]
[% row.mac_count | format_number %]
diff --git a/Netdisco/share/views/ajax/report/portutilization.tt b/Netdisco/share/views/ajax/report/portutilization.tt
index 3c981df0..42dbc896 100644
--- a/Netdisco/share/views/ajax/report/portutilization.tt
+++ b/Netdisco/share/views/ajax/report/portutilization.tt
@@ -11,7 +11,7 @@
[% WHILE (row = results.next) %]
- [% row.dns || row.ip | html_entity %]
+ [% row.dns || row.ip | html_entity %]
[% row.port_count %]
[% row.ports_in_use %]
[% row.ports_shutdown %]
diff --git a/Netdisco/share/views/ajax/search/device.tt b/Netdisco/share/views/ajax/search/device.tt
index 8ee38d10..4fe973a2 100644
--- a/Netdisco/share/views/ajax/search/device.tt
+++ b/Netdisco/share/views/ajax/search/device.tt
@@ -9,12 +9,13 @@
OS Version
Management IP
Serial
+ Last Discovered
[% WHILE (row = results.next) %]
- [% row.dns || row.ip | html_entity %]
+ [% row.dns || row.ip | html_entity %]
[% row.contact | html_entity %]
[% row.location | html_entity %]
[% row.name | html_entity %]
@@ -22,6 +23,7 @@
[% row.os_ver | html_entity %]
[% row.ip | html_entity %]
[% row.serial | html_entity %]
+ [% row.last_discover_stamp | html_entity %]
[% END %]
diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt
index 4bcfae55..5b84a8c3 100644
--- a/Netdisco/share/views/ajax/search/node_by_ip.tt
+++ b/Netdisco/share/views/ajax/search/node_by_ip.tt
@@ -40,7 +40,7 @@
[% END %]
Switch Port
+ href="[% device_ports %]&q=[% node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on">
[% node.switch | html_entity %] - [% node.port | html_entity %]
[% ' ' IF NOT node.active %]
[% IF node.device.dns AND node.device_port AND node.device_port.name %]
diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt
index 5f9b9da7..80fc0725 100644
--- a/Netdisco/share/views/ajax/search/node_by_mac.tt
+++ b/Netdisco/share/views/ajax/search/node_by_mac.tt
@@ -70,7 +70,7 @@
[% END %]
Switch Port
+ href="[% device_ports %]&q=[% node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on">
[% node.switch | html_entity %] - [% node.port | html_entity %]
[% ' ' IF NOT node.active %]
[% IF node.device.dns AND node.device_port AND node.device_port.name %]
@@ -105,7 +105,7 @@
[% END %]
Switch Port
+ href="[% device_ports %]&q=[% port.ip | uri %]&f=[% port.port | uri %]&c_mac=on&c_nodes=on&c_neighbors=on">
[% port.ip | html_entity %] - [% port.descr | html_entity %]
[% IF port.device.dns AND port.name %]
([% port.device.dns | html_entity %] - [% port.name | html_entity %])
diff --git a/Netdisco/share/views/ajax/search/port.tt b/Netdisco/share/views/ajax/search/port.tt
index 88416bb1..3266cd7a 100644
--- a/Netdisco/share/views/ajax/search/port.tt
+++ b/Netdisco/share/views/ajax/search/port.tt
@@ -11,7 +11,7 @@
[% WHILE (row = results.next) %]
[% row.name | html_entity %]
-
+
[% row.ip | html_entity %] [ [% row.port | html_entity %] ]
[% ' (' _ row.device.dns _ ')' IF row.device.dns %]
diff --git a/Netdisco/share/views/ajax/search/vlan.tt b/Netdisco/share/views/ajax/search/vlan.tt
index 8b128770..25a1ab6f 100644
--- a/Netdisco/share/views/ajax/search/vlan.tt
+++ b/Netdisco/share/views/ajax/search/vlan.tt
@@ -13,17 +13,17 @@
[% WHILE (row = results.next) %]
[% row.vlan.vlan | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.vlan | html_entity %]
[% row.dns || row.ip | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.dns || row.ip | html_entity %]
[% row.vlan.description | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.description | html_entity %]
[% row.model | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.model | html_entity %]
[% row.os | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.os | html_entity %]
[% row.vendor | html_entity %]
+ href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vendor | html_entity %]
[% END %]
diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt
index cdb17e84..0279bce4 100644
--- a/Netdisco/share/views/layouts/main.tt
+++ b/Netdisco/share/views/layouts/main.tt
@@ -116,7 +116,7 @@