/**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosDependencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $criteria->add(NagiosDependencyPeer::ID, $pks, Criteria::IN);
         $objs = NagiosDependencyPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #2
0
 /**
  * Gets an array of NagiosDependency objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this NagiosTimeperiod has previously been saved, it will retrieve
  * related NagiosDependencys from storage. If this NagiosTimeperiod is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array NagiosDependency[]
  * @throws     PropelException
  */
 public function getNagiosDependencys($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNagiosDependencys === null) {
         if ($this->isNew()) {
             $this->collNagiosDependencys = array();
         } else {
             $criteria->add(NagiosDependencyPeer::DEPENDENCY_PERIOD, $this->id);
             NagiosDependencyPeer::addSelectColumns($criteria);
             $this->collNagiosDependencys = NagiosDependencyPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(NagiosDependencyPeer::DEPENDENCY_PERIOD, $this->id);
             NagiosDependencyPeer::addSelectColumns($criteria);
             if (!isset($this->lastNagiosDependencyCriteria) || !$this->lastNagiosDependencyCriteria->equals($criteria)) {
                 $this->collNagiosDependencys = NagiosDependencyPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastNagiosDependencyCriteria = $criteria;
     return $this->collNagiosDependencys;
 }
 public function export()
 {
     global $lilac;
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosDependencyExporter attempting to export dependency configuration.");
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosDependencyExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n");
     $hosts = NagiosHostPeer::doSelect(new Criteria());
     foreach ($hosts as $host) {
         // Got hosts
         // Get inherited dependencies first
         $job->addNotice("Processing dependencies for host: " . $host->getName());
         $inheritedDependencies = $host->getInheritedDependencies();
         foreach ($inheritedDependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "host", $target, $host);
             }
         }
         $dependencies = $host->getNagiosDependencys();
         foreach ($dependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "host", $target, $host);
             }
         }
         // Get our services
         $inheritedServices = $host->getInheritedServices();
         foreach ($inheritedServices as $service) {
             $job->addNotice("Processing dependencies for service: " . $service->getDescription() . " on " . $host->getName());
             $serviceInheritedDependencies = $service->getInheritedDependencies();
             foreach ($serviceInheritedDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
             $c = new Criteria();
             $c->add(NagiosDependencyPeer::HOST, $host->getId());
             $c->add(NagiosDependencyPeer::SERVICE, $service->getId());
             $serviceDependencies = NagiosDependencyPeer::doSelect($c);
             foreach ($serviceDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
         }
         $services = $host->getNagiosServices();
         foreach ($services as $service) {
             $job->addNotice("Processing dependencies for service: " . $service->getDescription() . " on " . $host->getName());
             $serviceInheritedDependencies = $service->getInheritedDependencies();
             foreach ($serviceInheritedDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
             $serviceDependencies = $service->getNagiosDependencys();
             foreach ($serviceDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
         }
         $job->addNotice("Completed dependencies export for host: " . $host->getName());
     }
     // Get hostgroup dependencies
     $hostgroups = NagiosHostgroupPeer::doSelect(new Criteria());
     foreach ($hostgroups as $hostgroup) {
         $dependencies = $hostgroup->getNagiosDependencys();
         foreach ($dependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "hostgroup", $target, $hostgroup);
             }
         }
         $job->addNotice("Completed dependencies export for hostgroup: " . $hostgroup->getName());
     }
     $job->addNotice("NagiosDependencyExporter complete.");
     return true;
 }