当前位置: 首页>>代码示例>>PHP>>正文


PHP Device::CreateDevice方法代码示例

本文整理汇总了PHP中Device::CreateDevice方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::CreateDevice方法的具体用法?PHP Device::CreateDevice怎么用?PHP Device::CreateDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device::CreateDevice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade


//.........这里部分代码省略.........
        $sql = "SELECT * FROM fac_CDUTemplate;";
        foreach ($dbh->query($sql) as $cdutemplate) {
            $ct = PowerTemplate::Convert($cdutemplate);
            $dt = new PowerTemplate();
            $dt->TemplateID = ++$baseid;
            $dt->ManufacturerID = $ct->ManufacturerID;
            $dt->Model = "CDU {$ct->Model}";
            $dt->PSCount = $ct->PSCount;
            $dt->DeviceType = "CDU";
            $dt->SNMPVersion = $ct->SNMPVersion;
            $dt->CreateTemplate($dt->TemplateID);
            $converted[$ct->TemplateID] = $dt->TemplateID;
        }
        // Update all the records with their new templateid
        foreach ($converted as $oldid => $newid) {
            $dbh->query("UPDATE fac_CDUTemplate SET TemplateID={$newid} WHERE TemplateID={$oldid};");
            $dbh->query("UPDATE fac_PowerDistribution SET TemplateID={$newid} WHERE TemplateID={$oldid}");
        }
        // END - CDU template conversion
        // Store a list of existing CDU ids and their converted DeviceID
        $ConvertedCDUs = array();
        // Store a list of the cdu template ids and the number of power connections they support
        $CDUTemplates = array();
        // List of ports we are going to create for every device in the system
        $PowerPorts = array();
        // These should only apply to me but the possibility exists
        $PreNamedPorts = array();
        class PowerDevice extends Device
        {
            /*
            	to be efficient we don't want to create ports right now so we're extending 
            	the class to override the create function
            */
            function CreateDevice()
            {
                global $dbh;
                $this->MakeSafe();
                $this->Label = transform($this->Label);
                $this->SerialNo = transform($this->SerialNo);
                $this->AssetTag = transform($this->AssetTag);
                $sql = "INSERT INTO fac_Device SET Label=\"{$this->Label}\", SerialNo=\"{$this->SerialNo}\", AssetTag=\"{$this->AssetTag}\", \n\t\t\t\t\tPrimaryIP=\"{$this->PrimaryIP}\", SNMPCommunity=\"{$this->SNMPCommunity}\", ESX={$this->ESX}, Owner={$this->Owner}, \n\t\t\t\t\tEscalationTimeID={$this->EscalationTimeID}, EscalationID={$this->EscalationID}, PrimaryContact={$this->PrimaryContact}, \n\t\t\t\t\tCabinet={$this->Cabinet}, Position={$this->Position}, Height={$this->Height}, Ports={$this->Ports}, \n\t\t\t\t\tFirstPortNum={$this->FirstPortNum}, TemplateID={$this->TemplateID}, NominalWatts={$this->NominalWatts}, \n\t\t\t\t\tPowerSupplyCount={$this->PowerSupplyCount}, DeviceType=\"{$this->DeviceType}\", ChassisSlots={$this->ChassisSlots}, \n\t\t\t\t\tRearChassisSlots={$this->RearChassisSlots},ParentDevice={$this->ParentDevice}, \n\t\t\t\t\tMfgDate=\"" . date("Y-m-d", strtotime($this->MfgDate)) . "\", \n\t\t\t\t\tInstallDate=\"" . date("Y-m-d", strtotime($this->InstallDate)) . "\", WarrantyCo=\"{$this->WarrantyCo}\", \n\t\t\t\t\tWarrantyExpire=\"" . date("Y-m-d", strtotime($this->WarrantyExpire)) . "\", Notes=\"{$this->Notes}\", \n\t\t\t\t\tReservation={$this->Reservation}, HalfDepth={$this->HalfDepth}, BackSide={$this->BackSide};";
                if (!$dbh->exec($sql)) {
                    $info = $dbh->errorInfo();
                    error_log("PDO Error: {$info[2]} SQL={$sql}");
                    return false;
                }
                $this->DeviceID = $dbh->lastInsertId();
                class_exists('LogActions') ? LogActions::LogThis($this) : '';
                return $this->DeviceID;
            }
        }
        // Create new devices from existing CDUs
        $sql = "SELECT * FROM fac_PowerDistribution;";
        foreach ($dbh->query($sql) as $row) {
            $dev = new PowerDevice();
            $dev->Label = $row['Label'];
            $dev->Cabinet = $row['CabinetID'];
            $dev->TemplateID = $row['TemplateID'];
            $dev->PrimaryIP = $row['IPAddress'];
            $dev->SNMPCommunity = $row['SNMPCommunity'];
            $dev->Position = 0;
            $dev->Height = 0;
            $dev->Ports = 1;
            if (!isset($CDUTemplates[$dev->TemplateID])) {
                $CDUTemplates[$dev->TemplateID] = $dbh->query("SELECT NumOutlets FROM fac_CDUTemplate WHERE TemplateID={$dev->TemplateID} LIMIT 1;")->fetchColumn();
            }
开发者ID:Gusenichka,项目名称:openDCIM,代码行数:67,代码来源:install.php

示例2: Cabinet

    }
    // This should be in the commit data but if we get a smartass saying it's in the URL
    $dev->Label = $devicelabel;
    $cab = new Cabinet();
    $cab->CabinetID = $dev->Cabinet;
    if (!$cab->GetCabinet()) {
        $response['error'] = true;
        $response['errorcode'] = 404;
        $response['message'] = __("Cabinet not found");
    } else {
        if ($cab->Rights != "Write") {
            $response['error'] = true;
            $response['errorcode'] = 403;
            $response['message'] = __("Unauthorized");
        } else {
            if (!$dev->CreateDevice()) {
                $response['error'] = true;
                $response['errorcode'] = 404;
                $response['message'] = __("Device creation failed");
            } else {
                // refresh the model in case we extended it elsewhere
                $dev = new Device($dev->DeviceID);
                $dev->GetDevice();
                $response['error'] = false;
                $response['errorcode'] = 200;
                $response['device'] = $dev;
            }
        }
    }
    echoResponse(200, $response);
});
开发者ID:mnibbelink,项目名称:openDCIM,代码行数:31,代码来源:index.php

示例3: date

     if ($person->RackAdmin && $_POST['action'] == 'Move to Rack') {
         $req->CompleteRequest();
         $dev->Label = $req->Label;
         $dev->SerialNo = $req->SerialNo;
         $dev->MfgDate = $req->MfgDate;
         $dev->InstallDate = date('Y-m-d');
         $dev->AssetTag = $req->AssetTag;
         $dev->ESX = $req->ESX;
         $dev->Owner = $req->Owner;
         $dev->Cabinet = $_POST['CabinetID'];
         $dev->Position = $_POST['position'];
         $dev->Height = $req->DeviceHeight;
         $dev->Ports = $req->EthernetCount;
         $dev->DeviceType = $req->DeviceType;
         $dev->TemplateID = $req->DeviceClass;
         $dev->CreateDevice();
         $htmlMessage .= "<p>" . sprintf(__('Your request for racking up the device labeled %1$s has been completed.'), $req->Label) . "</p>";
         $htmlMessage .= "<p>" . sprintf(__('To view your device in its final location click %1$s'), "<a href=\"" . redirect("devices.php?DeviceID={$dev->DeviceID}") . "\"> " . __("this link") . "</a>.</p>\n\t\t\t\t</body></html>");
         $message->setBody($htmlMessage, 'text/html');
         try {
             $result = $mailer->send($message);
         } catch (Swift_RfcComplianceException $e) {
             $error .= "Send: " . $e->getMessage() . "<br>\n";
         } catch (Swift_TransportException $e) {
             $error .= "Server: <span class=\"errmsg\">" . $e->getMessage() . "</span><br>\n";
         }
         header('Location: ' . redirect("devices.php?DeviceID={$dev->DeviceID}"));
         exit;
     }
 } elseif ($_POST['action'] == 'Delete Request') {
     if ($person->RackAdmin || $person->UserID == $contact->UserID) {
开发者ID:ghasedak,项目名称:openDCIM,代码行数:31,代码来源:rackrequest.php


注:本文中的Device::CreateDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。