Esempio n. 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;
 }
Esempio n. 2
0
                    }
                }
            } else {
                if ($_POST['request'] == 'parent_add') {
                    // Wants to add a parent
                    $c = new Criteria();
                    $c->add(NagiosHostPeer::NAME, $_POST['parenthost']);
                    $c->setIgnoreCase(true);
                    $parentHost = NagiosHostPeer::doSelectOne($c);
                    if (!$parentHost) {
                        $error = "The host named " . $_POST['parenthost'] . " was not found.";
                    } else {
                        $tempParent = new NagiosHostParent();
                        $tempParent->setChildHost($host->getId());
                        $tempParent->setParentHost($parentHost->getId());
                        $tempParent->save();
                        $success = "Parent added";
                    }
                }
            }
        }
    }
}
if (isset($_GET['id'])) {
    // Load template.
    $host = NagiosHostPeer::retrieveByPK($_GET['id']);
    if (!$host) {
        header("Location: hosts.php");
        die;
    } else {
        // GET VALUES
Esempio n. 3
0
                        $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">    
		$(document).ready(function() {