Example #1
0
function get_vps_swap_list($vps)
{
    global $db;
    if ($_SESSION["is_admin"]) {
        return get_user_vps_list(array($vps->veid));
    }
    $sql = "SELECT vps_id, vps_hostname FROM vps v\n\t        INNER JOIN servers s ON v.vps_server = s.server_id\n\t\t    INNER JOIN locations l ON s.server_location = l.location_id\n\t\t    WHERE\n\t\t      m_id = " . $db->check($_SESSION["member"]["m_id"]) . "\n\t\t      AND\n\t\t      v.vps_deleted IS NULL\n\t\t      AND\n\t\t      s.server_maintenance = 0\n\t\t      AND\n\t\t      l.location_type = '" . ($vps->is_playground() ? 'production' : 'playground') . "'";
    $rs = $db->query($sql);
    $ret = array();
    while ($row = $db->fetch_array($rs)) {
        $ret[$row["vps_id"]] = "#" . $row["vps_id"] . " " . $row["vps_hostname"];
    }
    return $ret;
}
Example #2
0
function mount_edit_form($target, $m, $default = false)
{
    global $STORAGE_MOUNT_MODES_RO_RW, $STORAGE_MOUNT_TYPES, $xtpl;
    $e_list = get_nas_export_list($default);
    $nodes = list_servers();
    $empty = array("" => "---");
    $xtpl->table_title(_("Edit mount") . " " . $m["dst"]);
    $xtpl->form_create($target . '&id=' . $_GET["id"], 'post');
    $xtpl->form_add_select(_("Export") . ':', 'export_id', $empty + $e_list, $_POST["export_id"] ? $_POST["export_id"] : (int) $m["storage_export_id"]);
    $xtpl->form_add_select(_("VPS") . ':', 'vps_id', get_user_vps_list(), $_POST["vps_id"] ? $_POST["vps_id"] : $m["vps_id"]);
    $xtpl->form_add_select(_("Access mode") . ':', 'access_mode', $STORAGE_MOUNT_MODES_RO_RW, $_POST["mode"] ? $_POST["mode"] : $m["mode"]);
    if ($_SESSION["is_admin"]) {
        $xtpl->form_add_select(_("Source node") . ':', 'source_node_id', $empty + $nodes, $_POST["source_node_id"] ? $_POST["source_node_id"] : $m["server_id"], _("Has no effect if export is selected."));
        $xtpl->form_add_input(_("Source") . ':', 'text', '50', 'src', $_POST["src"] ? $_POST["src"] : $m["src"], _("Path is relative to source node root if specified, otherwise absolute. Has no effect if export is selected."));
    }
    $xtpl->form_add_input(_("Destination") . ':', 'text', '50', 'dst', $_POST["dst"] ? $_POST["dst"] : $m["dst"], _("Path is relative to VPS root,<br>allowed chars: a-Z A-Z 0-9 _ - . /"));
    if ($_SESSION["is_admin"]) {
        $xtpl->form_add_input(_("Mount options") . ':', 'text', '50', 'm_opts', $_POST["m_opts"] ? $_POST["m_opts"] : $m["mount_opts"], '');
        $xtpl->form_add_input(_("Umount options") . ':', 'text', '50', 'u_opts', $_POST["u_opts"] ? $_POST["u_opts"] : $m["umount_opts"], '');
        $xtpl->form_add_select(_("Type") . ':', 'type', $STORAGE_MOUNT_TYPES, $_POST["type"] ? $_POST["type"] : $m["mount_type"]);
    }
    $xtpl->form_add_input(_("Pre-mount command") . ':', 'text', '50', 'cmd_premount', $_POST["cmd_premount"] ? $_POST["cmd_premount"] : $m["cmd_premount"], _("Command that is executed within VPS context <strong>before</strong> mount"));
    $xtpl->form_add_input(_("Post-mount command") . ':', 'text', '50', 'cmd_postmount', $_POST["cmd_postmount"] ? $_POST["cmd_postmount"] : $m["cmd_postmount"], _("Command that is executed within VPS context <strong>after</strong> mount"));
    $xtpl->form_add_input(_("Pre-umount command") . ':', 'text', '50', 'cmd_preumount', $_POST["cmd_preumount"] ? $_POST["cmd_preumount"] : $m["cmd_preumount"], _("Command that is executed within VPS context <strong>before</strong> umount"));
    $xtpl->form_add_input(_("Post-umount command") . ':', 'text', '50', 'cmd_postumount', $_POST["cmd_postumount"] ? $_POST["cmd_postumount"] : $m["cmd_postumount"], _("Command that is executed within VPS context <strong>after</strong> umount"));
    $xtpl->form_add_checkbox(_("Remount on save") . ':', 'remount_immediately', '1', $_POST["type"] ? $_POST["remount_immediately"] : true, "<strong>" . _("Recommended") . "</strong>");
    $xtpl->form_out(_("Save"));
}