function builddclist($id = null) { $dc = new DataCenter(); $dcList = $dc->GetDCList(); $idnum = ''; if (!is_null($id)) { if ($id == "dc-front") { $idnum = 1; } elseif ($id == "dc-rear") { $idnum = 2; } $id = " name=\"{$id}\" id=\"{$id}\""; } $dcpicklist = "<select{$id}><option value=0> </option>"; foreach ($dcList as $d) { $dcpicklist .= "<option value={$d->DataCenterID}>{$d->Name}</option>"; } $dcpicklist .= '</select>'; return $dcpicklist; }
} $data_array = array(); if (isset($_POST['ListUnique'])) { $data_array = $log->ListUnique($_POST['ListUnique']); } if (isset($_POST['BuildTable'])) { echo BuildDataTable($log); exit; } header('Content-Type: application/json'); echo json_encode($data_array); exit; } $subversion = __("Logging View/Export"); $datacenter = new DataCenter(); $dcList = $datacenter->GetDCList(); $templ = new DeviceTemplate(); $dept = new Department(); $dev = new Device(); $log = new LogActions(); function BuildDataTable($log_object) { $limit = isset($_REQUEST['Limit']) ? $_REQUEST['Limit'] : 1000; $result = $log_object->Search($limit); // Left these expanded in case we need to add or remove columns. Otherwise I would have just collapsed entirely. $body = "<table id=\"export\" class=\"display\">\n\t<thead>\n\t\t<tr>\n\n\t\t\t\t<th>" . __("Time") . "</th>\n\t\t\t\t<th>" . __("UserID") . "</th>\n\t\t\t\t<th>" . __("Class") . "</th>\n\t\t\t\t<th>" . __("ObjectID") . "</th>\n\t\t\t\t<th>" . __("ChildID") . "</th>\n\t\t\t\t<th>" . __("Action") . "</th>\n\t\t\t\t<th>" . __("Property") . "</th>\n\t\t\t\t<th>" . __("Old Value") . "</th>\n\t\t\t\t<th>" . __("New Value") . "</th>\n\t\t\t</tr>\n\t</thead>\n\t<tbody>\n"; // suppressing errors for when there is a fake data set in place foreach ($result as $logitem) { switch ($logitem->Action) { case 1: $logitem->Action = __("Create");
/** * Compute the full inventory on devices in the data centers and return the data * center summary statistics * * @param PHPExcel_Worksheet $worksheet * @param array $DProps properties defined for the Excel document * @return (array|array|array|boolean)[] * statistics array, device inventory, cabinet inventory */ function computeSheetBodyDCInventory($DProps) { global $person; global $sessID; $dc = new DataCenter(); $cab = new Cabinet(); $device = new Device(); $invData = array(); $invCab = array(); $sheetColumns = $DProps['DC Inventory']['Columns']; $cabinetColumns = $DProps['Rack Inventory']['Columns']; $devTemplates = DeviceTemplate::getTemplateListIndexedbyID(); $deptList = Department::GetDepartmentListIndexedbyID(); $contactList = $person->GetUserList('indexed'); $limitedUser = false; $dcList = $dc->GetDCList(); $Stats = array(); // A little code to update the counter $percentDone = 0; $sectionMaxPercent = 40; $incrementalPercent = 1 / sizeof($dcList) * $sectionMaxPercent; foreach ($dcList as $dc) { $dcContainerList = $dc->getContainerList(); $dcStats = array(); $cab->DataCenterID = $dc->DataCenterID; $dcStats['Fl_Spc'] = $dc->SquareFootage; $dcStats['DesignPower'] = $dc->MaxkW; $dcStats['Watts'] = 0; $dcStats['Rk_Num'] = 0; $dcStats['Rk_UtT'] = 0; $dcStats['Rk_UtU'] = 0; $dcStats['Rk_UtE'] = 0; $dcStats['Rk_Res'] = 0; $cabList = $cab->ListCabinetsByDC(); if (count($cabList) == 0) { // empty data center room $devSpec = makeEmptySpec($sheetColumns, $dcContainerList); $devSpec['DC Name'] = $dc->Name; $invData[] = $devSpec; } else { foreach ($cabList as $cab) { if (!$person->ReadAccess and $cab->AssignedTo == 0 or $cab->AssignedTo > 0 and !$person->canRead($cab->AssignedTo)) { // User is not allowed to see anything in here $limitedUser = true; continue; } $zoneName = getZoneName($cab); $rowName = getRowName($cab); addRackStat($invCab, $cab, $cabinetColumns, $dc, $dcContainerList); $cab_height = $cab->CabinetHeight; if (mb_strtoupper($cab->Model) == 'RESERVED') { $dcStats['Rk_Res']++; } else { $dcStats['Rk_Num']++; } $dcStats['Rk_UtT'] += $cab_height; $device->Cabinet = $cab->CabinetID; $device_list = $device->ViewDevicesByCabinet(); // empty cabinet if (count($device_list) == 0 && $cab->CabinetHeight > 0) { $dcStats['Rk_UtE'] += $cab_height; $devSpec = makeEmptySpec($sheetColumns, $dcContainerList); $devSpec['Zone'] = $zoneName; $devSpec['Row'] = $rowName; $devSpec['DC Name'] = $dc->Name; $devSpec['Cabinet'] = $cab->Location; $devSpec['Position'] = 1; $devSpec['Height'] = $cab->CabinetHeight; $devSpec['Device'] = '__EMPTY'; $invData[] = $devSpec; } else { usort($device_list, 'cmpDevPos'); $low_idx = 1; foreach ($device_list as $dev) { if ($low_idx < $dev->Position) { // range of empty slots if ($dev->Position <= $cab_height) { $height = $dev->Position - $low_idx; } else { $height = $cab_height - $low_idx + 1; } if ($height > 0) { $dcStats['Rk_UtE'] += $height; $devSpec = makeEmptySpec($sheetColumns, $dcContainerList); ${$devSpec}['Zone'] = $zoneName; $devSpec['Row'] = $rowName; $devSpec['DC Name'] = $dc->Name; $devSpec['Cabinet'] = $cab->Location; $devSpec['Position'] = $low_idx; $devSpec['Height'] = $height; $devSpec['Device'] = '__EMPTY'; $invData[] = $devSpec; } $low_idx = $dev->Position; } // device in cabinet $reserved = $dev->Reservation ? 'reserved' : null; list($manufacturer, $model) = getDeviceTemplateName($devTemplates, $dev); $devSpec = makeEmptySpec($sheetColumns, $dcContainerList); $devSpec['DevID'] = $dev->DeviceID; $devSpec['Zone'] = $zoneName; $devSpec['Row'] = $rowName; $devSpec['DC Name'] = $dc->Name; $devSpec['Cabinet'] = $cab->Location; $devSpec['Position'] = $dev->Position; $devSpec['Half Depth'] = getDeviceDepthPos($dev); $devSpec['Height'] = $dev->Height; $devSpec['Device'] = $dev->Label; $devSpec['Parent Device'] = null; $devSpec['Manufacturer'] = $manufacturer; $devSpec['Model'] = $model; $devSpec['Device Type'] = $dev->DeviceType; $devSpec['Asset Number'] = $dev->AssetTag; $devSpec['Serial No.'] = $dev->SerialNo; $devSpec['Install Date'] = $dev->InstallDate; $devSpec['Warranty End'] = $dev->WarrantyExpire; $devSpec['Owner'] = getOwnerName($dev, $deptList); $devSpec['Power (W)'] = $dev->NominalWatts; $devSpec['Reservation'] = $reserved; $devSpec['Contact'] = getContactName($contactList, $dev->PrimaryContact); $devSpec['Tags'] = getTagsString($dev); $devSpec['Notes'] = html_entity_decode(strip_tags($dev->Notes), ENT_COMPAT, 'UTF-8'); $invData[] = $devSpec; $dcStats['Watts'] += $dev->NominalWatts; // devices can be installed at the same position and // could be of different height; count only the free // rack units which are not covered by any device if ($low_idx == $dev->Position) { $low_idx += $dev->Height; $dcStats['Rk_UtU'] += $dev->Height; } else { $rest_height = $dev->Position + $dev->Height - $low_idx; $rest_height = $rest_height > 0 ? $rest_height : 0; $low_idx += $rest_height; $dcStats['Rk_UtU'] += $rest_height; } if ($dev->DeviceType == 'Chassis') { list($watts, $invData) = computeDeviceChildren($sheetColumns, $invData, $dev, $dc->Name, $cab, $devTemplates, $deptList, $contactList, $dcContainerList); $dcStats['Watts'] += $watts; } } if ($low_idx <= $cab->CabinetHeight) { // empty range at the top of the cabinet, $low_idx is // the potentially free location $height = $cab->CabinetHeight - $low_idx + 1; $dcStats['Rk_UtE'] += $height; $devSpec = makeEmptySpec($sheetColumns, $dcContainerList); $devSpec['Zone'] = $zoneName; $devSpec['Row'] = $rowName; $devSpec['DC Name'] = $dc->Name; $devSpec['Cabinet'] = $cab->Location; $devSpec['Position'] = $low_idx; $devSpec['Height'] = $height; $devSpec['Device'] = '__EMPTY'; $invData[] = $devSpec; } } } } assignStatsVal($Stats, $dc, $dcStats); $percentDone += $incrementalPercent; JobQueue::updatePercentage($sessID, $percentDone); } return array($Stats, $invData, $invCab, $limitedUser); }
$response['error'] = false; $response['errorcode'] = 200; } $response['department'] = $depts; echoResponse(200, $response); }); // // URL: /api/v1/datacenter // Method: GET // Params: none // Returns: List of all data centers in the database // $app->get('/datacenter', function () { // Don't have to worry about rights, other than basic connection, to get data center list $dc = new DataCenter(); $dcList = $dc->GetDCList(); $response['error'] = false; $response['errorcode'] = 200; $response['datacenter'] = array(); foreach ($dcList as $d) { $tmp = array(); foreach ($d as $prop => $value) { $tmp[$prop] = $value; } array_push($response['datacenter'], $tmp); } echoResponse(200, $response); }); // // URL: /api/v1/datacenter/:id // Method: GET
$cabrow->GetCabRow(); if (isset($_POST["action"]) && ($_POST["action"] == "Create" || $_POST["action"] == "Update")) { $cabrow->Name = $_POST["name"]; $cabrow->DataCenterID = $_POST["datacenterid"]; $cabrow->ZoneID = $_POST["zoneid"]; if ($_POST["action"] == "Create") { $cabrow->CreateCabRow(); } else { if ($cabrow->UpdateCabRow()) { $status = __("Updated"); } } } $formpatch = "?cabrowid={$_REQUEST['cabrowid']}"; } $dcList = $DC->GetDCList(); $idcList = $DC->GetDCList(true); //indexed by id $izoneList = $zone->GetZoneList(true); //indexed by id $cabrowList = $cabrow->GetCabRowList(); ?> <!doctype html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>openDCIM Rows of Cabinets</title> <link rel="stylesheet" href="css/inventory.php" type="text/css">