Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve IP addresses of Device #1253

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,14 @@ function uploadifive() {
</select>
</div>
</div>
<div>
<div><label for="ResolveDeviceIp">',__("Resolve IP Address"),'</label></div>
<div><select id="ResolveDeviceIP" name="ResolveDeviceIp" defaultvalue="',$config->defaults["ResolveDeviceIp"],'" data="',$config->ParameterArray["ResolveDeviceIp"],'">
<option value="disabled">',__("Do not resolve Devices IP Address"),'</option>
<option value="enabled">',__("Resolve Device IP Address"),'</option>
</select>
</div>
</div>
</div> <!-- end table -->
<h3>',__("Cabinets"),'</h3>
<div class="table">
Expand Down
4 changes: 4 additions & 0 deletions db-20.01-to-20.02-maybe.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

UPDATE fac_Config SET DefaultVal = 'Location' WHERE fac_Config.Parameter = 'AssignCabinetLabels';


--- Add preference for resolution of device ip addresses

INSERT into fac_Config set Parameter='ResolveDeviceIp', Value='Disabled', UnitOfMeasure='string',ValType='string', DefaultVal='disabled';
--
-- Bump up the database version (uncomment below once released)
--
Expand Down
2 changes: 1 addition & 1 deletion devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ function setPreferredLayout() {<?php if(isset($_COOKIE["layout"]) && strtolower(
<div>
<div><label for="PrimaryIP">'.__("Primary IP / Host Name").'</label></div>
<div><input type="text" name="PrimaryIP" id="PrimaryIP" size="20" value="'.$dev->PrimaryIP.'">
<input type="hidden" name="FirstPortNum" value="'.$dev->FirstPortNum.'"></div>
<input type="hidden" name="FirstPortNum" value="'.$dev->FirstPortNum.'"><label for="PrimaryIP2">'.($config->ParameterArray['ResolveDeviceIp']=='enabled'?@gethostbyname($dev->PrimaryIP):'').'</label></div>
</div>
<div>
<div><label for="MfgDate">'.__("Manufacture Date").'</label></div>
Expand Down
32 changes: 22 additions & 10 deletions search_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_once('db.inc.php');
require_once('facilities.inc.php');

$resolve_ip = $config->ParameterArray['ResolveDeviceIp'];
$subheader=__("Data Center View/Export");

$datacenter=new DataCenter();
Expand All @@ -24,7 +25,7 @@
$cList=$person->GetUserList(true);

/* This is a helper function to deal with nested devices aka russian nesting dolls */
function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList,$resolve_ip){
// Find all of the children!
$childList=$dev->GetDeviceChildren();

Expand Down Expand Up @@ -74,8 +75,10 @@ function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
\t<td><a href=\"devices.php?DeviceID=$child->DeviceID\" target=\"device\">$child->Label</a></td>
\t<td>$child->SerialNo</td>
\t<td>$child->AssetTag</td>
\t<td>$child->PrimaryIP</td>
\t<td><a href=\"search.php?key=dev&DeviceType=$child->DeviceType&search\" target=\"search\">$child->DeviceType</a></td>
\t<td>$child->PrimaryIP</td>" .

(( $_POST['resolve'] == 'true' && $resolve_ip == 'enabled') ? ($child->PrimaryIP != '' ? "\t<td>" .@gethostbyname($child->PrimaryIP) . "</td>" : "\t<td></td>") : '' )
. "\t<td><a href=\"search.php?key=dev&DeviceType=$child->DeviceType&search\" target=\"search\">$child->DeviceType</a></td>
\t<td>$cModel</td>
\t<td>$ctags</td>
\t<td>$cDepartment</td>
Expand All @@ -92,7 +95,7 @@ function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
\n\t\t</tr>\n";

if($child->DeviceType=="Chassis"){
$chassis=processChassis($child,$dept,$row,$ca_result,$tpList,$cList);
$chassis=processChassis($child,$dept,$row,$ca_result,$tpList,$cList,$resolve_ip);
$body.=$chassis;
}
}
Expand Down Expand Up @@ -138,8 +141,9 @@ function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
\t<th>".__("Name")."</th>
\t<th>".__("Serial Number")."</th>
\t<th>".__("Asset Tag")."</th>
\t<th>".__("Primary IP / Host Name")."</th>
\t<th>".__("Device Type")."</th>
\t<th>".__("Primary IP / Host Name")."</th>".
(( $_POST['resolve'] == 'true' && $resolve_ip == 'enabled') ? "\t<th>" . __("Resolved IP") . "</th>" : '' ) .
"\t<th>".__("Device Type")."</th>
\t<th>".__("Template")."</th>
\t<th>".__("Tags")."</th>
\t<th>".__("Owner")."</th>
Expand Down Expand Up @@ -205,8 +209,9 @@ function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
\t<td><a href=\"devices.php?DeviceID=$dev->DeviceID\" target=\"device\">{$row["Label"]}</a></td>
\t<td>{$row["SerialNo"]}</td>
\t<td>{$row["AssetTag"]}</td>
\t<td>{$row["PrimaryIP"]}</td>
\t<td><a href=\"search.php?key=dev&DeviceType={$row["DeviceType"]}&search\" target=\"search\">{$row["DeviceType"]}</a></td>
\t<td>{$row["PrimaryIP"]}</td>" .
( ( $_POST['resolve'] == 'true' && $resolve_ip == 'enabled' ) ? ($row["PrimaryIP"] != '' ? "\t<td>" .@gethostbyname($row["PrimaryIP"]) . "</td>" : "\t<td></td>") : '' )
. "\t<td><a href=\"search.php?key=dev&DeviceType={$row["DeviceType"]}&search\" target=\"search\">{$row["DeviceType"]}</a></td>
\t<td>$Model</td>
\t<td>$tags</td>
\t<td>$Department</td>
Expand All @@ -222,7 +227,7 @@ function processChassis($dev,$dept,$row,$ca_result,$tpList,$cList){
{$ca_cells}\t\n\t\t</tr>\n";

if($row["DeviceType"]=="Chassis"){
$chassis=processChassis($dev,$dept,$row,$ca_result,$tpList,$cList);
$chassis=processChassis($dev,$dept,$row,$ca_result,$tpList,$cList,$resolve_ip);
$body.=$chassis;
}
}
Expand Down Expand Up @@ -287,7 +292,13 @@ function redraw(){
}
dt();
$('#datacenterid').change(function(){
$.post('', {datacenterid: $(this).val(), ajax: ''}, function(data){
$.post('', {datacenterid: $(this).val(), resolve: $("#resolve").is(":checked"), ajax: ''}, function(data){
$('#tablecontainer').html(data);
dt();
});
});
$('#resolve').click(function(){
$.post('', {datacenterid: $('#datacenterid').val(), resolve: $("#resolve").is(":checked"), ajax: ''}, function(data){
$('#tablecontainer').html(data);
dt();
});
Expand All @@ -307,6 +318,7 @@ function redraw(){
<option value="0">',__("All Data Centers"),'</option>';
foreach($dcList as $dc){print "\t\t\t\t<option value=\"$dc->DataCenterID\">$dc->Name</option>\n";} ?>
</select>
<?php if ($resolve_ip == 'enabled' ) {echo '<input id="resolve" type="checkbox">Show Resolved IPs (500 IPs aprox 20 seconds)'; }; ?>
<br><br>
<div class="center">
<div id="tablecontainer">
Expand Down