]> git.sur5r.net Git - bacula/bacula/commitdiff
- Landon merged his data encription changes into the HEAD
authorKern Sibbald <kern@sibbald.com>
Sun, 4 Dec 2005 10:55:43 +0000 (10:55 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 4 Dec 2005 10:55:43 +0000 (10:55 +0000)
- Apply days keyword patch from Alexander.Bergolth at wu-wien.ac.at

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2641 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.39
bacula/src/dird/backup.c
bacula/src/dird/catreq.c
bacula/src/dird/protos.h
bacula/src/dird/pythondir.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_status.c
bacula/src/stored/label.c
bacula/src/stored/reserve.c
bacula/src/version.h

index b1a58fc6dd9e9300f07ca7927f87164727df1efd..8ced04a928ec6eac5a7a0d25fd2fca728f40b7f4 100644 (file)
@@ -3,6 +3,16 @@
 
 General:
 
+Changes to 1.39.2:
+- Landon merged his data encription changes into the HEAD
+- Apply days keyword patch from Alexander.Bergolth at wu-wien.ac.at 
+  If this patch is applied, the number of days can be specified with
+  "list nextvol days=xx"
+  or
+  "status dir days=xx"
+  My use case is to be able to preview the next scheduled job (and the 
+  next tape to be used) on fridays if there are no scheduled jobs during 
+  the weekend.
 Changes to 1.39.1:
 03Dec05
 - Fix font code in gnome2 console user patch. Fixes bug #501.
index f10207a158c8f9d641f94850b829c08371e9cf6b..f9bb0e0e3ca7acbbcb02e82ac2555bf80eeb8c55 100644 (file)
@@ -97,7 +97,7 @@ bool do_backup_init(JCR *jcr)
          }
       }
    }
-   jcr->PoolId = pr.PoolId;               /****FIXME**** this can go away */
+   jcr->PoolId = pr.PoolId;
    jcr->jr.PoolId = pr.PoolId;
 
    Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->cloned, jcr->job->run_cmds);
index 5ac184d4f529701665be001d5717c3b37a9ac60e..d8c879cef716f7d005e6c6c74136717a5444c519 100644 (file)
@@ -162,16 +162,6 @@ void catalog_request(JCR *jcr, BSOCK *bs)
             } else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) {
                reason = _("not correct MediaType");
             } else {
-              /*
-               * ****FIXME***
-               *   This test (accept_any_volume) is turned off
-               *   because it doesn't properly check if the volume
-               *   really is out of sequence!
-               *
-               * } else if (!jcr->pool->accept_any_volume) {
-               *    reason = "Volume not in sequence";
-               */
-
                /*
                 * Now try recycling if necessary
                 *   reason set non-NULL if we cannot use it
index 96b79e52941054bc630fc14007fad968f28a6054..d2e36f22018baa3e65af7a3f41fa25ecd0a12ea5 100644 (file)
@@ -164,7 +164,7 @@ int get_num_drives_from_SD(UAContext *ua);
 /* ua_output.c */
 void prtit(void *ctx, const char *msg);
 int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
-RUN *find_next_run(RUN *run, JOB *job, time_t &runtime);
+RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays);
 
 /* ua_restore.c */
 int get_next_jobid_from_list(char **p, JobId_t *JobId);
index 233f1f9ff808173e2e7506c37c84b6afb8d175fe..c47ba6a464478cb3b29ef0141c7e42a7bdc10215 100644 (file)
@@ -242,7 +242,9 @@ bail_out:
    return -1;
 }
 
-
+/*
+ * Set pointer to instantiated events class
+ */
 static PyObject *set_job_events(PyObject *self, PyObject *arg)
 {
    PyObject *eObject;
@@ -261,7 +263,7 @@ static PyObject *set_job_events(PyObject *self, PyObject *arg)
    return Py_None;
 }
 
-/* Run a Bacula command */
+/* Run a Bacula job */
 static PyObject *job_run(PyObject *self, PyObject *arg)
 {
    JCR *jcr;
index 2b0e9d04541bfdff57369a243d272f0c6fd8c964..f3e1916692a24c766029140f56684035e6556d38 100644 (file)
@@ -41,7 +41,7 @@ extern brwlock_t con_lock;
 
 /* Forward referenced functions */
 static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist);
-static bool list_nextvol(UAContext *ua);
+static bool list_nextvol(UAContext *ua, int ndays);
 
 /*
  * Turn auto display of console messages on/off
@@ -407,8 +407,18 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
       /* List next volume */
       } else if (strcasecmp(ua->argk[i], N_("nextvol")) == 0 ||
                  strcasecmp(ua->argk[i], N_("nextvolume")) == 0) {
-         list_nextvol(ua);
-      } else if (strcasecmp(ua->argk[i], N_("limit")) == 0) {
+        n = 1;
+         j = find_arg_with_value(ua, N_("days"));
+         if (j >= 0) {
+            n = atoi(ua->argv[j]);
+           if ((n < 0) || (n > 50)) {
+             bsendmsg(ua, _("Ignoring illegal value for days.\n"));
+             n = 1;
+           }
+         }
+         list_nextvol(ua, n);
+      } else if (strcasecmp(ua->argk[i], N_("limit")) == 0
+                || strcasecmp(ua->argk[i], N_("days")) == 0) {
          /* Ignore it */
       } else {
          bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
@@ -417,7 +427,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
    return 1;
 }
 
-static bool list_nextvol(UAContext *ua)
+static bool list_nextvol(UAContext *ua, int ndays)
 {
    JOB *job;
    JCR *jcr = ua->jcr;
@@ -426,6 +436,7 @@ static bool list_nextvol(UAContext *ua)
    time_t runtime;
    bool found = false;
    MEDIA_DBR mr;
+   POOL_DBR pr;
 
    memset(&mr, 0, sizeof(mr));
    int i = find_arg_with_value(ua, "job");
@@ -442,7 +453,7 @@ static bool list_nextvol(UAContext *ua)
          }
       }
    }
-   for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+   for (run=NULL; (run = find_next_run(run, job, runtime, ndays)); ) {
       pool = run->pool ? run->pool : NULL;
       if (!complete_jcr_for_job(jcr, job, pool)) {
          return false;
@@ -451,11 +462,18 @@ static bool list_nextvol(UAContext *ua)
       if (run->storage) {
          jcr->store = run->storage;
       }
+      memset(&pr, 0, sizeof(pr));
+      pr.PoolId = jcr->PoolId;
+      if (! db_get_pool_record(ua->jcr, ua->db, &pr)) {
+        strcpy(pr.Name, "*UnknownPool*");
+      }
       if (!find_next_volume_for_append(jcr, &mr, 0)) {
-         bsendmsg(ua, _("Could not find next Volume.\n"));
+        bsendmsg(ua, _("Could not find next Volume for Job %s (%s, %s).\n"),
+           job->hdr.name, pr.Name, level_to_str(run->level));
       } else {
-         bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
-            job->hdr.name, mr.VolumeName);
+         bsendmsg(ua,
+           _("The next Volume to be used by Job \"%s\" (%s, %s) will be %s\n"),
+            job->hdr.name, pr.Name, level_to_str(run->level), mr.VolumeName);
          found = true;
       }
       if (jcr->db && jcr->db != ua->db) {
@@ -464,7 +482,8 @@ static bool list_nextvol(UAContext *ua)
       }
    }
    if (!found) {
-      bsendmsg(ua, _("Could not find next Volume.\n"));
+      bsendmsg(ua, _("Could not find next Volume for Job %s.\n"),
+        job->hdr.name);
       return false;
    }
    return true;
@@ -475,36 +494,24 @@ static bool list_nextvol(UAContext *ua)
  * For a given job, we examine all his run records
  *  to see if it is scheduled today or tomorrow.
  */
-RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
+RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
 {
-   time_t now, tomorrow;
+   time_t now, future, endtime;
    SCHED *sched;
-   struct tm tm;
-   int mday, wday, month, wom, tmday, twday, tmonth, twom, i;
-   int woy, twoy;
-   int tod, tom;
+   struct tm tm, runtm;
+   int mday, wday, month, wom, i;
+   int woy;
+   int day;
+   int is_scheduled;
 
    sched = job->schedule;
    if (sched == NULL) {            /* scheduled? */
       return NULL;                 /* no nothing to report */
    }
-   /* Break down current time into components */
+
+   /* Break down the time into components */
    now = time(NULL);
-   localtime_r(&now, &tm);
-   mday = tm.tm_mday - 1;
-   wday = tm.tm_wday;
-   month = tm.tm_mon;
-   wom = mday / 7;
-   woy = tm_woy(now);
-
-   /* Break down tomorrow into components */
-   tomorrow = now + 60 * 60 * 24;
-   localtime_r(&tomorrow, &tm);
-   tmday = tm.tm_mday - 1;
-   twday = tm.tm_wday;
-   tmonth = tm.tm_mon;
-   twom = tmday / 7;
-   twoy  = tm_woy(tomorrow);
+   endtime = now + (ndays * 60 * 60 * 24);
 
    if (run == NULL) {
       run = sched->run;
@@ -515,68 +522,59 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
       /*
        * Find runs in next 24 hours
        */
-      tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) &&
+      for (day = 0; day <= ndays; day++) {
+        future = now + (day * 60 * 60 * 24);
+
+        /* Break down the time into components */
+        localtime_r(&future, &tm);
+        mday = tm.tm_mday - 1;
+        wday = tm.tm_wday;
+        month = tm.tm_mon;
+        wom = mday / 7;
+        woy = tm_woy(future);
+
+        is_scheduled = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) &&
             bit_is_set(month, run->month) && bit_is_set(wom, run->wom) &&
             bit_is_set(woy, run->woy);
-
-      tom = bit_is_set(tmday, run->mday) && bit_is_set(twday, run->wday) &&
-            bit_is_set(tmonth, run->month) && bit_is_set(twom, run->wom) &&
-            bit_is_set(twoy, run->woy);
-
 #ifdef xxx
-      Dmsg2(000, "tod=%d tom=%d\n", tod, tom);
-      Dmsg1(000, "bit_set_mday=%d\n", bit_is_set(mday, run->mday));
-      Dmsg1(000, "bit_set_wday=%d\n", bit_is_set(wday, run->wday));
-      Dmsg1(000, "bit_set_month=%d\n", bit_is_set(month, run->month));
-      Dmsg1(000, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
-      Dmsg1(000, "bit_set_woy=%d\n", bit_is_set(woy, run->woy));
+        Dmsg2(000, "day=%d is_scheduled=%d\n", day, is_scheduled);
+        Dmsg1(000, "bit_set_mday=%d\n", bit_is_set(mday, run->mday));
+        Dmsg1(000, "bit_set_wday=%d\n", bit_is_set(wday, run->wday));
+        Dmsg1(000, "bit_set_month=%d\n", bit_is_set(month, run->month));
+        Dmsg1(000, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
+        Dmsg1(000, "bit_set_woy=%d\n", bit_is_set(woy, run->woy));
 #endif
-      if (tod) {                   /* Jobs scheduled today (next 24 hours) */
+
+        if (is_scheduled) { /* Jobs scheduled on that day */
 #ifdef xxx
-         char buf[300], num[10];
-         bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour);
-         for (i=0; i<24; i++) {
-            if (bit_is_set(i, run->hour)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
-               bstrncat(buf, num, sizeof(buf));
-            }
-         }
-         bstrncat(buf, "\n", sizeof(buf));
-         Dmsg1(000, "%s", buf);
+           char buf[300], num[10];
+           bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour);
+           for (i=0; i<24; i++) {
+              if (bit_is_set(i, run->hour)) {
+                 bsnprintf(num, sizeof(num), "%d ", i);
+                 bstrncat(buf, num, sizeof(buf));
+              }
+           }
+           bstrncat(buf, "\n", sizeof(buf));
+           Dmsg1(000, "%s", buf);
 #endif
-         /* find time (time_t) job is to be run */
-         localtime_r(&now, &tm);
-         for (i=tm.tm_hour; i < 24; i++) {
-            if (bit_is_set(i, run->hour)) {
-               tm.tm_hour = i;
-               tm.tm_min = run->minute;
-               tm.tm_sec = 0;
-               runtime = mktime(&tm);
-               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
-               if (runtime > now) {
-                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
-                  return run;         /* found it, return run resource */
-               }
-            }
-         }
-      }
-
-//    Dmsg2(200, "runtime=%d now=%d\n", runtime, now);
-      if (tom) {                /* look at jobs scheduled tomorrow */
-         localtime_r(&tomorrow, &tm);
-         for (i=0; i < 24; i++) {
-            if (bit_is_set(i, run->hour)) {
-               tm.tm_hour = i;
-               tm.tm_min = run->minute;
-               tm.tm_sec = 0;
-               runtime = mktime(&tm);
-               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
-               if (runtime < tomorrow) {
-                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
-                  return run;         /* found it, return run resource */
-               }
-            }
-         }
+           /* find time (time_t) job is to be run */
+           localtime_r(&future, &runtm);
+           for (i= 0; i < 24; i++) {
+              if (bit_is_set(i, run->hour)) {
+                 runtm.tm_hour = i;
+                 runtm.tm_min = run->minute;
+                 runtm.tm_sec = 0;
+                 runtime = mktime(&runtm);
+                 Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
+                 if ((runtime > now) && (runtime < endtime)) {
+                    Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
+                    return run;         /* found it, return run resource */
+                 }
+              }
+           }
+        }
       }
    } /* end for loop over runs */
    /* Nothing found */
index 2e24753f34522d00ea099af9bf7bde66ff3f90d9..f1a07d4ed437c4c175019e62cde43a501ac0d1c3 100644 (file)
@@ -440,16 +440,27 @@ static void list_scheduled_jobs(UAContext *ua)
    bool hdr_printed = false;
    dlist sched;
    sched_pkt *sp;
+   int days, i;
 
    Dmsg0(200, "enter list_sched_jobs()\n");
 
+   days = 1;
+   i = find_arg_with_value(ua, N_("days"));
+   if (i >= 0) {
+     days = atoi(ua->argv[i]);
+     if ((days < 0) || (days > 50)) {
+       bsendmsg(ua, _("Ignoring illegal value for days.\n"));
+       days = 1;
+     }
+   }
+
    /* Loop through all jobs */
    LockRes();
    foreach_res(job, R_JOB) {
       if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
          continue;
       }
-      for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+      for (run=NULL; (run = find_next_run(run, job, runtime, days)); ) {
          level = job->JobLevel;
          if (run->level) {
             level = run->level;
index 4aae8a828a07e57c70ceaa7603c9c3e451b54b95..306f143289d17dc1d64fc38365e4ba1bad381b9f 100644 (file)
@@ -755,8 +755,8 @@ bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
    unser_string(dev->VolHdr.ProgDate);
 
    ser_end(rec->data, SER_LENGTH_Volume_Label);
-   Dmsg0(90, "unser_vol_label\n");
-   if (debug_level >= 90) {
+   Dmsg0(190, "unser_vol_label\n");
+   if (debug_level >= 190) {
       dump_volume_label(dev);
    }
    return true;
index 55a903a3f1be887cf62f0125105b26ef904fb931..f38d223fb1361f5799fe9c3366540c2392b8f2ed 100644 (file)
@@ -612,7 +612,6 @@ static int reserve_device(RCTX &rctx)
       if (ok) {
          rctx.jcr->dcr = dcr;
       }
-      Dmsg3(200, "dev_name=%s mediatype=%s ok=%d\n", dcr->dev_name, dcr->media_type, ok);
    } else {
       ok = reserve_device_for_read(dcr);
       if (ok) {
@@ -623,6 +622,8 @@ static int reserve_device(RCTX &rctx)
       free_dcr(dcr);
       return 0;
    }
+   Dmsg4(100, "Reserved dev_name=%s mediatype=%s pool=%s ok=%d\n",
+         dcr->dev_name, dcr->media_type, dcr->pool_name, ok);
    return 1;
 }
 
index 4058a040e2d8abac4ef0924aa02f7d0767d7fdb1..39b53383cfa2e941b37f7ec8d1f1cc24bb76e6e8 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "1.39.1"
-#define BDATE   "29 November 2005"
-#define LSMDATE "29Nov05"
+#define VERSION "1.39.2"
+#define BDATE   "04 December 2005"
+#define LSMDATE "04Dec05"
 
 /* Debug flags */
 #undef  DEBUG