diff --git a/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/gosa-plugins/goto/addons/goto/class_gotomasses.inc
index 13c563bb3005d7dfa7459f495861d06cb64f37d9..ce00d1e933577301547fc7a029cfb9ad56295512 100644 (file)
class gotomasses extends plugin
{
/* Definitions */
- var $plHeadline = "System deployment";
- var $plDescription = "This does something";
+ var $plHeadline = "Deployment status";
+ var $plDescription = "System deployment status";
/* attribute list for save action */
var $attributes= array();
var $event_tags = array();
var $sort_by = "Schedule";
- var $sort_dir = "down";
+ var $sort_dir = "up";
var $entries = array();
var $range = 25;
var $start = 0;
+ var $recently_removed = array();
+
function gotomasses(&$config, $dn= NULL)
{
/* Include config object */
$this->config= &$config;
- $this->o_queue = new gosaSupportDaemon(TRUE,10);
+ $this->o_queue = new gosaSupportDaemon(TRUE,5);
$this->events = DaemonEvent::get_event_types( SYSTEM_EVENT);
/* Get tags that will be used in queue searches */
$this->event_tags = array("none");
- foreach($this->events['BY_CLASS'] as $evt){
- if(isset($evt['s_Queued_Action'])){
- $this->event_tags[] = $evt['s_Queued_Action'];
- }
+ foreach($this->events['SCHEDULED'] as $evt){
+ $this->event_tags[] = $evt['s_Queued_Action'];
+ }
+
+ /* Load filter settings */
+ if(!session::is_set("gotomasses_filter")){
+ $gotomasses_filter =
+ array(
+ "range" => $this->range,
+ "sort_by" => $this->sort_by,
+ "sort_dir" => $this->sort_dir);
+ session::set("gotomasses_filter",$gotomasses_filter);
+ }
+ $gotomasses_filter = session::get("gotomasses_filter");
+ foreach(array("range","sort_by","sort_dir") as $attr) {
+ $this->$attr = $gotomasses_filter[$attr];
}
}
"/^prio_down_/" => "prio_down",
"/^edit_task_/" => "edit",
+ "/^log_view_/" => "logview",
"/^remove_task_/" => "remove",
"/^new_task_/" => "new_task");;
}
+ /************
+ * Import CSV file
+ ************/
+
+ if($s_action == "import_file"){
+ $this->dialog = new goto_import_file($this->config,$this);
+ }
+
+ if(isset($_POST['import_abort'])){
+ $this->dialog = FALSE;
+ }
+
+
/************
* Handle Priority modifications
************/
$type = FALSE;
if(isset($this->entries[$id])){
$event = $this->entries[$s_entry];
-
-
- if($event['STATUS'] == "waiting" && isset($this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']])){
- $type = $this->events['BY_QUEUED_ACTION'][$event['HEADERTAG']];
+ if($event['STATUS'] == "waiting" && isset($this->events['QUEUED'][$event['HEADERTAG']])){
+ $evt_name = $this->events['QUEUED'][$event['HEADERTAG']];
+ $type = $this->events['BY_CLASS'][$evt_name];
$this->dialog = new $type['CLASS_NAME']($this->config,$event);
}
}
}
+
+ /************
+ * LOG VIEW
+ ************/
+
+ if($s_action == "logview"){
+ $id = $s_entry;
+ $type = FALSE;
+ if(isset($this->entries[$id])){
+ $event = $this->entries[$s_entry];
+ $this->dialog = new goto_log_view($this->config,"",$event,$this);
+ }
+ }
+
+
/************
* REMOVE
************/
if($s_action == "remove_multiple" || $s_action == "remove"){
if(!$this->acl_is_removeable()){
- msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
+ msg_dialog::display(_("Permission"), msgPool::permDelete(), ERROR_DIALOG);
}else{
if($s_action == "remove"){
$ids = $this->list_get_selected_items();
}
+ $this->ids_to_remove = array();
+
if(count($ids)){
$ret = $this->o_queue->ids_exist($ids);
$ret = $this->o_queue->get_entries_by_id($ret);
-
$tmp = "";
foreach($ret as $task){
/* Only remove WAITING or ERROR entries */
- if(in_array($task['STATUS'],array("waiting","error"))){
+ if(in_array($task['STATUS'],array("waiting","error","processed")) ||
+ ($task['STATUS'] == "processing" && !preg_match("/install/",$task['HEADERTAG'])) ){
$this->ids_to_remove[] = $task['ID'];
- if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']])){
- $evt = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
+ if(isset($this->events['QUEUED'][$task['HEADERTAG']])){
+ $evt_name = $this->events['QUEUED'][$task['HEADERTAG']];
+ $evt = $this->events['BY_CLASS'][$evt_name];
$tmp.= "\n".$task['ID']." - ".$evt['s_Menu_Name']." ".$task['MACADDRESS'];
}else{
$tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']." ".$task['MACADDRESS'];
}
}
$smarty->assign("multiple", TRUE);
- $smarty->assign("info",sprintf(_("You are about to remove the following actions from the GOsa support Daemon: %s"),"<pre>".$tmp."</pre>"));
+ $smarty->assign("info",msgPool::deleteInfo("<pre>".$tmp."</pre>"));
$this->current = $s_entry;
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
}
/* Remove specified tasks */
if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
+
+ /* Reboot hosts with not yet startet installations and timestamps in the past
+ */
+ timezone::get_default_timezone();
+ foreach($this->ids_to_remove as $id){
+ $entry = $this->o_queue->get_entries_by_id(array($id));
+ if(isset($entry['ANSWER1'])){
+ $entry = $entry['ANSWER1'];
+ if( $entry['STATUS'] == "waiting" &&
+ $entry['HEADERTAG'] == "trigger_action_reinstall"){
+ $evt = new DaemonEvent_reinstall($this->config,$entry);
+ if($evt->get_timestamp(FALSE) < time()){
+ $r_evt = new DaemonEvent_localboot($this->config);
+ $r_evt->add_targets(array($entry['MACADDRESS']));
+ $r_evt->set_type(TRIGGERED_EVENT);
+ $this->o_queue->append($r_evt);
+ }
+ }
+ }
+ }
+
$this->o_queue->remove_entries($this->ids_to_remove);
$this->save();
}
if(is_object($this->dialog)){
$this->dialog->save_object();
if(!$this->o_queue->append($this->dialog)){
- msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
- $this->o_queue->get_error()),ERROR_DIALOG);
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($this->o_queue->get_error()),ERROR_DIALOG);
}else{
$this->dialog = FALSE;
$this->current = -1;
$divlist->EnableSaveButton(FALSE);
$divlist->SetHeadpageMode();
$s = ".|"._("Actions")."|\n";
- $s.= "..|<img src='images/list_new.png' alt='' border='0' class='center'> "._("Create")."\n";
- foreach($this->events['BY_CLASS'] as $name => $event){
+ $s.= "..|<img src='images/lists/new.png' alt='' border='0' class='center'> "._("Create")."\n";
+
+ foreach($this->events['SCHEDULED'] as $name => $event){
$s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|add_event_".$name."\n";
}
if($this->acl_is_removeable()){
$s.= "..|---|\n";
- $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'> "._("Remove")."|remove_multiple\n";
+ $s.= "..|<img src='images/lists/import.png' alt='' border='0' class='center'> "._("Import")."|import_file\n";
+ $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'> "._("Remove")."|remove_multiple\n";
}
if(preg_match("/w/",$this->getacl(""))){
$s.= "..|---|\n";
- $s.= "..|<img src='images/status_start.png' alt='' border='0' class='center'> "._("Resume all")."|resume_all\n";
- $s.= "..|<img src='images/status_pause.png' alt='' border='0' class='center'> "._("Pause all")."|pause_all\n";
- $s.= "..|<img src='images/small_error.png' alt='' border='0' class='center'> "._("Abort all")."|abort_process_all\n";
- $s.= "..|<img src='images/rocket.png' alt='' border='0' class='center'> "._("Execute all")."|execute_process_all\n";
+ $s.= "..|<img alt='"._("Resume")."' src='images/status_start.png' border='0' class='center'> "._("Resume")."|resume_all\n";
+ $s.= "..|<img alt='"._("Pause")."' src='images/status_pause.png' border='0' class='center'> "._("Pause")."|pause_all\n";
+ $s.= "..|<img alt='"._("Abort")."' src='images/small_error.png' border='0' class='center'> "._("Abort")."|abort_process_all\n";
+ $s.= "..|<img alt='"._("Execute")."' src='images/rocket.png' border='0' class='center'> "._("Execute")."|execute_process_all\n";
}
$divlist->SetDropDownHeaderMenu($s);
if($this->sort_dir == "up"){
- $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
+ $sort_img = "<img src='images/lists/sort-up.png' alt='/\' border=0>";
}else{
- $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
+ $sort_img = "<img src='images/lists/sort-down.png' alt='\/' border=0>";
}
if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
/* Create divlist */
- $divlist->SetListHeader("<input type='image' src='images/list_reload.png' title='"._("Reload")."'>");
+ $divlist->SetListHeader("<input type='image' src='images/lists/reload.png' title='"._("Reload")."'>");
$plug = $_GET['plug'];
$chk = "<input type='checkbox' id='select_all' name='select_all'
$divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TaskID'>"._("Task").$sort_img_2."</a>",
"attach"=>"style='width:120px;'"));
$divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
- "attach"=>"style='width:100px;'"));
+ "attach"=>"style='width:140px;'"));
$divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status").$sort_img_4."</a>",
"attach"=>"style='width:80px;'"));
$divlist->AddHeader(array("string"=>_("Action"),
- "attach"=>"style='border-right:0px;width:120px;'"));
+ "attach"=>"style='border-right:0px;width:140px;'"));
/* Reload the list of entries */
$prio_actions="";
$action = "";
+
/* If WAITING add priority action
*/
if(in_array($task['STATUS'],array("waiting"))){
$prio_actions.= "<input class='center' type='image' src='images/prio_increase.png'
- title='"._("Move up in execution queue")."' name='prio_up_".$key."'> ";
+ title='"._("Move up")."' name='prio_up_".$key."'> ";
$prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png'
- title='"._("Move down in execution queue")."' name='prio_down_".$key."'> ";
+ title='"._("Move down")."' name='prio_down_".$key."'> ";
}
/* If WAITING add pause action
title='"._("Resume job")."' name='resume_".$key."'> ";
}
- /* If PROCESSING add abort action
- */
- if(in_array($task['STATUS'],array("processing"))){
- $prio_actions.= "<input class='center' type='image' src='images/small_error.png'
- title='"._("Abort execution")."' name='abort_process_".$key."'>";
- }
-
/* If PAUSED or WAITING add execution action
*/
if(in_array($task['STATUS'],array("paused","waiting"))){
$prio_actions.= "<input class='center' type='image' src='images/rocket.png'
- title='"._("Force execution now!")."' name='execute_process_".$key."'> ";
+ title='"._("Execute now")."' name='execute_process_".$key."'> ";
+ }
+
+ /* Add logview button, currently ever.
+ */
+ if(TRUE){
+ $action .= "<input type='image' src='images/fai_hook.png' name='log_view_".$key."'
+ class='center' title='"._("View logs")."' alt='"._("View logs")."'> ";
}
/* If PAUSED or WAITING add edit action
*/
if(in_array($task['STATUS'],array("waiting"))){
- $action.= "<input type='image' src='images/edit.png' name='edit_task_".$key."'
- class='center' alt='"._("Edit")."'>";
+ $action.= "<input type='image' src='images/lists/edit.png' name='edit_task_".$key."'
+ class='center' title='"._("Edit")."' alt='"._("Edit")."'>";
+ }
+
+ /* If PROCESSING add abort action
+ */
+ if(in_array($task['STATUS'],array("processing")) && preg_match("/install/",$task['HEADERTAG'])){
+ $action.= "<img src='images/empty.png' alt=''>";
+ $action.= "<input class='center' type='image' src='images/small_error.png'
+ title='"._("Abort job")."' name='abort_process_".$key."'>";
}
/* If WAITING or ERROR add remove action
*/
- if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error"))){
- $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$key."'
- class='center' alt='"._("Remove")."'>";
+ if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error","processed"))){
+ $action.= "<input type='image' src='images/lists/trash.png' name='remove_task_".$key."'
+ class='center' title='"._("Remove")."' alt='"._("Remove")."'>";
+ }
+ if(in_array($task['STATUS'],array("processing")) && !preg_match("/install/",$task['HEADERTAG'])){
+ $action.= "<input type='image' src='images/lists/trash.png' name='remove_task_".$key."'
+ class='center' title='"._("Remove")."' alt='"._("Remove")."'>";
}
+ /* Create entry display name and tooltip */
$color = "";
$display = $task['MACADDRESS'];
+ $tooltip = "";
+ if(isset($task['PLAINNAME']) && !preg_match("/none/i",$task['PLAINNAME'])){
+ $display = $task['PLAINNAME'];
+ $tooltip = " title='".$task['MACADDRESS']."' ";
+ }
$display2= $task['HEADERTAG'];
/* Check if this event exists as Daemon class
* In this case, display a more accurate entry.
*/
- if(isset($this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']]['s_Menu_Name'])){
- $event_type = $this->events['BY_QUEUED_ACTION'][$task['HEADERTAG']];
- $display2= $event_type['s_Menu_Name'];
+ if(isset($this->events['QUEUED'][$task['HEADERTAG']])){
+ $evt_name = $this->events['QUEUED'][$task['HEADERTAG']];
+ $event_type = $this->events['BY_CLASS'][$evt_name];
+ $display2 = $event_type['s_Menu_Name'];
if(strlen($display2) > 20){
$display2 = substr($display2,0,18)."...";
if($status == "error"){
$status = "<img class='center' src='images/false.png' alt=''> "._("Error");
}
+ if($status == "processed"){
+ $status = "<img class='center' src='images/true.png' alt=''> "._("Processed");
+ }
/* Special handling for all entries that have
STATUS == "processing" && PROGRESS == NUMERIC
*/
if($status == "processing" && isset($task['PROGRESS'])){
$percent = $task['PROGRESS'];
- $status = "<img src='progress.php?x=80&y=13&p=".$percent."' alt='".$percent." %'>";
- }
+ /* Show activation? */
+ if ($percent == "goto-activation"){
+ $status = "<img class='center' src='images/lists/off.png' alt=''> "._("Locked");
+
+ /* Show hardware detect? */
+ } elseif ($percent == "goto-hardware-detection") {
+ $status = "<img class='center' src='images/hardware.png' alt=''> "._("Detection");
+
+ /* Real percent */
+ } else {
+ if (preg_match('/install/', $task['HEADERTAG'])){
+ $status = "<img src='progress.php?x=80&y=13&p=".$task['PROGRESS']."' alt=''
+ id='progress_".preg_replace("/:/","_",$task['MACADDRESS'])."'>";
+ } else {
+ $status = preg_replace('/ /', ' ', _("in progress"));
+ }
+ }
+ }
/* Create each field */
$field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
"attach" => "style='width:20px;".$color."'");
$field1 = array("string" => $display,
- "attach" => "style='".$color."'");
+ "attach" => $tooltip."style='".$color."'");
$field1a= array("string" => $display2,
"attach" => "style='".$color.";width:120px;'");
- $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
+ $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:140px;'");
$field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'");
- $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
+ $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:140px;border-right:0px;'");
$divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
}
"200"=> "200",
"9999" => "*"));
- $count = $this->o_queue->number_of_queued_entries();
- $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
+ $count = $this->o_queue->number_of_queued_entries($this->event_tags);
+ if(!$count) $count = $this->range;
+ $divlist->SetListFooter(range_selector($count, $this->start, $this->range,"range"));
$smarty->assign("range",$this->range);
$smarty->assign("div",$divlist->Draw());
return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
if(class_available("DaemonEvent_faireboot")){
$tmp = new DaemonEvent_faireboot($this->config);
$tmp->add_targets($update_ids);
+ $tmp->set_type(TRIGGERED_EVENT);
+ $this->recently_removed = $update_ids;
+
if(!$this->o_queue->append($tmp)){
msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG);
return(FALSE);
}
}else{
msg_dialog::display(_("Error"),
- sprintf(_("The Job could not be aborted, the '%s' event class was not found."),
+ sprintf(_("The job could not be aborted, the required class '%s' was not found."),
"DaemonEvent_faireboot") , ERROR_DIALOG);
}
}
/* Assign entries by id.
*/
$this->entries = array();
+
foreach($entries as $entry){
+
+ /* Skip entries which will be removed within the next seconds */
+ if(isset($entry['MACADDRESS']) && in_array($entry['MACADDRESS'],$this->recently_removed)){
+ continue;
+ }
$this->entries[$entry['ID']]= $entry;
}
+ $this->recently_removed = array();
}
if(isset($_POST['range']) && is_numeric($_POST['range'])){
$this->range = $_POST['range'];
}
-
+
+ /* Save filter settings */
+ $gotomasses_filter = session::get("gotomasses_filter");
+ foreach(array("range","sort_by","sort_dir") as $attr){
+ $gotomasses_filter[$attr] = $this->$attr;
+ }
+ session::set("gotomasses_filter",$gotomasses_filter);
+
/* Page changed. */
if(isset($_GET['start'])){
$start = $_GET['start'];
}
/* Check start stop and reset if necessary */
- $count = $this->o_queue->number_of_queued_entries();
+ $count = $this->o_queue->number_of_queued_entries($this->event_tags);
if($this->start >= $count){
$this->start = $count -1;
}