No longer use dns as a key into devices; cope with dupe dns
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<tbody>
|
||||
[% FOREACH row IN orphans %]
|
||||
<tr>
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.dns || row.ip | uri %]">
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.ip | uri %]">
|
||||
[% row.dns || row.name || row.ip | html_entity %]</a></td>
|
||||
<td>
|
||||
[% IF row.location %]
|
||||
@@ -75,7 +75,7 @@
|
||||
<tbody>
|
||||
[% FOREACH row IN network %]
|
||||
<tr>
|
||||
<td><a href="[% uri_for('/device') %]?tab=netmap&q=[% row.dns || row.ip | uri %]">
|
||||
<td><a href="[% uri_for('/device') %]?tab=netmap&q=[% row.ip | uri %]">
|
||||
[% row.dns || row.name || row.ip | html_entity %]</a></td>
|
||||
<td>
|
||||
[% IF row.location %]
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
[% SET count = count + 1 %]
|
||||
<tr>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell"
|
||||
href="[% uri_for('/device') %]?q=[% row.dns | uri %]">[% row.dns | html_entity %]</a></td>
|
||||
href="[% uri_for('/device') %]?q=[% row.ip | uri %]">[% row.dns | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell">
|
||||
<input data-form="update" name="ports" type="number" value="[% row.port_count | html_entity %]">
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
[% WHILE (row = results.next) %]
|
||||
[% SET count = count + 1 %]
|
||||
<tr>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell" href="[% uri_for('/device') %]?q=[% row.dev1 | uri %]">
|
||||
<td class="nd_center-cell"><a class="nd_linkcell" href="[% uri_for('/device') %]?q=[% row.device1.ip | uri %]">
|
||||
[% (row.device1.dns || row.device1.name || row.device1.ip) | html_entity %]</a>
|
||||
</td>
|
||||
<td class="nd_center-cell">[% row.port1 | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell" href="[% uri_for('/device') %]?q=[% row.dev2 | uri %]">
|
||||
<td class="nd_center-cell"><a class="nd_linkcell" href="[% uri_for('/device') %]?q=[% row.device2.ip | uri %]">
|
||||
[% (row.device2.dns || row.device2.name || row.device2.ip) | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.port2 | html_entity %]</td>
|
||||
<td class="nd_center-cell">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</tbody>
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td><a href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.port | uri %]">
|
||||
<td><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
||||
[% row.dns || row.name || row.ip | html_entity %] ( [% row.port | html_entity %] ) </a></td>
|
||||
<td><a href="[% search_node %]&q=[% row.remote_ip | uri %]">
|
||||
[% row.remote_ip | html_entity %]</a>
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
<td>[% d.vtp_domain | html_entity %]</td>
|
||||
</tr>
|
||||
[% IF user_has_role('admin') %]
|
||||
<tr data-for-device="[% d.dns || d.ip %]">
|
||||
<tr data-for-device="[% d.ip %]">
|
||||
<td>Admin Tasks</td>
|
||||
<td>
|
||||
<input type="hidden" data-form="discover" value="[% d.ip %]" name="device"/>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
data-animation="" data-title="Click to Enable"></i>
|
||||
[% END %]
|
||||
<a class="nd_log-icon"
|
||||
href="[% uri_for('/admin/portlog') %]?q=[% device.dns || device.ip | uri %]&f=[% row.port | uri %]">
|
||||
href="[% uri_for('/admin/portlog') %]?q=[% device.ip | uri %]&f=[% row.port | uri %]">
|
||||
<i class="icon-file-text-alt"
|
||||
rel="tooltip" data-placement="top" data-offset="3"
|
||||
data-animation="" data-title="View Port Log"></i>
|
||||
@@ -240,7 +240,7 @@
|
||||
<i class="icon-signal"></i>
|
||||
[% END %]
|
||||
<a href="[% uri_for('/device',
|
||||
self_options) %]&q=[% row.neighbor.dns || row.neighbor.ip | uri %]&f=[% row.remote_port | uri %]&prefer=port">
|
||||
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 %]</a><br/>
|
||||
[% IF params.neigh_id and (row.remote_id or row.remote_type) %]
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
[% NEXT UNLESS p.channel # No channel port is admin down %]
|
||||
<tr>
|
||||
<td>
|
||||
<a href="[% device_ports %]&q=[% results.$row.device.dns || results.$row.device.ip | uri %]&f=[% p.port | uri %]">
|
||||
<a href="[% device_ports %]&q=[% results.$row.device.ip | uri %]&f=[% p.port | uri %]">
|
||||
[% p.port | html_entity %]</a></td>
|
||||
<td>[% p.name %]</td>
|
||||
<td>[% p.descr %]</td>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</tbody>
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td class="nd_center-cell"><a href="[% search_device %]&q=[% row.dns || row.ip | uri %]">
|
||||
<td class="nd_center-cell"><a href="[% search_device %]&q=[% row.ip | uri %]">
|
||||
[% row.dns || row.name || row.ip | html_entity %]</a>
|
||||
<td class="nd_center-cell">[% row.alias | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.contact | html_entity %]</td>
|
||||
@@ -18,4 +18,4 @@
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
[Not Set]
|
||||
[% END %]
|
||||
</td>
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.dns || row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td><a href="[% search_device %]&q=[% row.name | uri %]&name=[% row.name | uri %]">
|
||||
[% row.name | html_entity %]</a>
|
||||
</td>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a href="[% search_device %]&q=[% row.dns || row.ip | uri %]">
|
||||
<td><a href="[% search_device %]&q=[% row.ip | uri %]">
|
||||
[% row.name | html_entity %]</a>
|
||||
<td>[% row.dns | html_entity %]</td>
|
||||
<td>[% row.ip | html_entity %]</td>
|
||||
@@ -20,4 +20,4 @@
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<tr>
|
||||
<td>[% row.device.dns || row.device.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% row.device.dns || row.device.ip | uri %]&f=[% row.port | uri %]&c_duplex=on">
|
||||
href="[% device_ports %]&q=[% row.device.ip | uri %]&f=[% row.port | uri %]&c_duplex=on">
|
||||
[% row.port | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.name | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.duplex.ucfirst | html_entity %]</td>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<td class="nd_center-cell"><a href="[% search_node %]&q=[% row.mac.upper | uri %]">
|
||||
[% row.mac.upper | html_entity %]</a>
|
||||
<td class="nd_center-cell">[% row.vendor | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.dns || row.switch | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.switch | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
[% row.dns || row.name || row.switch | html_entity %] ([% row.port | html_entity %])</a></td>
|
||||
<td class="nd_center-cell">[% row.ip_count | format_number %]</td>
|
||||
</tr>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<tr>
|
||||
<td class="nd_center-cell">[% row.dns || row.name || row.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.port | uri %]">
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
||||
[% row.port | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.remote_id | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td>[% row.dns || row.name || row.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
[% row.port | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.description | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.up_admin | html_entity %]</td>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td>[% row.dns || row.name || row.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
[% row.port | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.description | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.stp | html_entity %]</td>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td>[% row.dns || row.name || row.ip | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
|
||||
[% row.port | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.description | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.mac_count | format_number %]</td>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a href="[% device_ports %]&q=[% row.dns || row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td><a href="[% device_ports %]&q=[% row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.port_count %]</td>
|
||||
<td class="nd_center-cell">[% row.ports_in_use %]</td>
|
||||
<td class="nd_center-cell">[% row.ports_shutdown %]</td>
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
<th>OS Version</th>
|
||||
<th>Management IP</th>
|
||||
<th>Serial</th>
|
||||
<th>Last Discovered</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.dns || row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td><a href="[% uri_for('/device') %]?q=[% row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td>[% row.contact | html_entity %]</td>
|
||||
<td>[% row.location | html_entity %]</td>
|
||||
<td>[% row.name | html_entity %]</td>
|
||||
@@ -22,6 +23,7 @@
|
||||
<td>[% row.os_ver | html_entity %]</td>
|
||||
<td>[% row.ip | html_entity %]</td>
|
||||
<td>[% row.serial | html_entity %]</td>
|
||||
<td>[% row.last_discover_stamp | html_entity %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
[% END %]
|
||||
<td>Switch Port</td>
|
||||
<td><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% node.device.dns || node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on">
|
||||
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 %]</a>
|
||||
[% ' <i class="icon-book text-warning"></i> ' IF NOT node.active %]
|
||||
[% IF node.device.dns AND node.device_port AND node.device_port.name %]
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
[% END %]
|
||||
<td>Switch Port</td>
|
||||
<td><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% node.device.dns || node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on">
|
||||
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 %]</a>
|
||||
[% ' <i class="icon-book text-warning"></i> ' IF NOT node.active %]
|
||||
[% IF node.device.dns AND node.device_port AND node.device_port.name %]
|
||||
@@ -105,7 +105,7 @@
|
||||
[% END %]
|
||||
<td>Switch Port</td>
|
||||
<td><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% port.device.dns || port.ip | uri %]&f=[% port.port | uri %]&c_mac=on&c_nodes=on&c_neighbors=on">
|
||||
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 %]</a>
|
||||
[% IF port.device.dns AND port.name %]
|
||||
([% port.device.dns | html_entity %] - [% port.name | html_entity %])
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td>[% row.name | html_entity %]</td>
|
||||
<td><a href="[% device_ports %]&q=[% row.device.dns || row.ip | uri %]&f=[% row.port | uri %]">
|
||||
<td><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
||||
[% row.ip | html_entity %] [ [% row.port | html_entity %] ]</a>
|
||||
[% ' (' _ row.device.dns _ ')' IF row.device.dns %]
|
||||
</td>
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a class="nd_linkcell nd_stealth-link"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.vlan | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.vlan | html_entity %]</a></td>
|
||||
<td><a class="nd_linkcell"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||
<td><a class="nd_linkcell nd_stealth-link"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.description | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vlan.description | html_entity %]</a></td>
|
||||
<td><a class="nd_linkcell nd_stealth-link"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.model | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.model | html_entity %]</a></td>
|
||||
<td><a class="nd_linkcell nd_stealth-link"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.os | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.os | html_entity %]</a></td>
|
||||
<td><a class="nd_linkcell nd_stealth-link"
|
||||
href="[% device_ports %]&q=[% row.dns || row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vendor | html_entity %]</a></td>
|
||||
href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.vlan.vlan | uri %]">[% row.vendor | html_entity %]</a></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
</ul>
|
||||
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
|
||||
<input placeholder="Find Anything" class="search-query span3"
|
||||
id="nq" name="q" type="text" autocomplete="off"/>
|
||||
id="nq" name="q" value="[% display_name %]" type="text" autocomplete="off"/>
|
||||
<div class="btn-group nd_navbar-search-group">
|
||||
<button class="btn btn-inverse nd_navbar-search-icon">
|
||||
<span style="font-size: 18px;">
|
||||
|
||||
Reference in New Issue
Block a user