]> git.sur5r.net Git - bacula/bacula/commitdiff
Add code for starting multiple migrations
authorKern Sibbald <kern@sibbald.com>
Sun, 23 Apr 2006 15:15:05 +0000 (15:15 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 23 Apr 2006 15:15:05 +0000 (15:15 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2961 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/dird/migrate.c

index b74009a813736123f21c72129917a9916a7cbe55..cfa76f1b9acf9ef38a113cc09c7ea50ab11b214e 100644 (file)
@@ -88,6 +88,8 @@ minutes).
 
 [ possibly a Python event -- kes ]
 ===
+- run_cmd() returns int should return JobId_t
+- get_next_jobid_from_list() returns int should return JobId_t
 - Document export LDFLAGS=-L/usr/lib64
 - Don't attempt to restore from "Disabled" Volumes.
 - Network error on Win32 should set Win32 error code.
index 9e79a51c6e53416f4135e7e430309a35c6f66068..7657c8cd27f19fbe7ea65f504631753b32fe131b 100644 (file)
@@ -43,6 +43,7 @@ static bool get_job_to_migrate(JCR *jcr);
 struct idpkt;
 static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1,
                  const char *query2, const char *type);
+static void start_migration_job(JCR *jcr);
 
 /* 
  * Called here before the job is run to do the job
@@ -449,8 +450,9 @@ static bool get_job_to_migrate(JCR *jcr)
    ids.count = 0;
 
    if (jcr->MigrateJobId != 0) {
-      jcr->previous_jr.JobId = jcr->MigrateJobId;
       Dmsg1(000, "previous jobid=%u\n", jcr->MigrateJobId);
+      edit_uint64(jcr->MigrateJobId, ids.list);
+      ids.count = 1;
    } else {
       switch (jcr->job->selection_type) {
       case MT_JOB:
@@ -513,6 +515,8 @@ static bool get_job_to_migrate(JCR *jcr)
    JobId = 0;
    stat = get_next_jobid_from_list(&p, &JobId);
    Dmsg2(000, "get_next_jobid stat=%d JobId=%u\n", stat, JobId);
+   jcr->MigrateJobId = JobId;
+   start_migration_job(jcr);
    if (stat < 0) {
       Jmsg(jcr, M_FATAL, 0, _("Invalid JobId found.\n"));
       goto bail_out;
@@ -522,7 +526,7 @@ static bool get_job_to_migrate(JCR *jcr)
    }
    
    jcr->previous_jr.JobId = JobId;
-   Dmsg1(000, "Last jobid=%d\n", jcr->previous_jr.JobId);
+   Dmsg1(000, "Previous jobid=%d\n", jcr->previous_jr.JobId);
 
    if (!db_get_job_record(jcr, jcr->db, &jcr->previous_jr)) {
       Jmsg(jcr, M_FATAL, 0, _("Could not get job record for JobId %s to migrate. ERR=%s"),
@@ -542,6 +546,25 @@ bail_out:
    return false;
 }
 
+static void start_migration_job(JCR *jcr)
+{
+   UAContext *ua = new_ua_context(jcr);
+   char ed1[50];
+   ua->batch = true;
+   Mmsg(ua->cmd, "run %s jobid=%s", jcr->job->hdr.name, 
+        edit_uint64(jcr->MigrateJobId, ed1));
+   Dmsg1(000, "=============== Migration cmd=%s\n", ua->cmd);
+   parse_ua_args(ua);                 /* parse command */
+// int stat = run_cmd(ua, ua->cmd);
+   int stat = (int)jcr->MigrateJobId;
+   if (stat == 0) {
+      Jmsg(jcr, M_ERROR, 0, _("Could not start migration job.\n"));
+   } else {
+      Jmsg(jcr, M_INFO, 0, _("Migration JobId %d started.\n"), stat);
+   }
+   free_ua_context(ua);
+}
+
 
 static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1,
                  const char *query2, const char *type) {