X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fsystems%2Fadmin%2Fsystems%2Fclass_servGeneric.inc;h=716e6a0cec35c50f05d6f68445a0d9acfc523eca;hb=1c3a983c1becc18239a03aa271f4d3347d0a9a49;hp=ac8d330eb1ec2f79035193821982417624397486;hpb=ce4c2c39b7fa0f95972890ea3e90378ac7841457;p=gosa.git diff --git a/gosa-plugins/systems/admin/systems/class_servGeneric.inc b/gosa-plugins/systems/admin/systems/class_servGeneric.inc index ac8d330eb..716e6a0ce 100644 --- a/gosa-plugins/systems/admin/systems/class_servGeneric.inc +++ b/gosa-plugins/systems/admin/systems/class_servGeneric.inc @@ -1,12 +1,27 @@ "Eins ist toll", "zwei" => "Zwei ist noch besser"); - /* Generic terminal attributes */ var $ignore_account= TRUE; var $interfaces= array(); @@ -17,7 +32,6 @@ class servgeneric extends plugin var $l= ""; var $description= ""; var $orig_dn= ""; - var $didAction= FALSE; /* attribute list for save action */ var $attributes= array("cn", "description","gotoMode"); @@ -28,15 +42,8 @@ class servgeneric extends plugin var $netConfigDNS; var $modes = array(); var $ui ; - var $mapActions = array("reboot" => "", - "instant_update" => "softupdate", - "localboot" => "localboot", - "update" => "sceduledupdate", - "reinstall" => "install", - "rescan" => "", - "wake" => "", - "memcheck" => "memcheck", - "sysinfo" => "sysinfo"); + var $validActions = array("reboot" => "", "update" => "", "localboot" => "", "reinstall" => "", "rescan" => "", + "wake" => "", "memcheck" => "", "sysinfo" => ""); var $fai_activated =FALSE; var $view_logged = FALSE; @@ -104,50 +111,30 @@ class servgeneric extends plugin return($display); } - /* Check for action */ - if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){ - $method= "gosa"; - $action= $_POST['saction']; - if ($action == "reinstall" || $action == "update" || $action == "instant_update"){ - $method= "job"; - } - gosaSupportDaemon::send("${method}_trigger_action_".$action, $this->netConfigDNS->macAddress, array("macAddress" => $this->netConfigDNS->macAddress)); - - $this->didAction= TRUE; - - if ($_POST['saction'] != "wake") { - - /* Set FAIstate */ - if($this->fai_activated && $this->dn != "new"){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - if($attrs['FAIstate'] == ""){ - #FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } - $ldap->cd($this->dn); - $ldap->modify($attrs); + if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){ + $action = $_POST['saction']; + + /* Check if we have an DaemonEvent for this action */ + if(class_available("DaemonEvent")){ + $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT); + if(isset($events['TRIGGERED']["DaemonEvent_".$action])){ + $evt = $events['TRIGGERED']["DaemonEvent_".$action]; + $tmp = new $evt['CLASS_NAME']($this->config); + $tmp->add_targets(array($this->netConfigDNS->macAddress)); + $tmp->set_type(TRIGGERED_EVENT); + $o_queue = new gosaSupportDaemon(); + if(!$o_queue->append($tmp)){ + msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."), + $o_queue->get_error()),ERROR_DIALOG); } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn)); + } + }else{ + msg_dialog::display(_("Event error"), + sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG); } + } /* Base select dialog */ @@ -200,14 +187,9 @@ class servgeneric extends plugin $smarty->assign("base_select", $this->base); /* Assign status */ - $query= "fping -q -r 1 -t 500 ".$this->cn; - exec ($query, $dummy, $retval); - - /* Offline */ - if ($retval == 0){ + if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){ $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), - "instant_update" => _("Instant update"), - "update" => _("Scheduled update"), + "update" => _("Update"), "reinstall" => _("Reinstall"), "rescan" => _("Rescan hardware"), "memcheck" => _("Memory test"), @@ -216,7 +198,7 @@ class servgeneric extends plugin } else { $smarty->assign("actions", array("wake" => _("Wake up"), "reinstall" => _("Reinstall"), - "update" => _("Scheduled update"), + "update" => _("Update"), "memcheck" => _("Memory test"), "localboot" => _("Force localboot"), "sysinfo" => _("System analysis"))); @@ -293,12 +275,12 @@ class servgeneric extends plugin /* must: cn */ if ($this->cn == ""){ - $message[]= _("The required field 'Server name' is not set."); + msgPool::required(_("Server name")); } /* Check if given name is a valid host/dns name */ if(!tests::is_dns_name($this->cn)){ - $message[] = _("Please specify a valid name for this object."); + $message[]= msgPool::invalid(_("Server name"), $this->cn, "/[a-z0-9\.\-]/i"); } if ($this->orig_dn != $this->dn){ @@ -309,7 +291,7 @@ class servgeneric extends plugin while ($attrs= $ldap->fetch()){ if ($attrs['dn'] != $this->orig_dn){ if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,".get_ou('incomingou')."/",$attrs['dn']) && preg_match("/,".get_ou('serverou')."/",$attrs['dn'])){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + $message[]= msgPool::duplicated(_("Server name")); break; } } @@ -380,12 +362,24 @@ class servgeneric extends plugin $this->netConfigDNS->save(); /* Optionally execute a command after we're done */ - if(!$this->didAction){ - $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } + $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); if ($activate){ - gosaSupportDaemon::send("gosa_set_activated_for_installation", $this->netConfigDNS->ipHostNumber); + + /* Send installation activation + */ + $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT); + $o_queue = new gosaSupportDaemon(); + if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){ + $evt = $events['TRIGGERED']['DaemonEvent_installation_activation']; + $tmp = new $evt['CLASS_NAME']($this->config); + $tmp->set_type(TRIGGERED_EVENT); + $tmp->add_targets(array($this->netConfigDNS->macAddress)); + if(!$o_queue->append($tmp)){ + msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."), + $o_queue->get_error()),ERROR_DIALOG); + } + } } }