function GetDeviceDiversity() { global $dbh; $pc = new PowerConnection(); $PDU = new PowerDistribution(); // If this is a child (card slot) device, then only the parent will have power connections defined if ($this->ParentDevice > 0) { $tmpDev = new Device(); $tmpDev->DeviceID = $this->ParentDevice; $sourceList = $tmpDev->GetDeviceDiversity(); } else { $pc->DeviceID = $this->DeviceID; $pcList = $pc->GetConnectionsByDevice(); $sourceList = array(); $sourceCount = 0; foreach ($pcList as $pcRow) { $PDU->PDUID = $pcRow->PDUID; $powerSource = $PDU->GetSourceForPDU(); if (!in_array($powerSource, $sourceList)) { $sourceList[$sourceCount++] = $powerSource; } } } return $sourceList; }
if ($dev->DeviceType == 'Chassis') { $tooltip .= __($row["Label"]) . " " . $dev->{$row}["Field"] . "<br>\n"; } break; case "Model": $template = new CDUTemplate(); $manufacturer = new Manufacturer(); $template->TemplateID = $pdu->TemplateID; $template->GetTemplate(); $manufacturer->ManufacturerID = $template->ManufacturerID; $manufacturer->GetManufacturerByID(); $tooltip .= __($row["Label"]) . ": [{$manufacturer->Name}] {$template->Model}<br>\n"; break; case "NumOutlets": $template = new CDUTemplate(); $powerConn = new PowerConnection(); $template->TemplateID = $pdu->TemplateID; $template->GetTemplate(); $powerConn->PDUID = $pdu->PDUID; $connList = $powerConn->GetConnectionsByPDU(); $tooltip .= __($row["Label"]) . ": " . count($connList) . "/" . ($template->NumOutlets + 1) . "<br>\n"; break; case "Uptime": $tooltip .= __($row["Label"]) . ": " . $pdu->GetSmartCDUUptime() . "<br>\n"; break; case "PanelID": $pan = new PowerPanel(); $pan->PanelID = $pdu->PanelID; $pan->GetPanel(); $tooltip .= __($row["Label"]) . ": {$pan->PanelLabel}<br>\n"; break;
function DeletePDU() { global $person; $this->MakeSafe(); // Do not attempt anything else if the lookup fails if (!$this->GetPDU()) { return false; } // Check rights $cab = new Cabinet(); $cab->CabinetID = $this->CabinetID; $cab->GetCabinet(); if (!$person->canWrite($cab->AssignedTo)) { return false; } // First, remove any connections to the PDU $tmpConn = new PowerConnection(); $tmpConn->PDUID = $this->PDUID; $connList = $tmpConn->GetConnectionsByPDU(); foreach ($connList as $delConn) { $delConn->RemoveConnection(); } // Clear out any records from PDUStats, possible S.U.T. involving changing // a devicetype but leaving behind a phantom reading for a non-power device $sql = "DELETE FROM fac_PDUStats WHERE PDUID={$this->PDUID};"; $this->exec($sql); $sql = "DELETE FROM fac_PowerDistribution WHERE PDUID={$this->PDUID};"; if (!$this->exec($sql)) { // Something went south and this didn't delete. return false; } else { class_exists('LogActions') ? LogActions::LogThis($this) : ''; return true; } }
<div class="center"> <div id="tablecontainer">'; // // // Begin Report Generation // // $pan = new PowerPanel(); $pdu = new PowerDistribution(); $dev = new Device(); $cab = new Cabinet(); $dept = new Department(); $dc = new DataCenter(); $pwrConn = new PowerConnection(); // Make some quick user defined sort comparisons for this report only function compareCab( $a, $b ) { if ( $a->Location == $b->Location ) return 0; return ( $a->Location > $b->Location ) ? +1 : -1; } $dc->DataCenterID = intval( $_REQUEST['datacenterid'] ); $dc->GetDataCenter(); $skipNormal = false;
if (isset($_POST['DeviceID']) && isset($_POST['power'])) { if (isset($_POST['con']) && isset($_POST['pduid'])) { $pwrConnection = new PowerConnection(); $pwrConnection->DeviceID = $_POST['DeviceID']; $pwrConnection->PDUID = $_POST['pduid']; $pwrConnection->PDUPosition = $_POST['con']; $pwrConnection->DeviceConnNumber = $_POST['power']; if (isset($_POST['e'])) { $pwrConnection->CreateConnection(); } else { $pwrConnection->RemoveConnection(); } echo 'ok'; } else { $dev = new Device(); $pwrConnection = new PowerConnection(); $pdu = new PowerDistribution(); $dev->DeviceID = $_POST['DeviceID']; $dev->GetDevice(); $pwrConnection->DeviceID = $dev->ParentDevice > 0 ? $dev->ParentDevice : $dev->DeviceID; $pwrCords = $pwrConnection->GetConnectionsByDevice(); print "<span>Server Name: {$dev->Label}</span><span># Power Supplies: {$dev->PowerSupplyCount}</span><div class=\"table border\">\n\t\t\t<div><div>" . __("Power Strip") . "</div><div>" . __("Plug #") . "</div><div>" . __("Power Supply") . "</div></div>"; foreach ($pwrCords as $cord) { $pdu->PDUID = $cord->PDUID; $pdu->GetPDU(); print "\t\t\t<div><div data=\"{$pdu->PDUID}\"><a href=\"power_pdu.php?pduid={$pdu->PDUID}\">{$pdu->Label}</a></div><div><a href=\"power_connection.php?pdu={$pdu->PDUID}&conn={$cord->PDUPosition}\">{$cord->PDUPosition}</a></div><div" . ($cord->DeviceConnNumber == $_POST['power'] ? ' class="bold"' : ' class="disabled"') . ">{$cord->DeviceConnNumber}</div></div>\n"; } print "</div>"; } exit; }
/** * Placeholder for backward compatibility (iTop <= 2.1.0) * in case an extension attempts to redefine this function... */ public static function GetRelationQueries($sRelCode) { return parent::GetRelationQueries($sRelCode); }
public static function GetRelationQueries($sRelCode) { switch ($sRelCode) { case "impacts": $aRels = array(); return array_merge($aRels, parent::GetRelationQueries($sRelCode)); break; case 'depends on': $aRels = array("powerconnection" => array("sQuery" => "SELECT PowerConnection WHERE id = :this->powerstart_id", "bPropagate" => true, "iDistance" => 10)); return array_merge($aRels, parent::GetRelationQueries($sRelCode)); break; default: return parent::GetRelationQueries($sRelCode); } }