Beispiel #1
0
$params["name"] = $hostname;
$params["hostname"] = $hostname;
$params["uuid"] = $uuid;
$params["gid"] = $gid;
$params["from"] = $from;
$params["pid"] = $pid;
$params["ltitle"] = get_def_package_label($name, $version);
$params["create_directory"] = 'on';
$params["start_script"] = 'on';
$params["clean_on_success"] = 'on';
$params["do_reboot"] = getPackageHasToReboot($p_api, $_GET["pid"]) == 1 ? 'on' : '';
$params["do_wol"] = web_def_awake() == 1 ? 'on' : '';
$params["do_inventory"] = web_def_inventory() == 1 ? 'on' : '';
$params["next_connection_delay"] = web_def_delay();
$params["max_connection_attempt"] = web_def_attempts();
$params["maxbw"] = web_def_maxbw();
$params["deployment_intervals"] = web_def_deployment_intervals();
$prefix = '';
if (strlen($_POST["gid"])) {
    $prefix = 'group';
}
$params['tab'] = $prefix . 'tablaunch';
$halt_to = array();
foreach ($_POST as $p => $v) {
    if (preg_match('/^issue_halt_to_/', $p)) {
        $p = preg_replace('/^issue_halt_to_/', '', $p);
        if ($v == 'on') {
            $halt_to[] = $p;
        }
    }
}
Beispiel #2
0
         $f->add(new HiddenTpl("gid"), array("value" => $gid, "hide" => True));
     }
 }
 $label->display();
 $f->add(new HiddenTpl("pid"), array("value" => $pid, "hide" => True));
 $f->add(new HiddenTpl("papi"), array("value" => quick_get("papi"), "hide" => True));
 $f->add(new HiddenTpl("from"), array("value" => $from, "hide" => True));
 $action = quick_get('launchAction');
 if (isset($action) && $action != '') {
     $f->add(new HiddenTpl('launchAction'), array("value" => quick_get('launchAction'), "hide" => True));
 }
 $start_script = quick_get('start_script', True);
 $clean_on_success = quick_get('clean_on_success', True);
 $max_bw = quick_get('maxbw');
 if (!isset($max_bw) || $max_bw == '') {
     $max_bw = web_def_maxbw();
 }
 // $start_date is now()
 $start_date = quick_get('start_date') ? quick_get('start_date') : date("Y-m-d H:i:s");
 // $end_date = now() + 1h by default (set in web_def_coh_life_time msc ini value)
 // $coh_life_time is set to 24h for convergence commands
 $coh_life_time = quick_get('convergence') ? 24 : web_def_coh_life_time();
 $end_date = quick_get('end_date') ? quick_get('end_date') : date("Y-m-d H:i:s", time() + $coh_life_time * 60 * 60);
 if (quick_get('launchAction')) {
     // Advanced Quick Action
     $f->add(new TrFormElement(_T('The command must start after', 'msc'), new DateTimeTpl('start_date')), array("value" => $start_date, "ask_for_now" => 0));
     $f->add(new TrFormElement(_T('The command must stop before', 'msc'), new DateTimeTpl('end_date')), array("value" => $end_date, "ask_for_never" => 0));
     $f->add(new HiddenTpl('ltitle'), array("value" => $name, "hide" => True));
     $f->add(new HiddenTpl('parameters'), array("value" => quick_get('parameters'), "hide" => True));
     $f->add(new HiddenTpl('do_wol'), array("value" => quick_get('do_wol', True) == 'on' ? 'checked' : '', "hide" => True));
     $f->add(new HiddenTpl('start_script'), array("value" => $start_script == 'on' ? 'checked' : '', "hide" => True));
Beispiel #3
0
 function display_options($f)
 {
     // $start_date is now()
     $start_date = date("Y-m-d H:i:s");
     // $end_date = now() + 24h by default (set in web_def_coh_life_time msc ini value)
     $end_date = date("Y-m-d H:i:s", time() + web_def_coh_life_time() * 60 * 60);
     $f->add(new HiddenTpl("lmembers"), array("value" => base64_encode(serialize($this->members)), "hide" => True));
     $f->add(new TrFormElement(_T('Bundle title', 'msc'), new InputTpl('bundle_title')), array("value" => $_POST['bundle_title']));
     $f->add(new TrFormElement(_T('Wake on lan', 'msc'), new CheckboxTpl("do_wol")), array("value" => $_POST['do_wol'] == 'on' ? 'checked' : ''));
     $f->add(new TrFormElement(_T('Start the script', 'msc'), new CheckboxTpl("start_script")), array("value" => 'checked'));
     $f->add(new TrFormElement(_T('Delete files after a successful execution', 'msc'), new CheckboxTpl("clean_on_success")), array("value" => 'checked'));
     $f->add(new TrFormElement(_T('Start inventory', 'msc'), new CheckboxTpl("do_inventory")), array("value" => $_POST['do_inventory'] == 'on' ? 'checked' : ''));
     $f->add(new TrFormElement(_T('Halt client after', 'msc'), new CheckboxTpl("issue_halt_to_done")), array("value" => $_POST['issue_halt_to_done'] == 'on' ? 'checked' : ''));
     /*$f->add(new TrFormElement('',                                                       new CheckboxTpl("issue_halt_to_failed", _T("failed", "msc"))), array("value" => $_POST['issue_halt_to_failed'] == 'on' ? 'checked' : ''));
       $f->add(new TrFormElement('',                                                       new CheckboxTpl("issue_halt_to_over_time", _T("over time", "msc"))), array("value" => $_POST['issue_halt_to_over_time'] == 'on' ? 'checked' : ''));
       $f->add(new TrFormElement('',                                                       new CheckboxTpl("issue_halt_to_out_of_interval", _T("out of interval", "msc"))), array("value" => $_POST['issue_halt_to_out_of_interval'] == 'on' ? 'checked' : ''));*/
     $f->add(new TrFormElement(_T('Command parameters', 'msc'), new InputTpl('parameters')), array("value" => ''));
     $f->add(new TrFormElement(_T('Beginning of validity', 'msc'), new DateTimeTpl('start_date')), array('value' => $start_date, 'ask_for_now' => 0));
     $f->add(new TrFormElement(_T('End of validity', 'msc'), new DateTimeTpl('end_date')), array('value' => $end_date, 'ask_for_never' => 0));
     $f->add(new TrFormElement(_T('Deployment interval', 'msc'), new InputTpl('deployment_intervals')), array("value" => $_POST['deployment_intervals']));
     $f->add(new TrFormElement(_T('Max bandwidth (kbits/s)', 'msc'), new NumericInputTpl('maxbw')), array("value" => web_def_maxbw()));
     $f->add(new HiddenTpl("create_directory"), array("value" => 'on', "hide" => True));
     if (web_force_mode()) {
         $f->add(new HiddenTpl("copy_mode"), array("value" => web_def_mode(), "hide" => True));
     } else {
         $rb = new RadioTpl("copy_mode");
         $rb->setChoices(array(_T('push', 'msc'), _T('push / pull', 'msc')));
         $rb->setvalues(array('push', 'push_pull'));
         $rb->setSelected($_POST['copy_mode']);
         $f->add(new TrFormElement(_T('Copy Mode', 'msc'), $rb));
     }
     /* Only display local proxy button on a group and if allowed */
     if (isset($_GET['gid']) && strlen($_GET['gid']) && web_allow_local_proxy()) {
         $f->add(new TrFormElement(_T('Deploy using a local proxy', 'msc'), new CheckboxTpl("local_proxy")), array("value" => ''));
     }
 }
Beispiel #4
0
function action($action, $target, $is_advanced) {
    $from = $_GET['from'];
    $path =  explode('|', $from);
    $module = $path[0];
    $submod = $path[1];
    $page = $path[2];
    $tab = $path[3];

    /* Handle posting of quick actions */
    if ($_SESSION["lang"] == "C") {
        $current_lang = "";
    } else {
        $current_lang = substr($_SESSION["lang"], 0, 2);
    }
    if (count($_GET["gid"]) > 0) {
        $type = 'group';
    } else {
        $type = '';
    }

    if ($is_advanced) {
        $params = array('from'=> 'base|computers|msctabs|tablaunch');
        foreach (array('gid', 'uuid', 'hostname') as $param) {
            $params[$param] = $_GET[$param];
        }

        $qa = msc_script_detailled_info($action);
        if ($qa[0]) {
            $qa = $qa[1];

            $params['badvanced'] = True;
            if (isset($qa['title'.$current_lang])) {
                $params['ltitle'] = trim('[QA] '.$qa['title'.$current_lang]);
            } else {
                $params['ltitle'] = trim('[QA] '.$qa['title']);
            }

            if ($action == '007wake_on_lan.msc') {
                # this is a very special case for WOL, it's not a command as we usualy understand it...
                $params['failure'] = '1';
                $params['create_directory'] = 'off';
                $params['start_script'] = 'off';
                $params['clean_on_success'] = 'off';
                $params['do_reboot'] = 'off';
                $params['do_wol'] = 'on';
                $params['do_inventory'] = 'off';
                $params['issue_halt'] = 'off';
                $params['next_connection_delay'] = 0;
                $params['max_connection_attempt'] = 1;
                $params['attempts_left'] = 1;
                foreach (array('create_directory', 'start_script', 'clean_on_success', 'do_reboot', 'do_wol', 'next_connection_delay', 'max_connection_attempt', 'do_inventory', 'copy_mode', 'deployment_intervals', 'issue_halt', 'parameters', 'local_proxy', 'maxbw') as $p) {
                     $params['hide_'.$p] = True;
                }
            } else {
                $params['do_reboot'] = '';
                $params["next_connection_delay"]  = web_def_delay();
                $params["max_connection_attempt"] = web_def_attempts();
                $params["maxbw"]                  = web_def_maxbw();
                $params["copy_mode"]              = web_def_mode();
                $params["deployment_intervals"]   = web_def_deployment_intervals();
                $halt = web_def_issue_halt_to();
                foreach ($halt as $h) {
                    $params["issue_halt_to_".$h] = 'on';
                }
            }
            $params['launchAction'] = $action;

            header("Location: ".urlStrRedirect("base/computers/".$type."msctabs", $params));
            exit;
        } else {
            new NotifyWidgetFailure(_T('Failed to retrieve this quick action.', 'msc'));
        }
    } else {
        $id = add_command_quick_with_id($action, $target, $current_lang, $_GET["gid"]);
        if ($id != -1) {
            scheduler_start_these_commands("", array($id));
            // if on a single computer
            if (count($_GET["gid"]) > 0) {
                $actionpage = 'groupmsctabs';
                $tab = 'grouptablogs';
            } else {
                $actionpage = 'msctabs';
                $tab = 'tablogs';
            }
            header("Location: ".urlStrRedirect("base/computers/$actionpage", array('tab'=>$tab, 'uuid'=>$_GET['uuid'], 'hostname'=>$_GET['hostname'], 'cmd_id'=>$id, 'gid'=>$_GET['gid'])));
            exit;
        }
    }
}