Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
Fix issue #16 : Add an option to ask resuming migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Joacchim committed May 18, 2011
1 parent 025324d commit df98180
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions inc/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ enum cloudmig_flags
SRC_PROFILE_NAME = 1 << 0,
DEST_PROFILE_NAME = 1 << 1,
IGNORE_STATUS = 1 << 2,
DEBUG = 1 << 3,
QUIET = 1 << 4,
DELETE_SOURCE_DATA = 1 << 5,
RESUME_MIGRATION = 1 << 3,
DEBUG = 1 << 4,
QUIET = 1 << 5,
DELETE_SOURCE_DATA = 1 << 6,
};

struct cloudmig_options
Expand Down
7 changes: 5 additions & 2 deletions src/cldmig/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int retrieve_opts(int argc, char* argv[])
// {"config", required_argument, 0, 'c'},
/* Status-related options */
// {"ignore-status", no_argument, 0, 'i'},
// {"force-resume", no_argument, 0, 'r'},
{"force-resume", no_argument, 0, 'r'},
/* Behavior-related options */
{"delete-source", no_argument, 0, 0},
/* Verbose/Log-related options */
Expand All @@ -92,7 +92,7 @@ int retrieve_opts(int argc, char* argv[])
};

while ((cur_opt = getopt_long(argc, argv,
"-s:d:v",
"-s:d:vr",
long_options, &option_index)) != -1)
{
switch (cur_opt)
Expand Down Expand Up @@ -147,6 +147,9 @@ int retrieve_opts(int argc, char* argv[])
}
gl_options->dest_profile = optarg;
break ;
case 'r':
gl_options->flags |= RESUME_MIGRATION;
break ;
/*
case 'i':
gl_options->flags |= IGNORE_STATUS;
Expand Down
14 changes: 13 additions & 1 deletion src/cldmig/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <unistd.h>

#include "cloudmig.h"
#include "options.h"

/*
*
Expand Down Expand Up @@ -149,8 +150,19 @@ int load_status(struct cloudmig_ctx* ctx)
* create the buckets states in order to be able
* to follow the states evolutions.
*/
if (status_retrieve_states(ctx))
if (resuming == 0
|| gl_options->flags & RESUME_MIGRATION)
{
if (status_retrieve_states(ctx))
goto err;
}
else
{
cloudmig_log(ERR_LVL, "[Loading Status]: Could not create status:"
"Ongoing migration for this configuration.\n"
"Please use --force-resume option\n");
goto err;
}

cloudmig_log(INFO_LVL, "[Loading Status]: Status loading"
" done with success.\n");
Expand Down

0 comments on commit df98180

Please sign in to comment.