]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Make sure that the storage for a job is pulled first from
authorKern Sibbald <kern@sibbald.com>
Wed, 22 Nov 2006 15:48:29 +0000 (15:48 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 22 Nov 2006 15:48:29 +0000 (15:48 +0000)
     the Pool and if not from the Job.
kes  Ensure that either the Pool or the Job specifies a Storage
     resource.

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

bacula/src/dird/dird.c
bacula/src/dird/job.c
bacula/src/dird/protos.h
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_run.c
bacula/src/dird/ua_status.c
bacula/technotes-1.39

index 2d19f24ec9ba52b898ad8ff2aa021c3672f77abe..0077507b304028131ce4a26f2e0ca03997e440a2 100644 (file)
@@ -726,6 +726,11 @@ static int check_resources()
             Emsg0(M_ERROR_TERM, 0, _("Too many items in Job resource\n"));
          }
       }
+      if (!job->storage && !job->pool->storage) {
+         Jmsg(NULL, M_FATAL, 0, _("No storage specified in Job \"%s\" nor in Pool.\n"),
+            job->hdr.name);
+         OK = false;
+      }
    } /* End loop over Job res */
 
    /* Loop over databases */
index f817e88632e5ce7cea966b3f03b0566a79879a37..798ff220379a82e17ee16df702516d43118e0e8f 100644 (file)
@@ -883,6 +883,20 @@ void dird_free_jcr(JCR *jcr)
    Dmsg0(200, "End dird free_jcr\n");
 }
 
+/* 
+ * The Job storage definition must be either in the Job record
+ *  or in the Pool record.  The Pool record overrides the Job 
+ *  record.
+ */
+STORE *get_job_storage(JOB *job)
+{
+   if (job->pool->storage) {
+      return (STORE *)job->pool->storage->first();
+   } else {
+      return (STORE *)job->storage->first();
+   }
+}
+
 /*
  * Set some defaults in the JCR necessary to
  * run. These items are pulled from the job
@@ -916,7 +930,11 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
    }
    jcr->JobPriority = job->Priority;
    /* Copy storage definitions -- deleted in dir_free_jcr above */
-   copy_rwstorage(jcr, job->storage, _("Job resource"));
+   if (job->storage) {
+      copy_rwstorage(jcr, job->storage, _("Job resource"));
+   } else {
+      copy_rwstorage(jcr, job->pool->storage, _("Job resource"));
+   }
    jcr->client = job->client;
    if (!jcr->client_name) {
       jcr->client_name = get_pool_memory(PM_NAME);
@@ -974,6 +992,10 @@ void copy_rwstorage(JCR *jcr, alist *storage, const char *where)
 /* Set storage override */
 void set_rwstorage(JCR *jcr, STORE *store)
 {
+   if (!store) {
+      Jmsg(jcr, M_FATAL, 0, _("No storage specified.\n"));
+      return;
+   }
    set_rstorage(jcr, store);
    set_wstorage(jcr, store);
 }
@@ -1011,6 +1033,12 @@ void set_rstorage(JCR *jcr, STORE *store)
 {
    STORE *storage;
 
+   if (!store) {
+      return;
+   }
+   if (!jcr->rstorage) {
+      jcr->rstorage = New(alist(10, not_owned_by_alist));
+   }
    jcr->rstore = store;
    foreach_alist(storage, jcr->rstorage) {
       if (store == storage) {
@@ -1057,6 +1085,12 @@ void set_wstorage(JCR *jcr, STORE *store)
 {
    STORE *storage;
 
+   if (!store) {
+      return;
+   }
+   if (!jcr->wstorage) {
+      jcr->wstorage = New(alist(10, not_owned_by_alist));
+   }
    jcr->wstore = store;
    foreach_alist(storage, jcr->wstorage) {
       if (store == storage) {
@@ -1076,8 +1110,6 @@ void free_wstorage(JCR *jcr)
    jcr->wstore = NULL;
 }
 
-
-
 void create_clones(JCR *jcr)
 {
    /*
index ccd77085684f805190758911368f4bc3959a187b..1c48fc9ab140205fed774145a54eb433adad6921 100644 (file)
@@ -111,6 +111,7 @@ extern DBId_t get_or_create_pool_record(JCR *jcr, char *pool_name);
 extern void apply_pool_overrides(JCR *jcr);
 extern JobId_t run_job(JCR *jcr);
 extern bool cancel_job(UAContext *ua, JCR *jcr);
+extern STORE *get_job_storage(JOB *job);
 extern void init_jcr_job_record(JCR *jcr);
 extern void copy_rwstorage(JCR *jcr, alist *storage, const char *where);
 extern void set_rwstorage(JCR *jcr, STORE *store);
index ecb26693c7024a0e8a6766438c481c69a668dc37..2552cd2f7039c6c31f4a3bb7fd16676b4c1375ac 100644 (file)
@@ -296,7 +296,7 @@ static int defaultscmd(UAContext *ua, const char *cmd)
          bsendmsg(ua, "pool=%s", job->pool->hdr.name);
          bsendmsg(ua, "messages=%s", job->messages->hdr.name);
          bsendmsg(ua, "client=%s", job->client->hdr.name);
-         store = (STORE *)job->storage->first();
+         store = get_job_storage(job);
          bsendmsg(ua, "storage=%s", store->hdr.name);
          bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:"");
          bsendmsg(ua, "level=%s", level_to_str(job->JobLevel));
index 30352ef11d95aa65526f75de63b3fc689f1d8073..ce329205d568a7cb14daaa7be0830236e1e3c0e7 100644 (file)
@@ -483,7 +483,7 @@ static bool list_nextvol(UAContext *ua, int ndays)
       if (run->storage) {
          jcr->wstore = run->storage;
       } else {
-         jcr->wstore = (STORE *)job->storage->first();
+         jcr->wstore = get_job_storage(job);
       }
       mr.StorageId = jcr->wstore->StorageId;
       if (!find_next_volume_for_append(jcr, &mr, 1, false/*no create*/)) {
index 55b60907b902819d0f32f27f210facbace40dcc0..ddc82bd2065da9602b8ab264e946da8727e63074 100644 (file)
@@ -352,8 +352,8 @@ int run_cmd(UAContext *ua, const char *cmd)
          }
          store = select_storage_resource(ua);
       }
-   } else if (job->storage) {
-      store = (STORE *)job->storage->first();           /* use default */
+   } else {
+      store = get_job_storage(job);            /* use default */
    }
    if (!store) {
       return 1;
index 7a4715d338d44c9e5960265220b7b54762ccbfc5..89afc6fb255cbc1957c15d2f0cfcff1c3953edb5 100644 (file)
@@ -483,7 +483,7 @@ static void list_scheduled_jobs(UAContext *ua)
          if (run->storage) {
             store = run->storage;
          } else {
-            store = (STORE *)job->storage->first();
+            store = get_job_storage(job);
          }
          if (!hdr_printed) {
             prt_runhdr(ua);
index 6b336eebdac8309d291defe7a229ffae5e7eb20b..b19a25f78e3e7eb0e772cd10f2537b5bad7f3237 100644 (file)
@@ -1,6 +1,11 @@
               Technical notes on version 1.39  
 
 General:
+22Nov06
+kes  Make sure that the storage for a job is pulled first from
+     the Pool and if not from the Job.  
+kes  Ensure that either the Pool or the Job specifies a Storage
+     resource.
 21Nov06 
 kes  Start applying new FSFE copyright.
 20Nov06