예제 #1
0
 static function createPorts($DeviceID, $update_existing = false)
 {
     // If $update_existing is true then we'll try to create all the ports and as a by product
     // create any new ports.  The setting here will ensure we don't log any errors from the
     // ports that already exist.
     $dev = new Device();
     $dev->DeviceID = $DeviceID;
     if (!$dev->GetDevice()) {
         return false;
     }
     // Check the user's permissions to modify this device
     if ($dev->Rights != 'Write') {
         return false;
     }
     $portList = array();
     //Search template ports
     $tports = array();
     if ($dev->TemplateID > 0) {
         $tport = new TemplatePowerPorts();
         $tport->TemplateID = $dev->TemplateID;
         $tports = $tport->getPorts();
     }
     for ($i = 1; $i <= $dev->PowerSupplyCount; $i++) {
         $portList[$i] = new PowerPorts();
         $portList[$i]->DeviceID = $dev->DeviceID;
         $portList[$i]->PortNumber = $i;
         if (isset($tports[$i])) {
             // Get any attributes from the template
             foreach ($tports[$i] as $key => $value) {
                 if (array_key_exists($key, $portList[$i])) {
                     $portList[$i]->{$key} = $value;
                 }
             }
             // Temp fix for issue #632 until the models can be brought into alignment
             $portList[$i]->Notes = $tports[$i]->PortNotes;
         }
         $portList[$i]->Label = $portList[$i]->Label == "" ? __("Power Connection") . " {$i}" : $portList[$i]->Label;
         $portList[$i]->createPort($update_existing);
     }
     return $portList;
 }
예제 #2
0
        $response['error'] = false;
        $response['errorcode'] = 200;
        $response['dataport'] = $tp;
    }
    echoResponse(200, $response);
});
//
//	URL:	/api/v1/devicetemplate/:templateid/powerport
//	Method:	GET
//	Params: templateid
//	Returns: Power ports defined for device template with templateid
//
$app->get('/devicetemplate/:templateid/powerport', function ($templateid) use($app) {
    $tp = new TemplatePowerPorts();
    $tp->TemplateID = $templateid;
    if (!($ports = $tp->getPorts())) {
        $response['error'] = true;
        $response['errorcode'] = 404;
        $response['message'] = __("No ports found for TemplateID: ") . " {$templateid}";
    } else {
        $response['error'] = false;
        $response['errorcode'] = 200;
        $response['powerport'] = $ports;
    }
    echoResponse(200, $response);
});
//
//	URL:	/api/v1/devicetemplate/:templateid/slot
//	Method:	GET
//	Params: templateid
//	Returns: Slots defined for device template with templateid
예제 #3
0
     $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);
 $postData["templateports"] = array();
 foreach ($tpList as $tport) {
     array_push($postData["templateports"], json_decode(json_encode($tport), true));
 }
 $tpp = new TemplatePowerPorts();
 $tpp->TemplateID = $temp->TemplateID;
 $tppList = $tpp->getPorts();
 $postData["templatepowerports"] = array();
 foreach ($tppList as $pport) {
     array_push($postData["templatepowerports"], json_decode(json_encode($pport), true));
 }
 if ($temp->DeviceType == "Chassis") {
     $sList = Slot::getSlots($temp->TemplateID);
     $postData["slots"] = array();
     foreach ($sList as $s) {
         array_push($postData["slots"], json_decode(json_encode($s), true));
     }
 }
 if ($temp->DeviceType == "CDU") {
     $ct->TemplateID = $temp->TemplateID;
     $ct->GetTemplate();
     $postData["cdutemplate"] = json_decode(json_encode($ct), true);