function updatecdu($template, $status) { $cdutemplate = new CDUTemplate(); $cdutemplate->TemplateID = $template->TemplateID; $cdutemplate->ManufacturerID = $template->ManufacturerID; $cdutemplate->Model = $template->Model; $cdutemplate->Managed = isset($_POST['Managed']) ? 1 : 0; $cdutemplate->ATS = isset($_POST['ATS']) ? 1 : 0; $cdutemplate->VersionOID = $_POST['VersionOID']; $cdutemplate->Multiplier = $_POST['Multiplier']; $cdutemplate->OID1 = $_POST['OID1']; $cdutemplate->OID2 = $_POST['OID2']; $cdutemplate->OID3 = $_POST['OID3']; $cdutemplate->ATSStatusOID = $_POST['ATSStatusOID']; $cdutemplate->ATSDesiredResult = $_POST['ATSDesiredResult']; $cdutemplate->ProcessingProfile = $_POST['ProcessingProfile']; $cdutemplate->Voltage = $_POST["Voltage"]; $cdutemplate->Amperage = $_POST["Amperage"]; $cdutemplate->NumOutlets = $template->PSCount; $status = $cdutemplate->UpdateTemplate() ? $status : __('Error updating cdu attributes'); return $status; }
function GetSmartCDUVersion() { if (!($dev = PowerDistribution::BasicTests($this->PDUID))) { return false; } if (!$this->GetPDU()) { return false; } $template = new CDUTemplate(); $template->TemplateID = $this->TemplateID; if (!$template->GetTemplate()) { return false; } return self::OSS_SNMP_Lookup($dev, null, "{$template->VersionOID}"); }
case "ChassisSlots": 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";
<?php require_once 'db.inc.php'; require_once 'facilities.inc.php'; $subheader = __("Data Center Cabinet Distribution Unit Templates"); if (!$person->SiteAdmin) { // No soup for you. header('Location: ' . redirect()); exit; } $template = new CDUTemplate(); $manufacturer = new Manufacturer(); if (isset($_REQUEST['templateid']) && $_REQUEST['templateid'] > 0) { $template->TemplateID = $_REQUEST['templateid']; $template->GetTemplate(); } $status = ''; if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'Create' || $_REQUEST['action'] == 'Update')) { $template->ManufacturerID = $_REQUEST['manufacturerid']; $template->Model = transform($_REQUEST['model']); $template->Managed = isset($_REQUEST['managed']) ? 1 : 0; $template->ATS = isset($_REQUEST['ats']) ? 1 : 0; $template->SNMPVersion = $_REQUEST['snmpversion']; $template->VersionOID = $_REQUEST['versionoid']; $template->Multiplier = $_REQUEST['multiplier']; $template->OID1 = $_REQUEST['oid1']; $template->OID2 = $_REQUEST['oid2']; $template->OID3 = $_REQUEST['oid3']; $template->ATSStatusOID = $_REQUEST['atsstatusoid']; $template->ATSDesiredResult = $_REQUEST['atsdesiredresult']; $template->ProcessingProfile = $_REQUEST['processingprofile'];
$maxDraw = $PDUdev->InputAmperage * $pan->PanelVoltage; } else { $maxDraw = $PDUdev->InputAmperage * $pan->PanelVoltage * 1.732; } // De-rate all breakers to 80% sustained load $maxDraw *= 0.8; if ($maxDraw > 0) { $PDUPercent = intval($pduDraw / $maxDraw * 100); } else { $PDUPercent = 0; } $PDUColor = $PDUPercent > intval($config->ParameterArray["PowerRed"]) ? $CriticalColor : ($PDUPercent > intval($config->ParameterArray["PowerYellow"]) ? $CautionColor : $GoodColor); $body .= sprintf("\n\t\t\t<a href=\"devices.php?DeviceID=%d\">CDU %s</a><br>(%.2f kW) / (%.2f kW Max)<br>\n", $PDUdev->PDUID, $PDUdev->Label, $pduDraw / 1000, $maxDraw / 1000); $body .= "\t\t\t\t<div class=\"meter-wrap\">\n\t\t\t\t\t<div class=\"meter-value\" style=\"background-color: {$PDUColor}; width: {$PDUPercent}%;\">\n\t\t\t\t\t\t<div class=\"meter-text\">{$PDUPercent}%</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t<br>\n"; if ($PDUdev->FailSafe) { $tmpl = new CDUTemplate(); $tmpl->TemplateID = $PDUdev->TemplateID; $tmpl->GetTemplate(); $ATSStatus = $PDUdev->getATSStatus(); if ($ATSStatus == "") { $ATSColor = "rs.png"; $ATSStatus = __("Unknown Status"); } elseif ($ATSStatus == $tmpl->ATSDesiredResult) { $ATSColor = "gs.png"; $ATSStatus = __("ATS Feeds OK"); } else { $ATSColor = "ys.png"; $ATSStatus = __("ATS Feeds Abnormal"); } $body .= "<div><img src=\"images/{$ATSColor}\">{$ATSStatus}</div>\n"; }
function UpdateTemplate() { $this->MakeSafe(); $sql = "UPDATE fac_DeviceTemplate SET ManufacturerID={$this->ManufacturerID},\n\t\t\tModel=\"{$this->Model}\", Height={$this->Height}, Weight={$this->Weight}, \n\t\t\tWattage={$this->Wattage}, DeviceType=\"{$this->DeviceType}\", \n\t\t\tPSCount={$this->PSCount}, NumPorts={$this->NumPorts}, Notes=\"{$this->Notes}\", \n\t\t\tFrontPictureFile=\"{$this->FrontPictureFile}\", RearPictureFile=\"{$this->RearPictureFile}\",\n\t\t\tChassisSlots={$this->ChassisSlots}, RearChassisSlots={$this->RearChassisSlots}, SNMPVersion=\"{$this->SNMPVersion}\",\n\t\t\tGlobalID={$this->GlobalID}, ShareToRepo={$this->ShareToRepo}, KeepLocal={$this->KeepLocal}\n\t\t\tWHERE TemplateID={$this->TemplateID};"; $old = new DeviceTemplate(); $old->TemplateID = $this->TemplateID; $old->GetTemplateByID(); if ($old->DeviceType == "CDU" && $this->DeviceType != $old->DeviceType) { // Template changed from CDU to something else, clean up the mess $cdut = new CDUTemplate(); $cdut->TemplateID = $this->TemplateID; $cdut->DeleteTemplate(); } elseif ($this->DeviceType == "CDU" && $this->DeviceType != $old->DeviceType) { // Template changed to CDU from something else, make the extra stuff $cdut = new CDUTemplate(); $cdut->Model = $this->Model; $cdut->ManufacturerID = $this->ManufacturerID; $cdut->CreateTemplate($this->TemplateID); } if ($old->DeviceType == "Sensor" && $this->DeviceType != $old->DeviceType) { // Template changed from Sensor to something else, clean up the mess $st = new SensorTemplate(); $st->TemplateID = $this->TemplateID; $st->DeleteTemplate(); } elseif ($this->DeviceType == "Sensor" && $this->DeviceType != $old->DeviceType) { // Template changed to Sensor from something else, make the extra stuff $st = new SensorTemplate(); $st->Model = $this->Model; $st->ManufacturerID = $this->ManufacturerID; $st->CreateTemplate($this->TemplateID); } if (!$this->query($sql)) { return false; } else { class_exists('LogActions') ? LogActions::LogThis($this, $old) : ''; $this->MakeDisplay(); return true; } }
<?php require_once "db.inc.php"; require_once "facilities.inc.php"; $subheader = __("Data Center Detail"); if (!$person->SiteAdmin) { // No soup for you. header('Location: ' . redirect()); exit; } $panel = new PowerPanel(); $pdu = new PowerDistribution(); $cab = new Cabinet(); $tmpl = new CDUTemplate(); $tmpList = $tmpl->GetTemplateList(); $script = ""; // AJAX if (isset($_POST['deletepanel'])) { $panel->PanelID = $_POST["PanelID"]; $return = 'no'; if ($panel->getPanel()) { $panel->deletePanel(); $return = 'ok'; } echo $return; exit; } // Set a default panel voltage based upon the configuration screen $panel->PanelVoltage = $config->ParameterArray["DefaultPanelVoltage"]; if (isset($_POST["action"]) && ($_POST["action"] == "Create" || $_POST["action"] == "Update")) { foreach ($panel as $prop => $val) {
<?php require_once "db.inc.php"; require_once "facilities.inc.php"; global $dbh; $picturedir = getcwd() . "/pictures/"; $t = new DeviceTemplate(); $m = new Manufacturer(); $ct = new CDUTemplate(); $sen = new SensorTemplate(); $tList = $t->GetTemplateShareList(); $c = curl_init('https://repository.opendcim.org/api/template'); curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_COOKIEFILE, "/tmp/repocookies.txt"); curl_setopt($c, CURLOPT_COOKIEJAR, "/tmp/repocookies.txt"); curl_setopt($c, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($c, CURLOPT_HTTPHEADER, array("UserID: " . $config->ParameterArray["APIUserID"], "APIKey: " . $config->ParameterArray["APIKey"], "Content-Type: application/json")); foreach ($tList as $temp) { if ($temp->ManufacturerID != $m->ManufacturerID) { $m->ManufacturerID = $temp->ManufacturerID; $m->GetManufacturerByID(); } $temp->ManufacturerID = $m->GlobalID; $tp = new TemplatePorts(); $tp->TemplateID = $temp->TemplateID; $tpList = $tp->getPorts(); // Convert the base template object to an associative array for easier manipulation $postData["template"] = json_decode(json_encode($temp), true);
$cabmessage = __("PDUs at") . ' ' . $cabmessage; $pdf->SetFont($config->ParameterArray['PDFfont'], 'B', 10); $pdf->Cell(0, 5, $cabmessage, 0, 1, 'C', 0); $pdf->SetFont($config->ParameterArray['PDFfont'], '', 10); $PDUList = $pdu->GetPDUbyCabinet(); $headerTags = array(__("Label"), __("NumOutputs"), __("Model"), __("PanelLabel"), __("PanelPole")); $cellWidths = array(50, 30, 118, 70, 20); $maxval = count($headerTags); for ($col = 0; $col < $maxval; $col++) { $pdf->Cell($cellWidths[$col], 7, $headerTags[$col], 1, 0, 'C', 1); } $pdf->Ln(); foreach ($PDUList as $PDUrow) { $panel->PanelID = $PDUrow->PanelID; $panel->getPanel(); $pdutemp = new CDUTemplate(); $pdutemp->TemplateID = $PDUrow->TemplateID; $pdutemp->GetTemplate(); $mfg->ManufacturerID = $pdutemp->ManufacturerID; $mfg->GetManufacturerByID(); $pdf->Cell($cellWidths[0], 6, $PDUrow->Label, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[1], 6, $pdutemp->NumOutlets, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[2], 6, "[{$mfg->Name}] {$pdutemp->Model}", 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[3], 6, $panel->PanelLabel, 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[4], 6, $PDUrow->PanelPole, 'LBRT', 1, 'L', $fill); $pdf->Cell($cellWidths[0], 6, '', 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[1], 6, '', 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[2], 6, '', 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[3], 6, '', 'LBRT', 0, 'L', $fill); $pdf->Cell($cellWidths[4], 6, '', 'LBRT', 1, 'L', $fill); $fill = !$fill;
<?php require_once "db.inc.php"; require_once "facilities.inc.php"; global $dbh; $picturedir = getcwd() . "/pictures/"; $t = new DeviceTemplate(); $m = new Manufacturer(); $ct = new CDUTemplate(); $sen = new SensorTemplate(); $tList = $t->GetTemplateShareList(); $c = curl_init(); curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_COOKIEFILE, "/tmp/repocookies.txt"); curl_setopt($c, CURLOPT_COOKIEJAR, "/tmp/repocookies.txt"); curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($c, CURLOPT_HTTPHEADER, array("UserID: " . $config->ParameterArray["APIUserID"], "APIKey: " . $config->ParameterArray["APIKey"], "Content-Type: application/json")); curl_setopt($c, CURLOPT_URL, 'https://repository.opendcim.org/api/manufacturer'); curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'GET'); $result = curl_exec($c); $jr = json_decode($result); if (is_array($jr->manufacturers)) { foreach ($jr->manufacturers as $tmpman) { $m->GlobalID = $tmpman->ManufacturerID; if ($m->getManufacturerByGlobalID()) { $m->Name = $tmpman->Name; $m->UpdateManufacturer(); } else { // We don't already have this one linked, so search for a candidate or add as a new one