From eeeb98532770101aa2b310ac43c9379316c447ce Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 4 Dec 2005 10:55:43 +0000 Subject: [PATCH] - Landon merged his data encription changes into the HEAD - 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 | 10 +++ bacula/src/dird/backup.c | 2 +- bacula/src/dird/catreq.c | 10 --- bacula/src/dird/protos.h | 2 +- bacula/src/dird/pythondir.c | 6 +- bacula/src/dird/ua_output.c | 172 ++++++++++++++++++------------------ bacula/src/dird/ua_status.c | 13 ++- bacula/src/stored/label.c | 4 +- bacula/src/stored/reserve.c | 3 +- bacula/src/version.h | 6 +- 10 files changed, 120 insertions(+), 108 deletions(-) diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index b1a58fc6dd..8ced04a928 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -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. diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index f10207a158..f9bb0e0e3c 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -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); diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 5ac184d4f5..d8c879cef7 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -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 diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 96b79e5294..d2e36f2201 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -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); diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index 233f1f9ff8..c47ba6a464 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -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; diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 2b0e9d0454..f3e1916692 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -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 */ diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 2e24753f34..f1a07d4ed4 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -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; diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 4aae8a828a..306f143289 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -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; diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 55a903a3f1..f38d223fb1 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -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; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 4058a040e2..39b53383cf 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 -- 2.39.5