[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bacula-devel] Clone jobs and storage


Hi,

On Wednesday 09 July 2008, Bastian Friedrich wrote:
>
> some months ago, I submitted a patch to be able to access the pool of the
> parental job in clone jobs.

... some more months ago, I submitted another patch that first implemented the 
job code callbacks as suggested by Kern.

I frankly do not know why I created two different callbacks in the director 
any more; both are part of the director, both have access to the same JCR 
structure.

The attached patch against current SVN drops one of these callback functions 
in favor of the other one (which is renamed, also); additionally, it adds 
the %w for writing storage.

The new/remaining callback function lives in dird_conf.c; I'm not sure whether 
this is the correct location...?

The codes %f, %p and %w can e.g. be used in Run statements and Run Scripts.

Best
   Bastian

-- 
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-24
f: +49 (0) 761-45684-10        www.collax.com

Geschäftsführer: William K. Hite / Boris Nalbach
AG München HRB 158898 . Ust.-IdNr: DE 814464942
\ atdt110
\ NO CONNECT
--- bacula-2.5-20080709svn/src/dird/protos.h.ori	2008-07-16 11:55:51.000000000 +0200
+++ bacula-2.5-20080709svn/src/dird/protos.h	2008-07-16 11:56:38.000000000 +0200
@@ -75,7 +75,7 @@
 
 /* dird_conf.c */
 extern const char *level_to_str(int level);
-extern "C" char *job_code_callback_filesetname(JCR *jcr, const char*);
+extern "C" char *job_code_callback_director(JCR *jcr, const char*);
 
 /* expand.c */
 int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp);
--- bacula-2.5-20080709svn/src/dird/dird_conf.c.ori	2008-07-16 11:55:43.000000000 +0200
+++ bacula-2.5-20080709svn/src/dird/dird_conf.c	2008-07-16 11:58:56.000000000 +0200
@@ -1812,7 +1812,7 @@
 
    if (pass == 2) {
       RUNSCRIPT *script = new_runscript();
-      script->set_job_code_callback(job_code_callback_filesetname);
+      script->set_job_code_callback(job_code_callback_director);
 
       script->set_command(lc->str);
 
@@ -1959,7 +1959,7 @@
        *  - POOLMEM command string (ex: /bin/true) 
        *  - int command type (ex: SHELL_CMD)
        */
-      res_runscript.set_job_code_callback(job_code_callback_filesetname);
+      res_runscript.set_job_code_callback(job_code_callback_director);
       while ((c=(char*)res_runscript.commands->pop()) != NULL) {
          t = (long)res_runscript.commands->pop();
          RUNSCRIPT *script = new_runscript();
@@ -1985,13 +1985,14 @@
 }
 
 /* callback function for edit_job_codes */
-extern "C" char *job_code_callback_filesetname(JCR *jcr, const char* param)
+extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
 {
-   if (param[0] == 'f') {
-      return jcr->fileset->name();
-   } else {
-      return NULL;
+   switch (param[0]) {
+      case 'f': return jcr->fileset->name(); break;
+      case 'p': return jcr->pool->name(); break;
+      case 'w': return jcr->wstore->name(); break;
    }
+   return NULL;
 }
 
 bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code)
--- bacula-2.5-20080709svn/src/dird/job.c.ori	2008-07-09 11:25:25.000000000 +0200
+++ bacula-2.5-20080709svn/src/dird/job.c	2008-07-16 11:56:22.000000000 +0200
@@ -1308,14 +1308,6 @@
    jcr->wstore = NULL;
 }
 
-char *job_code_callback_clones(JCR *jcr, const char* param) 
-{
-   if (param[0] == 'p') {
-      return jcr->pool->name();
-   }
-   return NULL;
-}
-
 void create_clones(JCR *jcr)
 {
    /*
@@ -1329,7 +1321,7 @@
       UAContext *ua = new_ua_context(jcr);
       ua->batch = true;
       foreach_alist(runcmd, job->run_cmds) {
-         cmd = edit_job_codes(jcr, cmd, runcmd, "", job_code_callback_clones);
+         cmd = edit_job_codes(jcr, cmd, runcmd, "", job_code_callback_director);
          Mmsg(ua->cmd, "run %s cloned=yes", cmd);
          Dmsg1(900, "=============== Clone cmd=%s\n", ua->cmd);
          parse_ua_args(ua);                 /* parse command */
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.