27 public function __construct() {
28 $this->Name =
"agent_bucket";
29 $this->Title = _(
"Bucket Analysis");
30 $this->AgentName =
"buckets";
32 parent::__construct();
39 protected function getDefaultBucketPool()
41 $user_pk = Auth::getUserId();
42 if (empty($user_pk)) {
47 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
48 $usersRec = $dbManager->getSingleRow(
'SELECT default_bucketpool_fk FROM users WHERE user_pk=$1', array($user_pk));
49 return $usersRec[
'default_bucketpool_fk'];
59 $bucketPool = $this->getDefaultBucketPool();
60 if (!empty($bucketPool))
62 menu_insert(
"Agents::" . $this->Title, 0, $this->Name);
72 $default_bucketpool_fk = $this->getDefaultBucketPool();
73 if (empty($default_bucketpool_fk)) {
77 $agentDao = $GLOBALS[
'container']->get(
'dao.agent');
78 $latestNomosAgentId = $agentDao->getCurrentAgentId(
"nomos",
"Nomos license scanner");
79 if (empty($latestNomosAgentId)) {
82 $latestBucketAgentId = $agentDao->getCurrentAgentId($this->AgentName,
"Bucket scanner");
83 if (empty($latestBucketAgentId)) {
87 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
89 $bucketLatestArsRec = $dbManager->getSingleRow(
"SELECT * FROM bucket_ars WHERE bucketpool_fk=$1 AND upload_fk=$2 AND nomosagent_fk=$3 and agent_fk=$4 AND ars_success=$5",
90 array($default_bucketpool_fk,$uploadId,$latestNomosAgentId,$latestBucketAgentId,$dbManager->booleanToDb(
true)),
91 __METHOD__.
'.latestNomosAndBucketScannedThisPool');
92 if (!empty($bucketLatestArsRec))
return 1;
94 $bucketOldArsRec = $dbManager->getSingleRow(
"SELECT * FROM bucket_ars WHERE bucketpool_fk=$1 AND upload_fk=$2 AND ars_success=$3",
95 array($default_bucketpool_fk,$uploadId,$dbManager->booleanToDb(
true)),
96 __METHOD__.
'.anyBucketScannedThisPool');
97 if (!empty($bucketOldArsRec))
return 2;
106 public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
108 $default_bucketpool_fk = $this->getDefaultBucketPool();
109 if (!$default_bucketpool_fk)
111 $errorMsg = _(
"User does not have a default bucketpool. Bucket agent cannot be scheduled without this.");
115 $dependencies[] =
"agent_nomos";
116 $dependencies[] =
"agent_pkgagent";
117 $jqargs =
"bppk=$default_bucketpool_fk, upk=$uploadId";
118 return $this->
doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies, $jqargs);
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
AgentHasResults($uploadId=0)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)