Skip to content

Commit

Permalink
For migration/copy Jobs need to look at mig_jcr.
Browse files Browse the repository at this point in the history
Added new %V option to expansion variables which is the same as %v
but always prints the destination Volumes a Job used. For migration
and copy Jobs this expansion looks at the mig_jcr pointer in the JCR.

As this mig_jcr only exists in the director the %V is expanded in
the callback expansion function in the director as in the generic
expansion function is compiled as part of the generic shared library
we are missing that variable there.

While implementing this expansion also reformated the whole function
as the switch statement was wrongly indented. Removed unneeded break
statements after a return. Document what is expanded in the callback
expansion function.

Fixes #139: export command in a RunScript ressource does not get the
            correct volume when doing scheduled JobType Copy
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent b447706 commit 289aaac
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 31 deletions.
79 changes: 52 additions & 27 deletions src/dird/dird_conf.c
Expand Up @@ -2416,43 +2416,68 @@ static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
/*
* callback function for edit_job_codes
* See ../lib/util.c, function edit_job_codes, for more remaining codes
*
* %f = Filesetname
* %h = Client Address
* %p = Poolname
* %w = Write storage
* %x = Spooling (yes/no)
* %C = Cloning (yes/no)
* %D = Director name
* %V = Volume name(s) (Destination)
*/
extern "C" char *job_code_callback_director(JCR *jcr, const char *param)
{
static char yes[] = "yes";
static char no[] = "no";

switch (param[0]) {
case 'f':
if (jcr->res.fileset) {
return jcr->res.fileset->name();
}
break;
case 'h':
if (jcr->res.client) {
return jcr->res.client->address;
}
break;
case 'p':
if (jcr->res.pool) {
return jcr->res.pool->name();
case 'f':
if (jcr->res.fileset) {
return jcr->res.fileset->name();
}
break;
case 'h':
if (jcr->res.client) {
return jcr->res.client->address;
}
break;
case 'p':
if (jcr->res.pool) {
return jcr->res.pool->name();
}
break;
case 'w':
if (jcr->res.wstore) {
return jcr->res.wstore->name();
}
break;
case 'x':
return jcr->spool_data ? yes : no;
case 'C':
return jcr->cloned ? yes : no;
case 'D':
return my_name;
case 'V':
if (jcr) {
/*
* If this is a migration/copy we need the volume name from the mig_jcr.
*/
if (jcr->mig_jcr) {
jcr = jcr->mig_jcr;
}
break;
case 'w':
if (jcr->res.wstore) {
return jcr->res.wstore->name();

if (jcr->VolumeName) {
return jcr->VolumeName;
} else {
return _("*none*");
}
break;
case 'x':
return jcr->spool_data ? yes : no;
break;
case 'D':
return my_name;
break;
case 'C':
return jcr->cloned ? yes : no;
break;
} else {
return _("*none*");
}
break;
}

return NULL;
}

Expand Down
7 changes: 3 additions & 4 deletions src/lib/util.c
Expand Up @@ -711,12 +711,11 @@ void decode_session_key(char *decode, char *session, char *key, int maxlen)
* %s = Since time
* %t = Job type (Backup, ...)
* %r = Recipients
* %v = Volume name
* %v = Volume name(s)
*
* omsg = edited output message
* imsg = input string containing edit codes (%x)
* to = recepients list
*
*/
POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_code_callback_t callback)
{
Expand Down Expand Up @@ -818,10 +817,10 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_co
break;
case 'v':
if (jcr) {
if (jcr->VolumeName && jcr->VolumeName[0]) {
if (jcr->VolumeName) {
str = jcr->VolumeName;
} else {
str = "";
str = _("*none*");
}
} else {
str = _("*none*");
Expand Down

0 comments on commit 289aaac

Please sign in to comment.