Пример #1
0
 function addParentByName($name)
 {
     $parentId = $this->getParentHost();
     $c = new Criteria();
     $c->add(NagiosHostPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $host = NagiosHostPeer::doSelectOne($c);
     if (!$host) {
         return false;
     }
     if (empty($parentId)) {
         $this->setParentHost($host->getId());
         return true;
     }
     // Okay, let's first see if there's a parent relationship around
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosHostParentPeer::CHILD_HOST_TEMPLATE, $this->getId());
         $c->add(NagiosHostParentPeer::PARENT_HOST, $host->getId());
         $relationship = NagiosHostParentPeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     // Okay, relationship doesn't exist, let's add it!
     $relationship = new NagiosHostParent();
     $relationship->setNagiosHostTemplate($this);
     $relationship->setNagiosHostRelatedByParentHost($host);
     $relationship->save();
     return true;
 }
Пример #2
0
                        $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();
                        if (!empty($parent)) {
                            $parentRelationship = new NagiosHostParent();
                            $parentRelationship->setNagiosHostRelatedByChildHost($tempHost);
                            $parentRelationship->setNagiosHostRelatedByParentHost($parent);
                            $parentRelationship->save();
                        }
                        $totalSuccess++;
                        $device->delete();
                    }
                    $success = $totalSuccess . " Device(s) Imported.";
                }
            }
        }
    }
}
print_header("AutoDiscovery");
if (isset($autodiscoveryJob)) {
    ?>
    <script type="text/javascript">