diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc
index 4511c35e0d92f3cfcad1f96aadee5129ddd97f35..219fdbb36ca2ed0d03dcce6ff3d5524e5527e3c8 100644 (file)
@param boolean Connect Directly connect to daemon socket.
@param float Timeout The timelimit for all socket actions.
*/
- public function __construct($connect=TRUE,$timeout=2)
+ public function __construct($connect=TRUE,$timeout=10)
{
#FIXME: bad idea about referencing global variables from within classes
global $config;
*/
public function connect()
{
- $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
- if($this->o_sock->connected()){
- $this->o_sock->setEncryptionKey($this->s_encryption_key);
- $this->is_connected = TRUE;
+ if(!empty($this->s_host) && !empty($this->i_port)){
+ $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
+ if($this->o_sock->connected()){
+ $this->o_sock->setEncryptionKey($this->s_encryption_key);
+ $this->is_connected = TRUE;
+ }else{
+ $this->set_error($this->o_sock->get_error());
+ $this->disconnect();
+ new log("debug","gosaSupportDaemon::connect()", "Could not connect to server.", array(),$this->get_error());
+ }
}else{
- $this->set_error($this->o_sock->get_error());
- $this->disconnect();
- new log("debug","gosaSupportDaemon::connect()", "Could not connect to server.", array(),$this->get_error());
+ $this->set_error(msgPool::cmdnotfound("GOSA_SI",_("GOsa support daemon")));
}
return($this->is_connected);
}
}
+ public function FAI_get_packages($release,$package = "")
+ {
+ $this->reset_error();
+
+ if(empty($package)){
+ $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+ "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where></xml>";
+ }else{
+ $xml_msg =
+ "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+ "<where><clause>".
+ "<connector>AND</connector>".
+ "<phrase><distribution>".$release."</distribution></phrase>".
+ "<phrase><package>".$package."</package></phrase>".
+ "</clause></where>".
+ "</xml>";
+ }
+
+ $ret = array();
+ if($this->connect()){
+ $this->o_sock->write($xml_msg);
+ $str = trim($this->o_sock->read());
+ $entries = $this->xml_to_array($str);
+ if(isset($entries['XML']) && is_array($entries['XML'])){
+
+ /* Check if returned values represent a valid answer */
+ if(isset($entries['XML'])){
+ if(isset($entries['XML']['ERROR_STRING'])) {
+ $this->set_error($entries['XML']['ERROR_STRING']);
+ new log("debug","GOsa-si",
+ get_class($this)."::".__FUNCTION__, array(),
+ "FAILED error was ".$this->get_error());
+ return($ret);
+ }
+
+ /* Unset header tags */
+ foreach(array("HEADER","SOURCE","TARGET","SESSION_ID") as $type){
+ if(isset($entries['XML'][$type])){
+ unset($entries['XML'][$type]);
+ }
+ }
+ $ret = $entries['XML'];
+ }
+ }
+ }
+ return($ret);
+
+
+ }
+
+
+ public function FAI_get_server($name = "")
+ {
+ $this->reset_error();
+
+ $xml_msg = "<xml><header>gosa_query_fai_server</header><target>GOSA</target><source>GOSA</source></xml>";
+ $ret = array();
+ if($this->connect()){
+ $this->o_sock->write($xml_msg);
+ $str = trim($this->o_sock->read());
+ $entries = $this->xml_to_array($str);
+ if(isset($entries['XML']) && is_array($entries['XML'])){
+
+ /* Check if returned values represent a valid answer */
+ if(isset($entries['XML'])){
+ if(isset($entries['XML']['ERROR_STRING'])) {
+ $this->set_error($entries['XML']['ERROR_STRING']);
+ new log("debug","GOsa-si",
+ get_class($this)."::".__FUNCTION__, array(),
+ "FAILED error was ".$this->get_error());
+ return($ret);
+ }
+
+ /* Unset header tags */
+ foreach(array("HEADER","SOURCE","TARGET","SESSION_ID") as $type){
+ if(isset($entries['XML'][$type])){
+ unset($entries['XML'][$type]);
+ }
+ }
+ $ret = $entries['XML'];
+ }
+ }
+ }
+ return($ret);
+ }
+
+
+ public function FAI_get_classes($name)
+ {
+ $this->reset_error();
+ $xml_msg = "<xml><header>gosa_query_fai_release</header><target>GOSA</target><source>GOSA</source>".
+ "<where><clause><phrase><release>".$name."</release></phrase></clause></where></xml>";;
+ $ret = array();
+ if($this->connect()){
+ $this->o_sock->write($xml_msg);
+ $str = trim($this->o_sock->read());
+ $entries = $this->xml_to_array($str);
+ if(isset($entries['XML']) && is_array($entries['XML'])){
+
+ /* Check if returned values represent a valid answer */
+ if(isset($entries['XML'])){
+ if(isset($entries['XML']['ERROR_STRING'])) {
+ $this->set_error($entries['XML']['ERROR_STRING']);
+ new log("debug","GOsa-si",
+ get_class($this)."::".__FUNCTION__, array($name),
+ "FAILED error was ".$this->get_error());
+ return($ret);
+ }
+
+ /* Unset header tags */
+ foreach(array("HEADER","SOURCE","TARGET","SESSION_ID") as $type){
+ if(isset($entries['XML'][$type])){
+ unset($entries['XML'][$type]);
+ }
+ }
+ $ret = $entries['XML'];
+ }
+ }
+ }
+ return($ret);
+ }
+
+
/*! \brief Returns an array containing all queued entries.
@return Array All queued entries as an array.
*/
$tags = "<where><clause>".$tags."</clause></where>";
}
- $xml_msg = "<xml>
+ $xml_msg =
+"<xml>
<header>gosa_query_jobdb</header>
<target>GOSA</target>
<source>GOSA</source>
}
}
+ /* Remove session ID. No one is interested in this... */
+ unset($ret['SESSION_ID']);
+
return($ret);
}
if(!isset($params['XML'])){
if (!array_key_exists('XML', $params)){
- $this->set_error(_("Could not parse XML."));
+ $this->set_error(_("Cannot not parse XML!"));
}
$params = array("COUNT" => 0);
}
/* Prepare data */
foreach ($data as $key => $value){
if(is_array($value)){
- foreach($value as $sub_val){
+ foreach($value as $sub_value){
$xml_message.= "<$key>$sub_value</$key>";
}
}else{
$request_answer = FALSE;
if($event->get_type() == SCHEDULED_EVENT){
$action = $event->get_schedule_action();
- $request_answer = TRUE;
}elseif($event->get_type() == TRIGGERED_EVENT){
$action = $event->get_trigger_action();
}else{
$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);
+ msg_dialog::display(_("Error"), sprintf(_("Cannot send abort event for entry %s!"),$entry['ID']) , ERROR_DIALOG);
new log("debug","DaemonEvent ", "gosaSupportDaemon::clean_queue_from_mac()", array($mac => $mac),
"FAILED, could not send 'DaemonEvent_faireboot' for entry ID (".$entry['ID'].") - ".$this->get_error());
}else{
* 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);
+ msg_dialog::display(_("Error"), sprintf(_("Cannot remove entry %s!"),$entry['ID']) , ERROR_DIALOG);
}
;break;
}