At Thu, 17 Jul 2014 10:31:59 +0800, Ruoyu wrote: > > Once a directory is plugged into the node, all data in it will be > removed. Therefore, it is better to print a warning message to > user first for fear that he or she specifies a wrong path. > > Unplugging also needs a confirmation before the execution because > recovery will impact the guest OS. > > For admin's scripts, the option -f (--force) is introduced to avoid > the confirmation. > > Test case 057, 063, 064 are also updated. > > Signed-off-by: Ruoyu <lian...@ucweb.com> > --- > dog/node.c | 27 ++++++++++++++++++++++++++- > tests/functional/057 | 8 ++++---- > tests/functional/063 | 2 +- > tests/functional/064 | 2 +- > 4 files changed, 32 insertions(+), 7 deletions(-)
Applied, thanks. Hitoshi > > diff --git a/dog/node.c b/dog/node.c > index 83ff541..e24cc38 100644 > --- a/dog/node.c > +++ b/dog/node.c > @@ -16,6 +16,7 @@ static struct node_cmd_data { > bool recovery_progress; > bool watch; > bool local; > + bool force; > } node_cmd_data; > > static void cal_total_vdi_size(uint32_t vid, const char *name, const char > *tag, > @@ -468,13 +469,33 @@ static int do_plug_unplug(char *disks, bool plug) > return EXIT_SUCCESS; > } > > +#define MD_PLUG_PRINT \ > + " __\n" \ > + " ()'`;\n" \ > + " /\\|`\n" \ > + " / | Caution! The directories to be plugged will be purged.\n" \ > + "(/_)_|_ Are you sure you want to continue? [yes/no]: " > + > static int md_plug(int argc, char **argv) > { > + if (!node_cmd_data.force) > + confirm(MD_PLUG_PRINT); > + > return do_plug_unplug(argv[optind], true); > } > > +#define MD_UNPLUG_PRINT \ > + " __\n" \ > + " ()'`;\n" \ > + " /\\|`\n" \ > + " / | Caution! Recovery will be triggered after unplugging.\n" \ > + "(/_)_|_ Are you sure you want to continue? [yes/no]: " > + > static int md_unplug(int argc, char **argv) > { > + if (!node_cmd_data.force) > + confirm(MD_UNPLUG_PRINT); > + > return do_plug_unplug(argv[optind], false); > } > > @@ -508,6 +529,9 @@ static int node_parser(int ch, const char *opt) > case 'l': > node_cmd_data.local = true; > break; > + case 'f': > + node_cmd_data.force = true; > + break; > } > > return 0; > @@ -518,6 +542,7 @@ static struct sd_option node_options[] = { > {'P', "progress", false, "show progress of recovery in the node"}, > {'w', "watch", false, "watch the stat every second"}, > {'l', "local", false, "issue request to local node"}, > + {'f', "force", false, "ignore the confirmation"}, > { 0, NULL, false, NULL }, > }; > > @@ -617,7 +642,7 @@ static struct subcommand node_cmd[] = { > CMD_NEED_NODELIST, node_info}, > {"recovery", NULL, "aphPrt", "show recovery information of nodes", NULL, > CMD_NEED_NODELIST, node_recovery, node_options}, > - {"md", "[disks]", "aprAht", "See 'dog node md' for more information", > + {"md", "[disks]", "aprAfht", "See 'dog node md' for more information", > node_md_cmd, CMD_NEED_ARG, node_md, node_options}, > {"stat", NULL, "aprwht", "show stat information about the node", NULL, > 0, node_stat, node_options}, > diff --git a/tests/functional/057 b/tests/functional/057 > index 8cb9f25..0974297 100755 > --- a/tests/functional/057 > +++ b/tests/functional/057 > @@ -27,26 +27,26 @@ _md_info > # plug during node event > _start_sheep 3 > _wait_for_sheep 4 > -$DOG node md plug $STORE/0/d3,$STORE/0/d4 > +$DOG node md plug -f $STORE/0/d3,$STORE/0/d4 > _wait_for_sheep_recovery 0 > _md_info > $DOG vdi check test > $DOG cluster info | _filter_cluster_info > > # plug duplicate path > -$DOG node md plug $STORE/0/d3 > +$DOG node md plug -f $STORE/0/d3 > $DOG node recovery > _md_info > > # unplug > -$DOG node md unplug $STORE/0/d0,$STORE/0/d1 > +$DOG node md unplug -f $STORE/0/d0,$STORE/0/d1 > _wait_for_sheep_recovery 0 > _md_info > $DOG vdi check test > $DOG cluster info | _filter_cluster_info > > # unplug invalid path > -$DOG node md unplug $STORE/0/d0 > +$DOG node md unplug -f $STORE/0/d0 > $DOG node recovery > _md_info > $DOG cluster info | _filter_cluster_info > diff --git a/tests/functional/063 b/tests/functional/063 > index cd5a855..eb56924 100755 > --- a/tests/functional/063 > +++ b/tests/functional/063 > @@ -24,7 +24,7 @@ $DOG vdi create test 200M -P > _node_info > $DOG node list > > -$DOG node md plug $STORE/4 > +$DOG node md plug -f $STORE/4 > _wait_for_sheep_recovery 0 > > $DOG cluster reweight > diff --git a/tests/functional/064 b/tests/functional/064 > index 3a6f168..88b80d4 100755 > --- a/tests/functional/064 > +++ b/tests/functional/064 > @@ -21,7 +21,7 @@ $DOG vdi create test 100M -P > _node_info > $DOG node list > > -$DOG node md plug $STORE/3 > +$DOG node md plug -f $STORE/3 > _wait_for_sheep_recovery 0 > _node_info > $DOG node list > -- > 1.8.3.2 > > > -- > sheepdog mailing list > sheepdog@lists.wpkg.org > http://lists.wpkg.org/mailman/listinfo/sheepdog -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog