コード例 #1
0
ファイル: autodiscovery.php プロジェクト: Evolix/lilac
         $c->add(AutodiscoveryDevicePeer::NAME, $device->getName());
         $c->setIgnoreCase(true);
         $host = AutodiscoveryDevicePeer::doSelectOne($c);
         if ($host->getId() == $device->getId()) {
             unset($host);
         }
     }
     if (!empty($host)) {
         $error = "A host already exists with the name of " . $device->getName() . ".  Change the device's name before importing.";
     }
 }
 if (empty($error)) {
     $totalSuccess = 0;
     // Okay, no errors, let's create our hosts!
     foreach ($_POST['selectedDevices'] as $deviceId) {
         $device = AutodiscoveryDevicePeer::retrieveByPK($deviceId);
         $tempHost = new NagiosHost();
         $tempHost->setAddress($device->getAddress());
         $tempHost->setName($device->getName());
         $tempHost->setAlias($device->getDescription());
         $tempHost->save();
         // Now assign a template, if wanted
         $template = $device->getNagiosHostTemplate();
         if (!empty($template)) {
             $inheritance = new NagiosHostTemplateInheritance();
             $inheritance->setNagiosHost($tempHost);
             $inheritance->setNagiosHostTemplateRelatedByTargetTemplate($template);
             $inheritance->save();
         }
         // Now parent
         $parent = $device->getNagiosHost();