/**
 * 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;
}
示例#2
0
    $response['error'] = false;
    $response['errorcode'] = 200;
    foreach ($app->request->get() as $prop => $val) {
        $dev->{$prop} = $val;
    }
    $response['zone'] = $zone->GetZone();
    echoResponse(200, $response);
});
//
//	URL:	/api/v1/cabrow
//	Method:	GET
//	Params:	none
//	Returns:  All cabinet rows for which the user's rights have access to view
//
$app->get('/cabrow', function () use($app) {
    $cabrow = new CabRow();
    $response['error'] = false;
    $response['errorcode'] = 200;
    foreach ($app->request->get() as $prop => $val) {
        $cabrow->{$prop} = $val;
    }
    $response['cabrow'] = $cabrow->Search(true);
    echoResponse(200, $response);
});
/**
 *
 *		API POST Methods go here
 *
 *		POST Methods are for updating existing records
 *
 **/
示例#3
0
<?php

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;
示例#4
0
 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
 }
示例#5
0
     $cabinet = new Cabinet();
     $cabinet->DataCenterID = $zone->DataCenterID;
     $cabinet->ZoneID = $zone->ZoneID;
     foreach ($cabinet->ListCabinetsByDC(true, true) as $cab) {
         $device = new Device();
         $device->Cabinet = $cab->CabinetID;
         foreach ($device->ViewDevicesByCabinet(true) as $dev) {
             if (!isset($devList[$dev->DeviceType])) {
                 $devList[$dev->DeviceType] = array();
             }
             $devList[$dev->DeviceType][$dev->DeviceID] = array();
         }
     }
 } elseif (isset($_REQUEST['cabrowid'])) {
     $cabrowid = isset($_POST['cabrowid']) ? $_POST['cabrowid'] : $_GET['cabrowid'];
     $cabrow = new CabRow();
     $cabrow->CabRowID = $cabrowid;
     $cabrow->GetCabRow();
     $cabinet = new Cabinet();
     $cabinet->CabRowID = $cabrow->CabRowID;
     $cabinetList = $cabinet->GetCabinetsByRow();
     if (isset($cabinetList)) {
         $datacenter = new DataCenter();
         $datacenter->DataCenterID = $cabinetList[0]->DataCenterID;
         $datacenter->GetDataCenter();
         $graphname .= "Row " . $cabrow->Name . " in Data Center " . $datacenter->Name;
         foreach ($cabinetList as $cab) {
             $device = new Device();
             $device->Cabinet = $cab->CabinetID;
             foreach ($device->ViewDevicesByCabinet(true) as $dev) {
                 if (!isset($devList[$dev->DeviceType])) {
/**
 * 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;
}
示例#7
0
 function Search($indexedbyid = false, $loose = false)
 {
     $o = new stdClass();
     // Store any values that have been added before we make them safe
     foreach ($this as $prop => $val) {
         if (isset($val)) {
             $o->{$prop} = $val;
         }
     }
     // Make everything safe for us to search with
     $this->MakeSafe();
     // This will store all our extended sql
     $sqlextend = "";
     foreach ($o as $prop => $val) {
         extendsql($prop, $this->{$prop}, $sqlextend, $loose);
     }
     // The join is purely to sort the templates by the manufacturer's name
     $sql = "SELECT * FROM fac_CabRow {$sqlextend} ORDER BY Name ASC;";
     $rowList = array();
     foreach ($this->query($sql) as $row) {
         if ($indexedbyid) {
             $rowList[$row["CabRowID"]] = CabRow::RowToObject($row);
         } else {
             $rowList[] = CabRow::RowToObject($row);
         }
     }
     return $rowList;
 }
示例#8
0
<?php

require_once "db.inc.php";
require_once "facilities.inc.php";
$subheader = __("Rows of Cabinets");
if (!$person->SiteAdmin) {
    // No soup for you.
    header('Location: ' . redirect());
    exit;
}
$cabrow = new CabRow();
$zone = new Zone();
$DC = new DataCenter();
$zoneList = $zone->GetZoneList();
$formpatch = "";
$status = "";
if (isset($_POST['action']) && $_POST['action'] == 'Delete') {
    $cabrow->CabRowID = $_POST['cabrowid'];
    $cabrow->DeleteCabRow();
    header('Location: cabrow.php');
    exit;
}
if (isset($_REQUEST["cabrowid"])) {
    $cabrow->CabRowID = isset($_POST['cabrowid']) ? $_POST['cabrowid'] : $_GET['cabrowid'];
    $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();
示例#9
0
 function GetCabRowList()
 {
     $sql = "SELECT * FROM fac_CabRow ORDER BY Name ASC;";
     $cabrowList = array();
     foreach ($this->query($sql) as $row) {
         $cabrowList[] = CabRow::RowToObject($row);
     }
     return $cabrowList;
 }