cli: enhance questionnaire for bond connections (rh #1007355)
The session now looks like this: There are optional arguments for 'bond' connection type. Do you want to provide them? (yes/no) [yes] Bonding mode [balance-rr]: Bonding monitoring mode (miimon or arp) [miimon]: miimon Bonding miimon [100]: Bonding downdelay [0]: Bonding updelay [0]: ...when answered arp... Bonding arp-interval [0]: Bonding arp-ip-target [none]: https://bugzilla.redhat.com/show_bug.cgi?id=1007355
This commit is contained in:
@@ -2624,14 +2624,14 @@ static void
|
|||||||
do_questionnaire_bond (char **mode, char **miimon, char **downdelay, char **updelay,
|
do_questionnaire_bond (char **mode, char **miimon, char **downdelay, char **updelay,
|
||||||
char **arpinterval, char **arpiptarget)
|
char **arpinterval, char **arpiptarget)
|
||||||
{
|
{
|
||||||
char *answer;
|
char *answer, *monitor_mode;
|
||||||
gboolean answer_bool;
|
gboolean answer_bool;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
gboolean once_more;
|
gboolean once_more;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* Ask for optional 'bond' arguments. */
|
/* Ask for optional 'bond' arguments. */
|
||||||
printf (_("There are 6 optional arguments for 'bond' connection type.\n"));
|
printf (_("There are optional arguments for 'bond' connection type.\n"));
|
||||||
answer = nmc_get_user_input (_("Do you want to provide them? (yes/no) [yes] "));
|
answer = nmc_get_user_input (_("Do you want to provide them? (yes/no) [yes] "));
|
||||||
if (answer && (!nmc_string_to_bool (answer, &answer_bool, NULL) || !answer_bool)) {
|
if (answer && (!nmc_string_to_bool (answer, &answer_bool, NULL) || !answer_bool)) {
|
||||||
g_free (answer);
|
g_free (answer);
|
||||||
@@ -2654,56 +2654,73 @@ do_questionnaire_bond (char **mode, char **miimon, char **downdelay, char **upde
|
|||||||
}
|
}
|
||||||
} while (!mode_tmp);
|
} while (!mode_tmp);
|
||||||
}
|
}
|
||||||
if (!*miimon) {
|
|
||||||
do {
|
do {
|
||||||
*miimon = nmc_get_user_input (_("Bonding miimon [100]): "));
|
monitor_mode = nmc_get_user_input (_("Bonding monitoring mode (miimon or arp) [miimon]: "));
|
||||||
once_more = *miimon && !nmc_string_to_uint (*miimon, TRUE, 0, G_MAXUINT32, &tmp);
|
if (!monitor_mode)
|
||||||
if (once_more) {
|
monitor_mode = g_strdup ("miimon");
|
||||||
printf (_("Error: 'miimon': '%s' is not a valid number <0-%u>.\n"),
|
once_more = strcmp (monitor_mode, "miimon") && strcmp (monitor_mode, "arp");
|
||||||
*miimon, G_MAXUINT32);
|
if (once_more) {
|
||||||
g_free (*miimon);
|
printf (_("Error: '%s' is not a valid monitoring mode'; use '%s' or '%s'.\n"),
|
||||||
}
|
monitor_mode, "miimon", "arp");
|
||||||
} while (once_more);
|
g_free (monitor_mode);
|
||||||
}
|
}
|
||||||
if (!*downdelay) {
|
} while (once_more);
|
||||||
do {
|
|
||||||
*downdelay = nmc_get_user_input (_("Bonding downdelay [0]): "));
|
if (strcmp (monitor_mode, "miimon") == 0) {
|
||||||
once_more = *downdelay && !nmc_string_to_uint (*downdelay, TRUE, 0, G_MAXUINT32, &tmp);
|
if (!*miimon) {
|
||||||
if (once_more) {
|
do {
|
||||||
printf (_("Error: 'downdelay': '%s' is not a valid number <0-%u>.\n"),
|
*miimon = nmc_get_user_input (_("Bonding miimon [100]): "));
|
||||||
*downdelay, G_MAXUINT32);
|
once_more = *miimon && !nmc_string_to_uint (*miimon, TRUE, 0, G_MAXUINT32, &tmp);
|
||||||
g_free (*downdelay);
|
if (once_more) {
|
||||||
}
|
printf (_("Error: 'miimon': '%s' is not a valid number <0-%u>.\n"),
|
||||||
} while (once_more);
|
*miimon, G_MAXUINT32);
|
||||||
}
|
g_free (*miimon);
|
||||||
if (!*updelay) {
|
}
|
||||||
do {
|
} while (once_more);
|
||||||
*updelay = nmc_get_user_input (_("Bonding updelay [0]): "));
|
}
|
||||||
once_more = *updelay && !nmc_string_to_uint (*updelay, TRUE, 0, G_MAXUINT32, &tmp);
|
if (!*downdelay) {
|
||||||
if (once_more) {
|
do {
|
||||||
printf (_("Error: 'updelay': '%s' is not a valid number <0-%u>.\n"),
|
*downdelay = nmc_get_user_input (_("Bonding downdelay [0]): "));
|
||||||
*updelay, G_MAXUINT32);
|
once_more = *downdelay && !nmc_string_to_uint (*downdelay, TRUE, 0, G_MAXUINT32, &tmp);
|
||||||
g_free (*updelay);
|
if (once_more) {
|
||||||
}
|
printf (_("Error: 'downdelay': '%s' is not a valid number <0-%u>.\n"),
|
||||||
} while (once_more);
|
*downdelay, G_MAXUINT32);
|
||||||
}
|
g_free (*downdelay);
|
||||||
if (!*arpinterval) {
|
}
|
||||||
do {
|
} while (once_more);
|
||||||
*arpinterval = nmc_get_user_input (_("Bonding arp-interval [0]): "));
|
}
|
||||||
once_more = *arpinterval && !nmc_string_to_uint (*arpinterval, TRUE, 0, G_MAXUINT32, &tmp);
|
if (!*updelay) {
|
||||||
if (once_more) {
|
do {
|
||||||
printf (_("Error: 'arp-interval': '%s' is not a valid number <0-%u>.\n"),
|
*updelay = nmc_get_user_input (_("Bonding updelay [0]): "));
|
||||||
*arpinterval, G_MAXUINT32);
|
once_more = *updelay && !nmc_string_to_uint (*updelay, TRUE, 0, G_MAXUINT32, &tmp);
|
||||||
g_free (*arpinterval);
|
if (once_more) {
|
||||||
}
|
printf (_("Error: 'updelay': '%s' is not a valid number <0-%u>.\n"),
|
||||||
} while (once_more);
|
*updelay, G_MAXUINT32);
|
||||||
}
|
g_free (*updelay);
|
||||||
if (!*arpiptarget) {
|
}
|
||||||
//FIXME: verify the string
|
} while (once_more);
|
||||||
*arpiptarget = nmc_get_user_input (_("Bonding arp-ip-target [none]): "));
|
}
|
||||||
|
} else {
|
||||||
|
if (!*arpinterval) {
|
||||||
|
do {
|
||||||
|
*arpinterval = nmc_get_user_input (_("Bonding arp-interval [0]): "));
|
||||||
|
once_more = *arpinterval && !nmc_string_to_uint (*arpinterval, TRUE, 0, G_MAXUINT32, &tmp);
|
||||||
|
if (once_more) {
|
||||||
|
printf (_("Error: 'arp-interval': '%s' is not a valid number <0-%u>.\n"),
|
||||||
|
*arpinterval, G_MAXUINT32);
|
||||||
|
g_free (*arpinterval);
|
||||||
|
}
|
||||||
|
} while (once_more);
|
||||||
|
}
|
||||||
|
if (!*arpiptarget) {
|
||||||
|
//FIXME: verify the string
|
||||||
|
*arpiptarget = nmc_get_user_input (_("Bonding arp-ip-target [none]): "));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (answer);
|
g_free (answer);
|
||||||
|
g_free (monitor_mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user