From 6c906021bfa33b15fb34c7a4c4e77f50f9529d7c Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 6 Mar 2008 15:10:20 +0000 Subject: [PATCH] Updated gosaDaemon -Added a new function that allows to remove all entries with a specific mac --Processing entries will be canceled via break job. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9395 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_gosaSupportDaemon.inc | 73 ++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index 803ff31c9..c8a05a09f 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -398,7 +398,7 @@ $xml_msg.= " $this->o_sock->write($xml_msg); $str = $this->o_sock->read(); $entries = $this->xml_to_array($str); - if(isset($entries['XML'])){ + if(isset($entries['XML']) || isset($entries['COUNT'])){ return(TRUE); } } @@ -720,6 +720,77 @@ $xml_msg.= " } + /*! \brief Removes all jobs from the queue that are tiggered with a specific macAddress. + @param String $mac The mac address for which we want to remove all jobs. + */ + function clean_queue_from_mac($mac) + { + global $config; + + /* First of all we have to check which jobs are startet + * for $mac + */ + $xml_msg =" + +
gosa_query_jobdb
+ GOSA + GOSA + + + + ".$mac." + + + +
+ "; + + $data = $this->_send($xml_msg,TRUE); + if(is_array($data) && isset($data['XML'])){ + $already_aborted = FALSE; + foreach($data['XML'] as $name => $entry){ + if(preg_match("/answer[0-9]*/i",$name)){ + $entry['STATUS'] = strtoupper($entry['STATUS']); + switch($entry['STATUS']){ + + case 'PROCESSING' : + + /* Send abort event, but only once + */ + if($already_aborted){ + break; + }elseif(class_available("DaemonEvent_faireboot")){ + $already_aborted = TRUE; + $tmp = new DaemonEvent_faireboot($config); + $tmp->add_targets(array($mac)); + $tmp->set_type(TRIGGERED_EVENT); + if(!$this->append($tmp)){ + msg_dialog::display(_("Error"), sprintf(_("Cannot send abort event for entry: %s"),$entry['ID']) , ERROR_DIALOG); + } + ;break; + }else{ + /* Couldn't find abort event, just remove entry */ + } + + case 'WAITING': + case 'ERROR': + default : + + /* Simply remove entries from queue. + * Failed or waiting events, can be removed without any trouble. + */ + if(!$this->remove_entries(array($entry['ID']))){ + msg_dialog::display(_("Error"), sprintf(_("Cannot remove entry: %s"),$entry['ID']) , ERROR_DIALOG); + } + ;break; + } + + } + } + } + } + + static function ping($target) { if (tests::is_mac($target)){ -- 2.30.2