<?php require_once 'db.inc.php'; require_once 'facilities.inc.php'; $subheader = __("Data Center Virtual Machine Detail"); if (!$person->WriteAccess || !isset($_REQUEST['vmindex'])) { // No soup for you. header('Location: ' . redirect()); exit; } $dept = new Department(); $esx = new ESX(); $con = new People(); $dev = new Device(); if ($_REQUEST['vmindex'] > 0) { $esx->VMIndex = $_REQUEST['vmindex']; $esx->GetVMbyIndex(); $dev->DeviceID = $esx->DeviceID; $dev->GetDevice(); if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'Update') { $esx->Owner = $_REQUEST['owner']; $esx->PrimaryContact = $_REQUEST['contact']; $esx->UpdateVMOwner(); header('Location: ' . redirect("devices.php?DeviceID={$esx->DeviceID}")); } } else { // How'd you get here without a valid vmindex? header('Location: ' . redirect()); exit; } $contactList = $con->GetUserList();
<?php require_once 'db.inc.php'; require_once 'facilities.inc.php'; $esx = new ESX(); $esx->UpdateInventory();
function GetVMbyIndex() { global $dbh; $sql = "SELECT * FROM fac_VMInventory WHERE VMIndex={$this->VMIndex};"; if (!($vmRow = $dbh->query($sql)->fetch())) { return false; } else { foreach (ESX::RowToObject($vmRow) as $param => $value) { $this->{$param} = $value; } return true; } }
function buildESXtable($DeviceID) { $ESX = new ESX(); $ESX->DeviceID = $DeviceID; $vmList = $ESX->GetDeviceInventory(); print "\n<div class=\"table border\"><div><div>" . __("VM Name") . "</div><div>" . __("Status") . "</div><div>" . __("Owner") . "</div><div>" . __("Last Updated") . "</div></div>\n"; foreach ($vmList as $vmRow) { $onOff = preg_match('/off/i', $vmRow->vmState) ? 'off' : 'on'; $Dept = new Department(); $Dept->DeptID = $vmRow->Owner; if ($Dept->DeptID > 0) { $Dept->GetDeptByID(); } else { $Dept->Name = __("Unknown"); } print "<div><div>{$vmRow->vmName}</div><div class=\"{$onOff}\">{$vmRow->vmState}</div><div><a href=\"updatevmowner.php?vmindex={$vmRow->VMIndex}\">{$Dept->Name}</a></div><div>{$vmRow->LastUpdated}</div></div>\n"; } echo '</div> <!-- END div.table -->'; }
<?php require_once 'db.inc.php'; require_once 'facilities.inc.php'; $searchKey = $_REQUEST['key']; //Remove control characters tab, enter, etc $searchTerm = preg_replace("/[[:cntrl:]]/", "", $_REQUEST['search']); //Remove any extra quotes that could get passed in from some funky js or something $searchTerm = str_replace(array("'", '"'), "", $searchTerm); $dc = new DataCenter(); $dcList = $dc->GetDCList(); $dev = new Device(); $esx = new ESX(); $cab = new Cabinet(); $pdu = new PowerDistribution(); $dept = new Department(); $resultcount = 0; $title = __("Search Results"); if ($searchKey == 'serial') { $dev->SerialNo = $searchTerm; $devList = $dev->SearchDevicebySerialNo(); $resultcount = count($devList); $title = __("Serial number search results for") . " "{$searchTerm}""; } elseif ($searchKey == 'ip') { $dev->PrimaryIP = $searchTerm; $devList = $dev->SearchDevicebyIP(); $resultcount = count($devList); $title = __("PrimaryIP search results for") . " "{$searchTerm}""; } elseif ($searchKey == 'label') { $dev->Label = $searchTerm; $devList = $dev->SearchDevicebyLabel();
// // $pdf = new PDF(); include_once "loadfonts.php"; $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont($config->ParameterArray['PDFfont'], '', 8); $pdf->SetFillColor(0, 0, 0); $pdf->SetTextColor(255); $pdf->SetDrawColor(128, 0, 0); $pdf->SetLineWidth(0.3); $pdf->SetfillColor(224, 235, 255); $pdf->SetTextColor(0); $pdf->Bookmark('Departments'); $deptList = $dept->GetDepartmentList(); $VM = new ESX(); $vmList = $VM->GetInventory(); $vmCount = count($vmList); $pdf->Cell(80, 5, __("Total Number of VMs")); $pdf->Cell(0, 5, $vmCount); $pdf->Ln(); $vmList = $VM->GetOrphanVMList(); $vmCount = 0; $pdf->Cell(80, 12, __("Virtual Machines Unassigned to a Department")); $pdf->Ln(); $headerTags = array(__("Index"), __("Virtual Machine Image Name"), __("Current Host Server")); $cellWidths = array(10, 80, 80); $maxval = count($headerTags); for ($col = 0; $col < $maxval; $col++) { $pdf->Cell($cellWidths[$col], 7, $headerTags[$col], 1, 0, 'C', 1); }
<?php require_once 'db.inc.php'; require_once 'facilities.inc.php'; require_once 'swiftmailer/swift_required.php'; $esx = new ESX(); $dev = new Device(); $dept = new Department(); $error = ""; // If any port other than 25 is specified, assume encryption and authentication if ($config->ParameterArray['SMTPPort'] != 25) { $transport = Swift_SmtpTransport::newInstance()->setHost($config->ParameterArray['SMTPServer'])->setPort($config->ParameterArray['SMTPPort'])->setEncryption('ssl')->setUsername($config->ParameterArray['SMTPUser'])->setPassword($config->ParameterArray['SMTPPassword']); } else { $transport = Swift_SmtpTransport::newInstance()->setHost($config->ParameterArray['SMTPServer'])->setPort($config->ParameterArray['SMTPPort']); } $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::NewInstance()->setSubject(__("Virtual Machine Inventory Exception Report")); // Set from address try { $message->setFrom($config->ParameterArray['MailFromAddr']); $message->SetReplyTo($config->ParameterArray["MailToAddr"]); } catch (Swift_RfcComplianceException $e) { $error .= __("MailFrom") . ": <span class=\"errmsg\">" . $e->getMessage() . "</span><br>\n"; } // Add people to recipient list try { $message->setTo($config->ParameterArray['MailToAddr']); /* // Add additional recipients below this section using the following examples * // Using addTo() to add recipients iteratively * $message->addTo('*****@*****.**'); * $message->addTo('*****@*****.**', 'Person 2 Name');
$pdf->Cell($cellWidths[0], 6, $devRow->Label, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[1], 6, $devRow->SerialNo, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[2], 6, $devRow->AssetTag, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[3], 6, $dc->Name, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[4], 6, $cab->Location, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[5], 6, $Position, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[6], 6, $devRow->Height, 'LBRT', 1, 'L', $fill); $TotalRU += $devRow->Height; $TotalBTU += $devRow->NominalWatts * 3.412; $DCRU += $devRow->Height; $DCBTU += $devRow->NominalWatts * 3.412; $fill = !$fill; } $pdf->Cell(0, 5, __("Total Rack Units for All Data Centers") . ': ' . $TotalRU, '', 1, 'L', ''); $pdf->Cell(0, 5, __("Total BTU Output for All Data Centers") . ': ' . sprintf('%d (%.2f Tons)', $TotalBTU, $TotalBTU / 12000), '', 1, 'L', ''); $esx = new ESX(); $esx->Owner = $deptRow->DeptID; $esxList = $esx->GetVMListbyOwner(); $headerTags = array(__("Virtual Machine Image Name"), __("Current Host Server"), __("State"), __("Last Polled")); $cellWidths = array(60, 40, 30, 40); $maxval = count($headerTags); for ($col = 0; $col < $maxval; $col++) { $pdf->Cell($cellWidths[$col], 7, $headerTags[$col], 1, 0, 'C', 1); } $pdf->Ln(); $fill = 0; $lastDevice = 0; foreach ($esxList as $esxRow) { if ($esxRow->DeviceID != $lastDevice) { $dev->DeviceID = $esxRow->DeviceID; $dev->GetDevice();