/** * Declares an association between this object and a AutodiscoveryJob object. * * @param AutodiscoveryJob $v * @return AutodiscoveryDevice The current object (for fluent API support) * @throws PropelException */ public function setAutodiscoveryJob(AutodiscoveryJob $v = null) { if ($v === null) { $this->setJobId(NULL); } else { $this->setJobId($v->getId()); } $this->aAutodiscoveryJob = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the AutodiscoveryJob object, it will not be re-added. if ($v !== null) { $v->addAutodiscoveryDevice($this); } return $this; }
} if (isset($_POST['request'])) { if ($_POST['request'] == "autodiscover") { if (!strlen(trim($_POST['job_name']))) { $error = "Job name must be provided."; } else { if (count($_POST['target']) == 0) { $error = "You must provide at least one target."; } else { ksort($_POST['target']); $config = new AutodiscoveryConfig("NmapAutoDiscoveryEngine"); $config->setVar("targets", $_POST['target']); $config->setVar("nmap_binary", $_POST['nmap_binary']); $config->setVar("traceroute_enabled", empty($_POST['traceroute_enabled']) ? true : true); $config->setVar("default_template", $_POST['default_template']); $autodiscoveryJob = new AutodiscoveryJob(); $autodiscoveryJob->setName($_POST['job_name']); $autodiscoveryJob->setDescription($_POST['job_description']); $autodiscoveryJob->setCmd(AutodiscoveryJob::CMD_START); $autodiscoveryJob->setConfig(serialize($config)); $autodiscoveryJob->setStatus("Starting..."); $autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_STARTING); $autodiscoveryJob->save(); // Attempt to execute the external auto-discovery script, fork it, and love it. exec("php autodiscovery/autodiscover.php " . $autodiscoveryJob->getId() . " > /dev/null", $tempOutput, $retVal); if ($retVal != 42) { $status_msg = "Failed to run external Autodiscovery script. Return value: " . $retVal . "<br /> Error:"; foreach ($tempOutput as $output) { $status_msg .= $output . "<br />"; } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param AutodiscoveryJob $value A AutodiscoveryJob object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(AutodiscoveryJob $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }