summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2010-10-06 15:36:30 -0400
committerDavid Zeuthen <davidz@redhat.com>2010-10-06 15:36:30 -0400
commit4e1ada172b3c469f0c441e5c63a2d5c7f207add5 (patch)
tree1a64ac64e539af2f03cc437b3096c4e3421ed769
parent24bb73bb6c7d7ed7a2fcf6bf3f5e62f08c04641d (diff)
Add --allow-degraded option to stc(1)'s start verb
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--stc/stc.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/stc/stc.c b/stc/stc.c
index a463a2a..acc2aaa 100644
--- a/stc/stc.c
+++ b/stc/stc.c
@@ -544,6 +544,11 @@ ask_user (const gchar *info,
return ret;
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gchar *opt_start_stop_id = NULL;
+static gboolean opt_start_allow_degraded = FALSE;
+
static gboolean
on_may_start_degraded (StcOperation *operation,
StcItem *item,
@@ -558,6 +563,12 @@ on_may_start_degraded (StcOperation *operation,
ret = FALSE;
+ if (opt_start_allow_degraded)
+ {
+ ret = TRUE;
+ goto out;
+ }
+
slave_devices = stc_item_get_slave_devices (item);
g_assert (slave_devices != NULL);
num_slave_devices = g_strv_length ((gchar **) slave_devices);
@@ -597,6 +608,8 @@ on_may_start_degraded (StcOperation *operation,
g_string_free (str, TRUE);
+ out:
+
return ret;
}
@@ -648,10 +661,14 @@ on_request_passphrase (StcOperation *operation,
}
+static const GOptionEntry command_start_entries[] =
+{
+ { "id", 'i', 0, G_OPTION_ARG_STRING, &opt_start_stop_id, "Configuration item", NULL},
+ { "allow-degraded", 'd', 0, G_OPTION_ARG_NONE, &opt_start_allow_degraded, "Answer yes to whether it's OK to start degraded", NULL},
+ { NULL }
+};
-static gchar *opt_start_stop_id = NULL;
-
-static const GOptionEntry command_start_stop_entries[] =
+static const GOptionEntry command_stop_entries[] =
{
{ "id", 'i', 0, G_OPTION_ARG_STRING, &opt_start_stop_id, "Configuration item", NULL},
{ NULL }
@@ -689,7 +706,9 @@ handle_command_start_stop (gint *argc,
g_option_context_set_ignore_unknown_options (o, TRUE);
g_option_context_set_help_enabled (o, FALSE);
g_option_context_set_summary (o, is_start ? "Start configuration item." : "Stop configuration item");
- g_option_context_add_main_entries (o, command_start_stop_entries, NULL /* GETTEXT_PACKAGE*/);
+ g_option_context_add_main_entries (o,
+ is_start ? command_start_entries : command_stop_entries,
+ NULL /* GETTEXT_PACKAGE*/);
complete_ids = FALSE;
if (request_completion && (g_strcmp0 (completion_prev, "--id") == 0 || g_strcmp0 (completion_prev, "-i") == 0))
@@ -715,6 +734,12 @@ handle_command_start_stop (gint *argc,
g_print ("--id \n");
}
+ if (request_completion &&
+ (!opt_start_allow_degraded && !complete_ids))
+ {
+ g_print ("--allow-degraded \n");
+ }
+
monitor = stc_monitor_new (error_handler, NULL);
if (complete_ids)