本文整理汇总了PHP中Device::UpdateDevice方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::UpdateDevice方法的具体用法?PHP Device::UpdateDevice怎么用?PHP Device::UpdateDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::UpdateDevice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatedevice
function updatedevice($deviceid)
{
$dev = new Device();
$dev->DeviceID = $deviceid;
$dev->GetDevice();
$dev->PowerSupplyCount = $dev->PowerSupplyCount - 1;
$dev->UpdateDevice();
}
示例2: IN
// Get a list of all non-switch and non-patch panel devices
$sql = "select DeviceID, Ports, DeviceType from fac_Device WHERE\n\t\tDeviceType NOT IN ('Physical Infrastructure', 'Switch', 'Patch Panel')";
$swCount = $dbh->prepare("select * from fac_SwitchConnection where EndpointDeviceID=:deviceid order by EndpointPort ASC");
$ppCount = $dbh->prepare("select * from fac_PatchConnection where FrontEndpointDeviceID=:deviceid order by FrontEndpointPort ASC");
$portHash = array();
$dev = new Device();
foreach ($dbh->query($sql) as $row) {
$swCount->execute(array(":deviceid" => $row["DeviceID"]));
$totalPorts = $swCount->rowCount();
$ppCount->execute(array(":deviceid" => $row["DeviceID"]));
$totalPorts += $ppCount->rowCount();
$dev->DeviceID = $row["DeviceID"];
$dev->GetDevice();
if ($dev->Ports < $totalPorts) {
$dev->Ports = $totalPorts;
$dev->UpdateDevice();
}
while ($conRow = $swCount->fetch()) {
$pNum = sizeof($ports[$row["DeviceID"]]) + 1;
$ports[$row["DeviceID"]][$pNum] = array();
$ports[$row["DeviceID"]][$pNum]["Label"] = $conRow["EndpointPort"];
$ports[$row["DeviceID"]][$pNum]["Notes"] = $conRow["Notes"];
$ports[$row["DeviceID"]][$pNum]["Connected Device"] = $conRow["SwitchDeviceID"];
$ports[$row["DeviceID"]][$pNum]["Connected Port"] = $conRow["SwitchPortNumber"];
$portHash[$row["DeviceID"] . "-" . $conRow["EndpointPort"]] = $pNum;
$ports[$conRow["SwitchDeviceID"]][$conRow["SwitchPortNumber"]]["Notes"] = $conRow["Notes"];
$ports[$conRow["SwitchDeviceID"]][$conRow["SwitchPortNumber"]]["Connected Device"] = $row["DeviceID"];
$ports[$conRow["SwitchDeviceID"]][$conRow["SwitchPortNumber"]]["Connected Port"] = $pNum;
printf("Created port %d (%d) for device %d connected to Switch %d Port %d<br>\n", $pNum, $conRow["EndpointPort"], $row["DeviceID"], $conRow["SwitchDeviceID"], $conRow["SwitchPortNumber"]);
}
while ($conRow = $ppCount->fetch()) {
示例3: 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();
}
}
示例4: updatedevice
function updatedevice($devid)
{
$dev = new Device();
$dev->DeviceID = $devid;
$dev->GetDevice();
$dev->Ports = $dev->Ports - 1;
$dev->UpdateDevice();
}