本文整理汇总了PHP中Device::GetDevice方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::GetDevice方法的具体用法?PHP Device::GetDevice怎么用?PHP Device::GetDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::GetDevice方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatedevice
function updatedevice($deviceid)
{
$dev = new Device();
$dev->DeviceID = $deviceid;
$dev->GetDevice();
$dev->PowerSupplyCount = $dev->PowerSupplyCount - 1;
$dev->UpdateDevice();
}
示例2: Device
}
if ($status == "") {
$path .= "<div style=\"text-align: center;\">";
$path .= "<div style=\"font-size: 1.5em;\">" . __("Path of") . " {$pathid}</div>\n";
//Path Table
$path .= "<table id=\"parcheos\">\n\t<tr>\n\t\t<td colspan=6> </td>\n\t</tr>\n\t<tr>\n";
$path .= "\t\t<td> </td>\n\t\t<td class=\"right\">";
$dev = new Device();
$end = false;
$elem_path = 0;
$form_eliminar = "";
while (!$end) {
//first device
//get the device
$dev->DeviceID = $cp->DeviceID;
$dev->GetDevice();
$elem_path++;
$form_eliminar .= "<input type=\"hidden\" name=\"DeviceID[{$elem_path}]\" value=\"{$cp->DeviceID}\">\n";
$form_eliminar .= "<input type=\"hidden\" name=\"PortNumber[{$elem_path}]\" value=\"{$cp->PortNumber}\">\n";
//If this device is the first and is a panel, I put it to the right position freeing the left
if ($elem_path == 1 && $dev->DeviceType == "Patch Panel") {
$path .= "</td>\n\t\t<td></td>";
//In connection type
$tipo_con = $cp->PortNumber > 0 ? "r" : "f";
//half hose
$path .= "\n\t\t<td class=\"{$tipo_con}-right\"></td>\n";
//Out connection type
$tipo_con = $cp->PortNumber > 0 ? "f" : "r";
//Can the path continue?
if ($dev->DeviceType == "Patch Panel") {
$path .= "\n\t\t<td class=\"connection-{$tipo_con}-1\">";
示例3: MakePath
function MakePath()
{
$this->MakeSafe();
//reset PathError
$this->PathError = 0;
//check devices/ports
$device = new Device();
$device->DeviceID = $this->devID1;
if (!$device->GetDevice()) {
$this->PathError = 1;
//dev1 does not exist
return false;
}
$devType1 = $device->DeviceType;
if ($device->DeviceType == "Patch Panel") {
$this->PathError = 2;
//dev1 is a Patch Pannel
return false;
}
$port1 = new DevicePorts();
$port1->DeviceID = $this->devID1;
$port1->PortNumber = $this->port1;
if (!$port1->getPort()) {
$this->PathError = 3;
//dev1,port1 is missing
return False;
}
if ($port1->ConnectedDeviceID > 0 && $port1->ConnectedPort > 0) {
$this->PathError = 4;
//dev1,port1 is connected
return False;
}
$device->DeviceID = $this->devID2;
if (!$device->GetDevice()) {
$this->PathError = 5;
//dev2 does not exist
return false;
}
$devType2 = $device->DeviceType;
if ($device->DeviceType == "Patch Panel") {
$this->PathError = 6;
//dev2 is a Patch Pannel
return false;
}
$port2 = new DevicePorts();
$port2->DeviceID = $this->devID2;
$port2->PortNumber = $this->port2;
if (!$port2->getPort()) {
$this->PathError = 7;
//dev2,port2 is missing
return False;
}
if ($port2->ConnectedDeviceID > 0 && $port2->ConnectedPort > 0) {
$this->PathError = 8;
//dev2,port2 is connected
return False;
}
//get dev2 info
$this->cab2 = $device->GetDeviceCabinetID();
//cab2
$cabinet = new Cabinet();
$cabinet->CabinetID = $this->cab2;
$cabinet->GetCabinet();
$this->row2 = $cabinet->CabRowID;
//row2
//if dev2 is panel protected device (connected to rear connection of a panel)
$this->espejo2 = $port2->ConnectedDeviceID > 0 && $port2->ConnectedPort < 0;
@unlink('ppath.log');
$this->escribe_log("**** NEW PATH ****");
$this->escribe_log("DEV1: ID=" . $this->devID1 . " PORT=" . $this->port1);
$this->escribe_log("DEV2: ID=" . $this->devID2 . " PORT=" . $this->port2 . " CAB_ID=" . $this->cab2 . " ROW_ID=" . $this->row2);
$this->escribe_log("-------------------");
//reset Path
$this->ClearPath();
//initiate list with device1, port1, weitgh=0, prev_dev=0, prev_port=0
$this->AddNodeToList($this->devID1, $this->port1, 0, 0, 0);
while ($this->SelectNode()) {
if ($this->DeviceID == $this->devID2) {
$this->escribe_log("Target found. Making the PATH...");
//make the path
$i = 1;
while ($this->DeviceID > 0) {
$dev = $this->DeviceID;
$port = $this->PortNumber;
$Path[$i]["DeviceID"] = $dev;
$Path[$i]["PortNumber"] = $port;
$this->DeviceID = $this->nodes[$dev][$port]["prev_dev"];
$this->PortNumber = $this->nodes[$dev][$port]["prev_port"];
$i++;
}
for ($j = 1; $j < $i; $j++) {
$this->Path[$j]["DeviceID"] = $Path[$i - $j]["DeviceID"];
$this->Path[$j]["PortNumber"] = $Path[$i - $j]["PortNumber"];
}
$this->escribe_log("PATH created.");
$this->escribe_log("");
return true;
}
$this->UpdateList();
}
//.........这里部分代码省略.........
示例4: upgrade
//.........这里部分代码省略.........
$st = $dbh->prepare("select * from fac_DeviceTemplate where DeviceType='CDU'");
$st->execute();
$up = $dbh->prepare("update fac_Device set SNMPVersion=:SNMPVersion where TemplateID=:TemplateID");
while ($row = $st->fetch()) {
$up->execute(array(":SNMPVersion" => $row["SNMPVersion"], ":TemplateID" => $row["TemplateID"]));
}
// END - CDU template conversion, to be done prior to device conversion
// Sensor template conversion
// Step one - convert individual SensorTemplates into just Templates
$s = $dbh->prepare("select * from fac_SensorTemplate");
$s->execute();
while ($row = $s->fetch()) {
// Create fresh instances
$st = new SensorTemplate();
$dt = new DeviceTemplate();
$dt->ManufacturerID = $row["ManufacturerID"];
$dt->Model = $row["Model"];
$dt->Height = 0;
$dt->Weight = 0;
$dt->Wattage = 0;
$dt->DeviceType = "Sensor";
$dt->PSCount = 0;
$dt->NumPorts = 0;
$dt->Notes = "Converted from version 3.3 format.";
$dt->FrontPictureFile = '';
$dt->RearPictureFile = '';
$dt->ChassisSlots = 0;
$dt->RearChassisSlots = 0;
$dt->CreateTemplate();
// The DeviceTemplate::CreateTemplate() method created a new SensorTemplate already
if ($dt->TemplateID < 1) {
error_log("DeviceTemplate creation failed.");
} else {
$st->TemplateID = $dt->TemplateID;
$st->GetTemplate();
$st->SNMPVersion = $row["SNMPVersion"];
$st->TemperatureOID = $row["TemperatureOID"];
$st->HumidityOID = $row["HumidityOID"];
$st->TempMultiplier = $row["TempMultiplier"];
$st->HumidityMultiplier = $row["HumidityMultiplier"];
$st->mUnits = $row["mUnits"];
$st->UpdateTemplate();
// Even though this is just temporary, update all existing references to the new TemplateID
$sql = "update fac_Cabinet set SensorTemplateID=:NewID where SensorTemplateID=:OldID";
$q = $dbh->prepare($sql);
$q->execute(array(":NewID" => $dt->TemplateID, ":OldID" => $row["TemplateID"]));
// Delete the original template entry in the fac_SensorTemplate table
$st->TemplateID = $row["TemplateID"];
$st->DeleteTemplate();
}
}
$ds = $dbh->prepare("alter table fac_SensorTemplate drop column SNMPVersion");
// Step two - pull sensors from the Cabinets and create as new devices
$s = $dbh->prepare("select * from fac_Cabinet where SensorIPAddress!=''");
$s->execute();
while ($row = $s->fetch()) {
$dev = new Device();
$dev->Label = $row["Location"] . " - Sensor";
$dev->SNMPCommunity = $row["SensorCommunity"];
$dev->PrimaryIP = $row["SensorIPAddress"];
$dev->TemplateID = $row["SensorTemplateID"];
$dev->DeviceType = "Sensor";
$dev->Cabinet = $row["CabinetID"];
$dev->CreateDevice();
}
// END - Sensor template conversion
// Power panel conversion
$dbh->beginTransaction();
$ss = $dbh->prepare("select * from fac_PowerSource");
$ss->execute();
$ps = $dbh->prepare("insert into fac_PowerPanel set PanelLabel=:PanelLabel");
$us = $dbh->prepare("update fac_PowerPanel set ParentPanelID=:PanelID where PowerSourceID=:SourceID");
while ($row = $ss->fetch()) {
$ps->execute(array(":PanelLabel" => $row["SourceName"]));
$us->execute(array(":PanelID" => $dbh->LastInsertId(), ":SourceID" => $row["PowerSourceID"]));
}
$dbh->commit();
// END - Power panel conversion
// Get rid of the original PowerSource table since it is no longer in use
$drop = $dbh->prepare("drop table fac_PowerSource");
$drop->execute();
$drop = $dbh->prepare("alter table fac_PowerPanel drop column PowerSourceID");
$drop->execute();
// Make sure all child devices have updated cabinet information
$sql = "SELECT DISTINCT ParentDevice AS DeviceID FROM fac_Device WHERE \n\t\t\tParentDevice>0 ORDER BY ParentDevice ASC;";
foreach ($dbh->query($sql) as $row) {
$d = new Device();
$d->DeviceID = $row['DeviceID'];
$d->GetDevice();
$d->UpdateDevice();
}
$version = "4.0";
}
if ($version == "4.0") {
// First apply the schema updates needed.
$results[] = applyupdate("db-4.0-to-4.0.1.sql");
// Rebuild the config table just in case.
$config->rebuild();
}
}
示例5: BasicTests
private static function BasicTests($DeviceID)
{
global $config;
// First check if the SNMP library is present
if (!class_exists('OSS_SNMP\\SNMP')) {
return false;
}
$dev = new Device();
$dev->DeviceID = $DeviceID;
// Make sure this is a real device and has an IP set
if (!$dev->GetDevice()) {
return false;
}
if ($dev->PrimaryIP == "") {
return false;
}
// If the device doesn't have an SNMP community set, check and see if we have a global one
$dev->SNMPCommunity = $dev->SNMPCommunity == "" ? $config->ParameterArray["SNMPCommunity"] : $dev->SNMPCommunity;
// We've passed all the repeatable tests, return the device object for digging
return $dev;
}
示例6: Cabinet
<?php
include 'sidebar.inc.php';
?>
<div class="main">
<div class="center"><div>
<!-- CONTENT GOES HERE -->
<?php
print "<h2>" . __("Work Order Contents") . "</h2>\n<div class=\"table\">\n\t<div><div>" . __("Cabinet") . "</div><div>" . __("Position") . "</div><div>" . __("Label") . "</div><div>" . __("Image") . "</div></div>\n";
foreach ($devList as $dev) {
// including the $cab and $devTempl in here so it gets reset each time and there
// is no chance for phantom data
$cab = new Cabinet();
if ($dev->ParentDevice > 0) {
$pdev = new Device();
$pdev->DeviceID = $dev->GetRootDeviceID();
$pdev->GetDevice();
$cab->CabinetID = $pdev->Cabinet;
} else {
$cab->CabinetID = $dev->Cabinet;
}
$cab->GetCabinet();
$devTmpl = new DeviceTemplate();
$devTmpl->TemplateID = $dev->TemplateID;
$devTmpl->GetTemplateByID();
$position = $dev->Height == 1 ? $dev->Position : $dev->Position . "-" . ($dev->Position + $dev->Height - 1);
print "<div><div>{$cab->Location}</div><div>{$position}</div><div>{$dev->Label}</div><div>" . $dev->GetDevicePicture('', '', 'nolinks') . "</div></div>\n";
}
print '</div>
<a href="export_port_connections.php?deviceid=wo"><button type="button">' . __("Export Connections") . '</button></a>';
?>
示例7: array
}
}
# Generate a list of ports from the device lists.
$portList = array();
foreach ($devList as $deviceType => $dev) {
foreach ($dev as $devid => $ports) {
$c_port_list = array();
foreach ($ports as $port) {
$portList[] = array('ConnectedDeviceID' => $port->ConnectedDeviceID, 'DeviceID' => $port->DeviceID, 'ConnectedPort' => $port->ConnectedPort, 'PortNumber' => $port->PortNumber, 'ColorID' => $port->ColorID, 'MediaID' => $port->MediaID, 'Label' => $port->Label);
$c_port_list[] = "<" . $port->Label . "> " . $port->Label;
}
$p_count = count($c_port_list);
$n_dev_label = "{";
$tdev = new Device();
$tdev->DeviceID = $devid;
$tdev->GetDevice();
# Generate the "Label" for the device. The label specifies
# the name and the port list.
for ($i = 0; $i < $p_count; $i++) {
if ($p_count > 1 && $i == 0) {
$n_dev_label .= "{";
}
if (floor($p_count / 2) == $i) {
if ($p_count > 1) {
$n_dev_label .= "}|{" . $tdev->Label . "}|{";
} else {
$n_dev_label .= "{" . $tdev->Label . "}|{";
}
}
$n_dev_label .= $c_port_list[$i];
if ($i < $p_count - 1 && $i + 1 != floor($p_count / 2)) {
示例8: updatedevice
function updatedevice($devid)
{
$dev = new Device();
$dev->DeviceID = $devid;
$dev->GetDevice();
$dev->Ports = $dev->Ports - 1;
$dev->UpdateDevice();
}
示例9: elseif
} elseif ($searchKey == "notes") {
$dev->Notes = $searchTerm;
$devList = $dev->LooseSearch(true);
$cab->Notes = $searchTerm;
$cabList = $cab->LooseSearch(true);
// DevicePorts and PowerPorts use the same structures and functions so
// we're just looping the search to not repeat code
foreach (array('DevicePorts', 'PowerPorts') as $pt) {
$p = new $pt();
$p->Notes = $searchTerm;
foreach ($p->LooseSearch() as $port) {
// This is gonna be a little slow but this will cut down on duplicate lookups
if (!isset($devList[$port->DeviceID])) {
$d = new Device($port->DeviceID);
// These should all be valid but just in case, skip it
if ($d->GetDevice()) {
$devList[$d->DeviceID] = $d;
}
}
}
}
$resultcount = count($devList) + count($cabList);
$title = __("Notes search results for") . " "{$searchTerm}"";
} elseif ($searchKey = "dev") {
// This is gonna be a generic catch all
foreach ($dev as $prop => $val) {
$dev->{$prop} = isset($_GET[$prop]) ? $_GET[$prop] : $val;
}
$devList = $dev->Search(true);
$resultcount = count($devList);
} else {
示例10: processPDUList
function processPDUList($list, $start, $increment)
{
global $dbh;
$dev = new Device();
$cdu = new PowerDistribution();
for ($n = $start; $n < sizeof($list); $n = $n + $increment) {
$row = $list[$n];
// Just send back zero if we don't get a result.
$pollValue1 = $pollValue2 = $pollValue3 = 0;
$dev->DeviceID = $row["PDUID"];
$dev->GetDevice();
$pollValue1 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID1"]));
// We won't use OID2 or 3 without the other so make sure both are set or just ignore them
if ($row["OID2"] != "" && $row["OID3"] != "") {
$pollValue2 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID2"]));
$pollValue3 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID3"]));
// Negativity test, it is required for APC 3ph modular PDU with IEC309-5W wires
if ($pollValue2 < 0) {
$pollValue2 = 0;
}
if ($pollValue3 < 0) {
$pollValue3 = 0;
}
}
// Have to reset this every time, otherwise the exec() will append
unset($statsOutput);
$amps = 0;
$watts = 0;
if ($pollValue1) {
// The multiplier should be an int but no telling what voodoo the db might cause
$multiplier = floatval($row["Multiplier"]);
$voltage = intval($row["Voltage"]);
switch ($row["ProcessingProfile"]) {
case "SingleOIDAmperes":
$amps = $pollValue1 / $multiplier;
$watts = $amps * $voltage;
break;
case "Combine3OIDAmperes":
$amps = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier;
$watts = $amps * $voltage;
break;
case "Convert3PhAmperes":
// OO does this next formula need another set of () to be clear?
$amps = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier / 3;
$watts = $amps * 1.732 * $voltage;
break;
case "Combine3OIDWatts":
$watts = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier;
break;
default:
$watts = $pollValue1 / $multiplier;
break;
}
}
$sql = "INSERT INTO fac_PDUStats SET PDUID={$row["PDUID"]}, Wattage={$watts}, \n\t\t\t\t\tLastRead=now() ON DUPLICATE KEY UPDATE Wattage={$watts}, LastRead=now();";
if (!$dbh->query($sql)) {
$info = $dbh->errorInfo();
error_log("Poll_PDU_Stats-Multiprocess::PDO Error: {$info[2]} SQL={$sql}");
}
}
$cdu->PDUID = $row["PDUID"];
if ($ver = $cdu->GetSmartCDUVersion()) {
$sql = "UPDATE fac_PowerDistribution SET FirmwareVersion=\"{$ver}\" WHERE PDUID={$cdu->PDUID};";
if (!$dbh->query($sql)) {
$info = $dbh->errorInfo();
error_log("Poll_PDU_Stats-Multiprocess::PDO Error: {$info[2]} SQL={$sql}");
}
}
}
示例11: GetSwitchConnections
function GetSwitchConnections()
{
$selectSQL = "select * from fac_SwitchConnection where SwitchDeviceID=\"" . $this->SwitchDeviceID . "\" order by SwitchPortNumber";
$tmpDev = new Device();
$tmpDev->DeviceID = $this->SwitchDeviceID;
$tmpDev->GetDevice();
for ($i = 1; $i <= $tmpDev->Ports; $i++) {
$connList[$i] = new SwitchConnection();
$connList[$i]->SwitchDeviceID = $tmpDev->DeviceID;
$connList[$i]->SwitchPortNumber = $i;
}
foreach ($this->query($selectSQL) as $connRow) {
$connNum = $connRow["SwitchPortNumber"];
$connList[$connNum]->SwitchDeviceID = $connRow["SwitchDeviceID"];
$connList[$connNum]->SwitchPortNumber = $connRow["SwitchPortNumber"];
$connList[$connNum]->EndpointDeviceID = $connRow["EndpointDeviceID"];
$connList[$connNum]->EndpointPort = $connRow["EndpointPort"];
$connList[$connNum]->Notes = $connRow["Notes"];
}
return $connList;
}
示例12: Device
$sheet->getActiveSheet()->SetCellValue('G' . $row, '="' . $color->Name . '"');
$row++;
}
if ($targetDev->DeviceType == "Patch Panel") {
$path = DevicePorts::followPathToEndPoint($devPort->ConnectedDeviceID, $devPort->ConnectedPort);
$pDev = new Device();
$tDev = new Device();
$pPort = new DevicePorts();
$tPort = new DevicePorts();
foreach ($path as $p) {
// Skip any rear port connections
if ($p->PortNumber > 0 && $p->ConnectedPort > 0) {
$pDev->DeviceID = $p->DeviceID;
$pDev->GetDevice();
$tDev->DeviceID = $p->ConnectedDeviceID;
$tDev->GetDevice();
$pPort->DeviceID = $p->DeviceID;
$pPort->PortNumber = $p->PortNumber;
$pPort->getPort();
if ($pPort->Label == "") {
$pPort->Label = $pPort->PortNumber;
}
$tPort->DeviceID = $p->ConnectedDeviceID;
$tPort->PortNumber = $p->ConnectedPort;
$tPort->getPort();
if ($tPort->Label == "") {
$tPort->Label = $tPort->PortNumber;
}
$sheet->getActiveSheet()->SetCellValue('A' . $row, '="' . $pDev->Label . '"');
$sheet->getActiveSheet()->SetCellValue('B' . $row, '="' . $pPort->Label . '"');
$sheet->getActiveSheet()->SetCellValue('C' . $row, '="' . $tDev->Label . '"');
示例13: array
<?php
require_once 'db.inc.php';
require_once 'facilities.inc.php';
// Uncomment these if you need/want to set a title in the header
// $header=__("");
$subheader = __("Data Center Operations Metrics");
//get devices from workorder
if (isset($_GET["getDevList"])) {
$returnData = array();
$devList = array();
$getDevList = json_decode($_GET["getDevList"]);
foreach ($getDevList as $getDev) {
$dev = new Device();
$dev->DeviceID = $getDev;
if ($dev->GetDevice()) {
$devList[] = $dev;
$returnData[] = $dev;
}
}
if (isset($_GET["getConnList"])) {
$connList = array();
foreach ($devList as $dev) {
$ports = DevicePorts::getPortList($dev->DeviceID);
foreach ($ports as $port) {
$notdup = true;
if (isset($port->ConnectedDeviceID)) {
$returnData[] = $port;
}
}
}