diff --git a/gosa-plugins/systems/admin/systems/class_servGeneric.inc b/gosa-plugins/systems/admin/systems/class_servGeneric.inc
index ac8d330eb1ec2f79035193821982417624397486..716e6a0cec35c50f05d6f68445a0d9acfc523eca 100644 (file)
<?php
<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class servgeneric extends plugin
{
class servgeneric extends plugin
{
- /* CLI vars */
- var $cli_summary= "Manage server base objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* Generic terminal attributes */
var $ignore_account= TRUE;
var $interfaces= array();
/* Generic terminal attributes */
var $ignore_account= TRUE;
var $interfaces= array();
var $l= "";
var $description= "";
var $orig_dn= "";
var $l= "";
var $description= "";
var $orig_dn= "";
- var $didAction= FALSE;
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
var $netConfigDNS;
var $modes = array();
var $ui ;
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;
var $fai_activated =FALSE;
var $view_logged = FALSE;
return($display);
}
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 */
}
/* Base select dialog */
$smarty->assign("base_select", $this->base);
/* Assign status */
$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"),
$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"),
"reinstall" => _("Reinstall"),
"rescan" => _("Rescan hardware"),
"memcheck" => _("Memory test"),
} else {
$smarty->assign("actions", array("wake" => _("Wake up"),
"reinstall" => _("Reinstall"),
} else {
$smarty->assign("actions", array("wake" => _("Wake up"),
"reinstall" => _("Reinstall"),
- "update" => _("Scheduled update"),
+ "update" => _("Update"),
"memcheck" => _("Memory test"),
"localboot" => _("Force localboot"),
"sysinfo" => _("System analysis")));
"memcheck" => _("Memory test"),
"localboot" => _("Force localboot"),
"sysinfo" => _("System analysis")));
/* must: cn */
if ($this->cn == ""){
/* 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)){
}
/* 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){
}
if ($this->orig_dn != $this->dn){
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'])){
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;
}
}
break;
}
}
$this->netConfigDNS->save();
/* Optionally execute a command after we're done */
$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){
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);
+ }
+ }
}
}
}
}