Example #1
0
$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;
        }
    }
}
$params['issue_halt_to'] = $halt_to;
$mode = web_def_mode();
$prefix = '';
if (strlen($gid)) {
    $prefix = 'group';
}
$cible = array($uuid);
// TODO: activate this  : msc_command_set_pause($cmd_id);
$id_command = add_command_api($pid, $cible, $params, $p_api, $mode, $gid);
if (!isXMLRPCError()) {
    scheduler_start_these_commands('', array($id_command));
    header("Location: " . urlStrRedirect("msc/logs/viewLogs", array('tab' => $prefix . $tab, 'uuid' => $uuid, 'hostname' => $hostname, 'gid' => $gid, 'cmd_id' => $id_command)));
    exit;
} else {
    ## Return to the launch tab, the backtrace will be displayed
    header("Location: " . urlStrRedirect("msc/logs/viewLogs", array('tab' => $prefix . 'tablaunch', 'uuid' => $uuid, 'hostname' => $hostname, 'gid' => $gid, 'cmd_id' => $id_command)));
    exit;
Example #2
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" => ''));
     }
 }
Example #3
0
         $f->add(new TrFormElement(_T('Convergence is active', 'msc'), new CheckboxTpl('active')), array("value" => quick_get('active') == 'on' ? 'checked' : ''));
         $f->add(new HiddenTpl('start_date'), array("value" => $start_date, "hide" => True));
         $f->add(new HiddenTpl('end_date'), array("value" => $end_date, "hide" => True));
     } else {
         $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));
     }
     if (quick_get('editConvergence')) {
         $f->add(new HiddenTpl('editConvergence'), array("value" => quick_get('editConvergence'), "hide" => True));
     }
     $deployment_fields = array(new InputTpl('deployment_intervals'), new TextTpl(sprintf('<i style="color: #999999">%s</i>', _T('Example for lunch and night (24h format): 12-14,20-8', 'msc'))));
     $deployment_values = array("value" => array(quick_get('deployment_intervals'), ''));
     $f->add(new TrFormElement(_T('Deployment interval', 'msc'), new multifieldTpl($deployment_fields)), $deployment_values);
     $f->add(new TrFormElement(_T('Max bandwidth (kbits/s)', 'msc'), new NumericInputTpl('maxbw')), array("value" => $max_bw, "required" => 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($_GET['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" => ''));
     }
 }
 $f->pop();
 $f->addValidateButton("bconfirm");
 $f->addCancelButton("bback");
Example #4
0
$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["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';
}
$prefix = '';
if (strlen($_POST["gid"])) {
    $prefix = 'group';
}
$params['tab'] = $prefix . 'tablaunch';
$params['badvanced'] = True;
header("Location: " . urlStrRedirect("{$module}/{$submod}/{$page}", $params));
exit;
?>
Example #5
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;
        }
    }
}