Пример #1
0
function gmirror_activate_consumer($mirror, $consumer)
{
    if (!is_valid_mirror($mirror) || !is_valid_consumer($consumer)) {
        return false;
    }
    return mwexec("/sbin/gmirror activate " . escapeshellarg($mirror) . " " . escapeshellarg($consumer));
}
Пример #2
0
$action_list = array("forget" => gettext("Forget all formerly connected consumers"), "clear" => gettext("Remove metadata from disk"), "insert" => gettext("Insert consumer into mirror"), "remove" => gettext("Remove consumer from mirror"), "activate" => gettext("Reactivate consumer on mirror"), "deactivate" => gettext("Deactivate consumer from mirror"), "rebuild" => gettext("Force rebuild of mirror consumer"));
/* User tried to pass a bogus action */
if (!empty($_REQUEST['action']) && !array_key_exists($_REQUEST['action'], $action_list)) {
    header("Location: diag_gmirror.php");
    return;
}
if ($_POST) {
    if (!isset($_POST['confirm']) || $_POST['confirm'] != gettext("Confirm")) {
        header("Location: diag_gmirror.php");
        return;
    }
    $input_errors = "";
    if ($_POST['action'] != "clear" && !is_valid_mirror($_POST['mirror'])) {
        $input_errors[] = gettext("You must supply a valid mirror name.");
    }
    if (!empty($_POST['consumer']) && !is_valid_consumer($_POST['consumer'])) {
        $input_errors[] = gettext("You must supply a valid consumer name");
    }
    /* Additional action-specific validation that hasn't already been tested */
    switch ($_POST['action']) {
        case "insert":
            if (!is_consumer_unused($_POST['consumer'])) {
                $input_errors[] = gettext("Consumer is already in use and cannot be inserted. Remove consumer from existing mirror first.");
            }
            if (gmirror_consumer_has_metadata($_POST['consumer'])) {
                $input_errors[] = gettext("Consumer has metadata from an existing mirror. Clear metadata before inserting consumer.");
            }
            $mstat = gmirror_get_status_single($_POST['mirror']);
            if (strtoupper($mstat) != "COMPLETE") {
                $input_errors[] = gettext("Mirror is not in a COMPLETE state, cannot insert consumer. Forget disconnected disks or wait for rebuild to finish.");
            }