/** * Render cabinet properties into this view. * * The cabinet properties zone, row, model, maximum weight and installation date * are rendered to be for this page. It checks if the user is allowed to see the * content of the cabinet and only if the user does the information is provided. * * @param Cabinet $cab * @param CabinetAudit $audit * @param string $AuditorName */ function renderCabinetProps($cab, $audit, $AuditorName) { $tmpDC = new DataCenter(); $tmpDC->DataCenterID = $cab->DataCenterID; $tmpDC->GetDataCenter(); $AuditorName = $AuditorName != '' ? "<br>{$AuditorName}" : ""; $renderedHTML = "\t\t<table id=\"cabprop\">\n\t\t\t<tr><td>" . __("Last Audit") . ":</td><td id=\"lastaudit\">{$audit->AuditStamp}{$AuditorName}</td></tr>\n\t\t\t<tr><td>" . __("Model") . ":</td><td>{$cab->Model}</td></tr>\n\t\t\t<tr><td>" . __("Data Center") . ":</td><td>{$tmpDC->Name}</td></tr>\n\t\t\t<tr><td>" . __("Install Date") . ":</td><td>{$cab->InstallationDate}</td></tr>\n"; if ($cab->ZoneID) { $zone = new Zone(); $zone->ZoneID = $cab->ZoneID; $zone->GetZone(); $renderedHTML .= "\t\t\t<tr><td>" . __("Zone") . ":</td><td>{$zone->Description}</td></tr>\n"; } if ($cab->CabRowID) { $cabrow = new CabRow(); $cabrow->CabRowID = $cab->CabRowID; $cabrow->GetCabRow(); $renderedHTML .= "\t\t\t<tr><td>" . __("Row") . ":</td><td>{$cabrow->Name}</td></tr>\n"; } $renderedHTML .= "\t\t\t<tr><td>" . __("Tags") . ":</td><td>" . renderTagsToString($cab) . "</td></tr>\n"; // This is out of context here and makes the information confusing. // $renderedHTML .= ' <tr><td class="left">' . __('Front Edge') . ':</td>'; // $renderedHTML .= "<td class=\"right\">$cab->FrontEdge </td></tr>\n"; $renderedHTML .= "\t\t</table>\n"; return $renderedHTML; }
require_once "db.inc.php"; require_once "facilities.inc.php"; $subheader = __("Data Center Cabinet Inventory"); // Get the list of departments that this user is a member of $viewList = $person->isMemberOf(); $cab = new Cabinet(); $head = $legend = $zeroheight = $body = $deptcolor = ""; $deptswithcolor = array(); $dev = new Device(); $templ = new DeviceTemplate(); $tempDept = new Department(); $dc = new DataCenter(); $cabrow = new CabRow(); $cabrow->CabRowID = $_REQUEST['row']; $cabrow->GetCabRow(); $cab->CabRowID = $cabrow->CabRowID; $cabinets = $cab->GetCabinetsByRow(); $frontedge = $cabrow->GetCabRowFrontEdge(); if (isset($_GET["rear"])) { //opposite view $cabinets = array_reverse($cabinets); } //start loop to parse all cabinets in the row foreach ($cabinets as $index => $cabinet) { $currentHeight = $cabinet->CabinetHeight; if ($config->ParameterArray["ReservedColor"] != "#FFFFFF" || $config->ParameterArray["FreeSpaceColor"] != "#FFFFFF") { $head .= "\t\t<style type=\"text/css\">\n\t\t\t.reserved{background-color: {$config->ParameterArray['ReservedColor']};}\n\t\t\t.freespace{background-color: {$config->ParameterArray['FreeSpaceColor']};}\n"; } $side = null; if ($frontedge == "Top" || $frontedge == "Bottom") {
private function UpdateList() { global $config; //find posible next devices with lower weight in list from actual node //for each device found, if already it exists and it is not useded, update it if (new weight) < (old weight) //if it does not exist, insert in list with his actual weight and $used=false //Destination device is $this->devID2 //weights $weight_cabinet = $config->ParameterArray["path_weight_cabinet"]; //weight for patches on actual cabinet $weight_rear = $config->ParameterArray["path_weight_rear"]; //weight fot rear connetcion between panels $weight_row = $config->ParameterArray["path_weight_row"]; //weigth for patches on same row of cabinets (except actual cabinet) //It is possible to assign a weight proportional to the distance between the actual cabinet and each cabinet of actual row, //so you can prioritize closest cabinets in the actual row. In the future... $this->escribe_log("\nSelected node: D=" . $this->DeviceID . "; P=" . $this->PortNumber . "; W=" . $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] . "; PD=" . $this->nodes[$this->DeviceID][$this->PortNumber]["prev_dev"] . "; PP=" . $this->nodes[$this->DeviceID][$this->PortNumber]["prev_port"]); //Compruebo si el puerto del dispositivo actual esta conectado a la conexion trasera de un panel //I check if the port of this device is connected to a rear-panel connection $port = new DevicePorts(); $port->DeviceID = $this->DeviceID; $port->PortNumber = $this->PortNumber; if (!$port->getPort()) { $this->escribe_log("ERROR GETTING PORT"); exit; } if ($port->ConnectedDeviceID != 0) { if ($port->ConnectedPort < 0) { //It's a port of the first device connected to rear panel connection or it's a rear port of a panel. //Go to mirror device $this->escribe_log(" Rear connection to D=" . $port->ConnectedDeviceID . " P=" . $port->ConnectedPort); $this->AddNodeToList($port->ConnectedDeviceID, -$port->ConnectedPort, $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_rear, $this->DeviceID, $this->PortNumber); } else { //port used in mirror panel //nothing to do $this->escribe_log(" Port used in mirror panel D=" . $port->ConnectedDeviceID . " P=" . $port->ConnectedPort); } } else { //It's a free front port //get dev info: cabinet and row $device = new Device(); $device->DeviceID = $this->DeviceID; $device->GetDevice(); $cab = $device->GetDeviceCabinetID(); $cabinet = new Cabinet(); $cabinet->CabinetID = $cab; $cabinet->GetCabinet(); $cabrow = new CabRow(); $cabrow->CabRowID = $cabinet->CabRowID; $cabrow->GetCabRow(); //busco el dispositivo final en el mismo armario (si no esta reflejado en un panel) //looking for the end device in the same cabinet (if not reflected in a panel) if ($cab == $this->cab2 && !$this->espejo2) { $this->escribe_log(" DEV2 found in actual cabinet (" . $cab . "-'" . $cabinet->Location . "')"); $this->AddNodeToList($this->devID2, -$this->port2, $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_cabinet, $this->DeviceID, $this->PortNumber); } elseif ($cabrow->CabRowID != 0 && $cabrow->CabRowID == $this->row2 && !$this->espejo2) { $this->escribe_log(" DEV2 found in actual row (" . $cabrow->CabRowID . "-'" . $cabrow->Name . "')"); $this->AddNodeToList($this->devID2, -$this->port2, $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_row, $this->DeviceID, $this->PortNumber); } //busco paneles con puertos libres en el armario actual //Look for panels with free ports on actual cabinet $this->escribe_log("Look for panels with free ports on actual cabinet (" . $cab . "-'" . $cabinet->Location . "')"); global $dbh; global $config; $mediaenforce = ""; if ($config->ParameterArray["MediaEnforce"] == 'enabled') { $mediaenforce = " AND af.MediaID=" . $port->MediaID; } $sql = "SELECT af.DeviceID AS DeviceID1,\r\n\t\t\t\t\t\taf.PortNumber AS PortNumber1,\r\n\t\t\t\t\t\tbf.DeviceID AS DeviceID2,\r\n\t\t\t\t\t\tbf.PortNumber AS PortNumber2\t \r\n\t\t\t\tFROM fac_Ports af, fac_Ports ar, fac_Ports bf, fac_Device d \r\n\t\t\t\tWHERE d.Cabinet=" . $cab . " AND \r\n\t\t\t\t\taf.DeviceID=d.DeviceID AND \r\n\t\t\t\t\taf.DeviceID!=" . $this->DeviceID . " AND\r\n\t\t\t\t\taf.ConnectedDeviceID IS NULL" . $mediaenforce . " AND \r\n\t\t\t\t\td.DeviceType='Patch Panel' AND\r\n\t\t\t\t\taf.PortNumber>0 AND\r\n\t\t\t\t\tar.DeviceID=af.DeviceID AND ar.PortNumber=-af.PortNumber AND\r\n\t\t\t\t\tbf.DeviceID=ar.ConnectedDeviceID AND bf.PortNumber=-ar.ConnectedPort AND\r\n\t\t\t\t\tbf.ConnectedDeviceID IS NULL\r\n\t\t\t\tORDER BY DeviceID1,PortNumber1,DeviceID2,PortNumber2;"; foreach ($dbh->query($sql) as $row) { //Compruebo si tengo que anadir esta pareja //I check if I have to add this pair of nodes if (isset($this->candidates[$row["DeviceID2"]]) && $this->nodes[$row["DeviceID2"]][$this->candidates[$row["DeviceID2"]]]["weight"] > $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_cabinet + $weight_rear || !isset($this->candidates[$row["DeviceID2"]]) && !isset($this->used_candidates[$row["DeviceID2"]])) { $this->AddNodeToList($row["DeviceID1"], -$row["PortNumber1"], $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_cabinet, $this->DeviceID, $this->PortNumber); //Anado directamente el espejo de este puerto //I add directly the mirror port of this port $this->AddNodeToList($row["DeviceID2"], $row["PortNumber2"], $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_cabinet + $weight_rear, $row["DeviceID1"], -$row["PortNumber1"]); } } //busco paneles con puertos libres en la fila actual //Look for panels with free ports on actual row $this->escribe_log("Look for panels with free ports on actual row (" . $cabrow->CabRowID . "-'" . $cabrow->Name . "')"); $sql = "SELECT af.DeviceID AS DeviceID1,\r\n\t\t\t\t\t\taf.PortNumber AS PortNumber1,\r\n\t\t\t\t\t\tbf.DeviceID AS DeviceID2,\r\n\t\t\t\t\t\tbf.PortNumber AS PortNumber2 \r\n\t\t\t\tFROM fac_Ports af, fac_Ports ar, fac_Ports bf, fac_Device d, fac_Cabinet c \r\n\t\t\t\tWHERE af.DeviceID=d.DeviceID AND \r\n\t\t\t\t\taf.DeviceID!=" . $this->DeviceID . " AND\r\n\t\t\t\t\td.Cabinet=c.CabinetID AND\r\n\t\t\t\t\td.Cabinet<>" . $cab . " AND\r\n\t\t\t\t\tc.CabRowID=" . $cabrow->CabRowID . " AND \r\n\t\t\t\t\taf.ConnectedDeviceID IS NULL" . $mediaenforce . " AND \r\n\t\t\t\t\td.DeviceType='Patch Panel' AND\r\n\t\t\t\t\taf.PortNumber>0 AND\r\n\t\t\t\t\tar.DeviceID=af.DeviceID AND ar.PortNumber=-af.PortNumber AND\r\n\t\t\t\t\tbf.DeviceID=ar.ConnectedDeviceID AND bf.PortNumber=-ar.ConnectedPort AND\r\n\t\t\t\t\tbf.ConnectedDeviceID IS NULL\r\n\t\t\t\tORDER BY DeviceID1,PortNumber1,DeviceID2,PortNumber2;"; foreach ($dbh->query($sql) as $row) { //Compruebo si tengo que anadir esta pareja //I check if I have to add this pair of nodes if (isset($this->candidates[$row["DeviceID2"]]) && $this->nodes[$row["DeviceID2"]][$this->candidates[$row["DeviceID2"]]]["weight"] > $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_row + $weight_rear || !isset($this->candidates[$row["DeviceID2"]]) && !isset($this->used_candidates[$row["DeviceID2"]])) { $this->AddNodeToList($row["DeviceID1"], -$row["PortNumber1"], $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_row, $this->DeviceID, $this->PortNumber); //Anado directamente el espejo de este puerto //I add directly the mirror port of this port $this->AddNodeToList($row["DeviceID2"], $row["PortNumber2"], $this->nodes[$this->DeviceID][$this->PortNumber]["weight"] + $weight_row + $weight_rear, $row["DeviceID1"], -$row["PortNumber1"]); } } } //quito el nodo de la lista de candidatos //remove the node from candidates and I include it in used_candidates $this->escribe_log("....Candidate DEV=" . $this->DeviceID . "->PORT=" . $this->PortNumber . " used"); unset($this->candidates[$this->DeviceID]); $this->used_candidates[$this->DeviceID] = true; //any value }
/** * Return the row name of a cabinet. * @param Cabinet $cab * @param (string|null) $emptyVal * @return string|null */ function getRowName($cab, $emptyVal = null) { $rowName = $emptyVal; if ($cab->CabRowID) { $cabrow = new CabRow(); $cabrow->CabRowID = $cab->CabRowID; $cabrow->GetCabRow(); $rowName = $cabrow->Name; } return $rowName; }
function UpdateCabRow() { $this->MakeSafe(); $oldcabrow = new CabRow(); $oldcabrow->CabRowID = $this->CabRowID; $oldcabrow->GetCabRow(); // TODO this here can lead to untracked changes on the cabinets. fix this to use the update method //update all cabinets in this cabrow $sql = "UPDATE fac_Cabinet SET ZoneID={$this->ZoneID}, DataCenterID={$this->DataCenterID} WHERE CabRowID={$this->CabRowID};"; if (!$this->query($sql)) { return false; } $sql = "UPDATE fac_CabRow SET Name=\"{$this->Name}\", DataCenterID={$this->DataCenterID}, ZoneID={$this->ZoneID} WHERE CabRowID={$this->CabRowID};"; if (!$this->query($sql)) { return false; } class_exists('LogActions') ? LogActions::LogThis($this, $oldcabrow) : ''; return true; }