From: hickert Date: Wed, 27 Feb 2008 07:24:36 +0000 (+0000) Subject: Updated system management. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c0fb6c51a64a0e121116172242e85a847022f22d;p=gosa.git Updated system management. -Trigger actions from menu updated. (Only Schedule works right now.) git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9139 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/systems/admin/systems/class_divListSystem.inc b/gosa-plugins/systems/admin/systems/class_divListSystem.inc index dc5467a98..909cc65d8 100644 --- a/gosa-plugins/systems/admin/systems/class_divListSystem.inc +++ b/gosa-plugins/systems/admin/systems/class_divListSystem.inc @@ -199,21 +199,18 @@ class divListSystem extends MultiSelectWindow " "._("Component")."|"."newsystem_component|\n"; } - # Actions + $events = DaemonEvent::get_event_types(); $s.= "..|". " "._("Trigger action")."|\n"; - $s.= "...|"." "._("Halt")."|"."halt_multiple|\n"; - $s.= "...|"." "._("Reboot")."|"."reboot_multiple|\n"; - $s.= "...|"." "._("Re-install")."|"."reinstall_multiple|\n"; - $s.= "...|"." "._("Softupdate")."|"."update_multiple|\n"; - $s.= "...|"." "._("Wake up")."|"."wake_multiple|\n"; + foreach($events['BY_CLASS'] as $name => $event){ + $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|trigger_event_".$name."\n"; + } + $s.= "..|". " "._("Schedule action")."|\n"; - $s.= "...|"." "._("Halt")."|"."schedule_halt_multiple|\n"; - $s.= "...|"." "._("Reboot")."|"."schedule_reboot_multiple|\n"; - $s.= "...|"." "._("Re-install")."|"."schedule_reinstall_multiple|\n"; - $s.= "...|"." "._("Softupdate")."|"."schedule_update_multiple|\n"; - $s.= "...|"." "._("Wake up")."|"."schedule_wake_multiple|\n"; + foreach($events['BY_CLASS'] as $name => $event){ + $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|schedule_event_".$name."\n"; + } $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; diff --git a/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/gosa-plugins/systems/admin/systems/class_systemManagement.inc index e626517c4..d2f695baa 100644 --- a/gosa-plugins/systems/admin/systems/class_systemManagement.inc +++ b/gosa-plugins/systems/admin/systems/class_systemManagement.inc @@ -141,6 +141,16 @@ class systems extends plugin $s_action = "editPaste"; } + /* Handle daemon events */ + if(isset($_POST['menu_action']) && preg_match("/^trigger_event_/",$_POST['menu_action'])){ + $s_action = $_POST['menu_action']; + } + + /* Handle daemon events */ + if(isset($_POST['menu_action']) && preg_match("/^schedule_event_/",$_POST['menu_action'])){ + $s_action = $_POST['menu_action']; + } + /* handle remove from layers menu */ if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ $s_action = "del_multiple"; @@ -483,28 +493,57 @@ class systems extends plugin /******************** - Action for MULTIPLE entries requested + Action(s) for MULTIPLE ********************/ - if (preg_match("/(halt|reboot|reinstall|update|wake|)_multiple/", $s_action)){ + + /******************** + SCHEDULE action in GOsa Daemon + ********************/ + if(preg_match("/^schedule_event_/",$s_action)){ $this->dns = array(); $ids = $this->list_get_selected_items(); if(count($ids)){ - $mac= array(); - $ldap = $this->config->get_ldap_link(); + $mac= array(); + $ldap = $this->config->get_ldap_link(); foreach($ids as $id){ - $ldap->cat ($this->terminals[$id]['dn'], array("macAddress")); - $attrs= $ldap->fetch(); - if (isset($attrs['macAddress'][0])){ - $mac[]= $attrs['macAddress'][0]; - } + $ldap->cat ($this->terminals[$id]['dn'], array("macAddress")); + $attrs= $ldap->fetch(); + if (isset($attrs['macAddress'][0])){ + $mac[]= $attrs['macAddress'][0]; + } } + $events = DaemonEvent::get_event_types(); + $type = preg_replace("/^schedule_event_/","",$s_action); + if(count($mac) && isset($events['BY_CLASS'][$type])){ + $event = $events['BY_CLASS'][$type]; + $this->systab = new $event['CLASS_NAME']($this->config); + $this->systab->add_targets($mac); + } + } + } - /* Action.... */ - $action= preg_replace('/_multiple.*$/', '', $s_action); - gosaSupportDaemon::send("gosa_trigger_action_".$action, $mac, array("macAddress" => $mac)); - + /* Insert scheduled events into queue */ + if($this->systab instanceof DaemonEvent){ + $this->systab->save_object(); + if(isset($_POST['save_event_dialog'])){ + $header = $this->systab->get_header_tag(); + $targets = $this->systab->get_targets(); + $data = $this->systab->save(); + $data['timestamp'] = $this->systab->get_timestamp(); + $o_queue = new gosaSupportDaemon(); + foreach($targets as $target){ + $data['mac'] = $target; + if(!$o_queue->send($header,$target,$data,TRUE)){ + msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."), + $o_queue->get_error()),ERROR_DIALOG); + } + } + $this->systab = FALSE; + } + if(isset($_POST['abort_event_dialog'])){ + $this->systab = FALSE; } }