]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix merge collision
authorKern Sibbald <kern@sibbald.com>
Wed, 11 Jan 2006 09:21:55 +0000 (09:21 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 11 Jan 2006 09:21:55 +0000 (09:21 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2735 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/scheduler.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_status.c
bacula/src/dird/ua_update.c

index bf15f6d3f5c1be2b8b6ef0c87e18211a66453036..446f9478a5db806dc928dcf7f960ee99dc2c0a17 100644 (file)
@@ -22,7 +22,7 @@
  *     Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -183,6 +183,7 @@ static RES_ITEM store_items[] = {
    {"device",      store_device,   ITEM(res_store.device),     R_DEVICE, ITEM_REQUIRED, 0},
    {"mediatype",   store_strname,  ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
    {"autochanger", store_yesno,    ITEM(res_store.autochanger), 1, ITEM_DEFAULT, 0},
+   {"enabled",     store_yesno,    ITEM(res_store.enabled),     1, ITEM_DEFAULT, 1},
    {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
    {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
    {"tlsenable",            store_yesno,     ITEM(res_store.tls_enable), 1, 0, 0},
@@ -258,6 +259,7 @@ RES_ITEM job_items[] = {
    {"prunejobs",   store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0},
    {"prunefiles",  store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0},
    {"prunevolumes",store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0},
+   {"enabled",     store_yesno, ITEM(res_job.enabled), 1, ITEM_DEFAULT, 1},
    {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
    {"spooldata",   store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
    {"rerunfailedlevels",   store_yesno, ITEM(res_job.rerun_failed_levels), 1, ITEM_DEFAULT, 0},
@@ -534,15 +536,16 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
       break;
    case R_JOB:
    case R_JOBDEFS:
-      sendit(sock, _("%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n"),
+      sendit(sock, _("%s: name=%s JobType=%d level=%s Priority=%d Enabled=%d\n"),
          type == R_JOB ? _("Job") : _("JobDefs"),
          res->res_job.hdr.name, res->res_job.JobType,
          level_to_str(res->res_job.JobLevel), res->res_job.Priority,
-         res->res_job.MaxConcurrentJobs);
-      sendit(sock, _("     Resched=%d Times=%d Interval=%s Spool=%d WritePartAfterJob=%d\n"),
-          res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
-          edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
-          res->res_job.spool_data, res->res_job.write_part_after_job);
+         res->res_job.enabled);
+      sendit(sock, _("     MaxJobs=%u Resched=%d Times=%d Interval=%s Spool=%d WritePartAfterJob=%d\n"),
+         res->res_job.MaxConcurrentJobs, 
+         res->res_job.RescheduleOnError, res->res_job.RescheduleTimes,
+         edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
+         res->res_job.spool_data, res->res_job.write_part_after_job);
       if (res->res_job.client) {
          sendit(sock, _("  --> "));
          dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
index 3fb71288568401aa7c80dd9c17412aea68a74041..4e95147f46c8e6073b2b7148e622942d484f409a 100644 (file)
@@ -6,7 +6,7 @@
  *    Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -251,6 +251,7 @@ public:
    char *tls_keyfile;                 /* TLS Client Key File */
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
    int64_t StorageId;                 /* Set from Storage DB record */
+   int enabled;                       /* Set if device is enabled */
 
    /* Methods */
    char *dev_name() const;
@@ -308,7 +309,8 @@ public:
    int RescheduleTimes;               /* Number of times to reschedule job */
    utime_t RescheduleInterval;        /* Reschedule interval */
    utime_t JobRetention;              /* job retention period in seconds */
-   bool write_part_after_job;         /* Set to write part after job in SD */
+   int write_part_after_job;          /* Set to write part after job in SD */
+   int enabled;                       /* Set if job enabled */
    
    MSGS      *messages;               /* How and where to send messages */
    SCHED     *schedule;               /* When -- Automatic schedule */
index a2a977ebb51a9f46bb5d1f69a2b560ac58c02b07..80c72f7f0dda2b707bede0379f88c761697eb68c 100644 (file)
@@ -10,7 +10,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -88,6 +88,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
    /* Wait until we have something in the
     * next hour or so.
     */
+again:
    while (jobs_to_run->empty()) {
       find_runs();
       if (!jobs_to_run->empty()) {
@@ -127,11 +128,14 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
    }
    run = next_job->run;               /* pick up needed values */
    job = next_job->job;
-   run->last_run = now;               /* mark as run now */
-
-   dump_job(next_job, _("Run job"));
-
+   if (job->enabled) {
+      dump_job(next_job, _("Run job"));
+   }
    free(next_job);
+   if (!job->enabled) {
+      goto again;                     /* ignore this job */
+   }
+   run->last_run = now;               /* mark as run now */
 
    jcr = new_jcr(sizeof(JCR), dird_free_jcr);
    ASSERT(job);
@@ -234,7 +238,7 @@ static void find_runs()
    LockRes();
    foreach_res(job, R_JOB) {
       sched = job->schedule;
-      if (sched == NULL) {            /* scheduled? */
+      if (sched == NULL || !job->enabled) { /* scheduled? or enabled? */
          continue;                    /* no, skip this job */
       }
       Dmsg1(1200, "Got job: %s\n", job->hdr.name);
index 8a224741f7d8d185d7edfc9aa42d4855466db635..df9593c377eb20aba5a3ef7f4ba7a5e888065591 100644 (file)
@@ -56,6 +56,8 @@ extern int update_cmd(UAContext *ua, const char *cmd);
 static int add_cmd(UAContext *ua, const char *cmd);
 static int create_cmd(UAContext *ua, const char *cmd);
 static int cancel_cmd(UAContext *ua, const char *cmd);
+static int enable_cmd(UAContext *ua, const char *cmd);
+static int disable_cmd(UAContext *ua, const char *cmd);
 static int setdebug_cmd(UAContext *ua, const char *cmd);
 static int trace_cmd(UAContext *ua, const char *cmd);
 static int var_cmd(UAContext *ua, const char *cmd);
@@ -91,6 +93,8 @@ static struct cmdstruct commands[] = {
  { N_("cancel"),     cancel_cmd,    _("cancel [<jobid=nnn> | <job=name>] -- cancel a job")},
  { N_("create"),     create_cmd,    _("create DB Pool from resource")},
  { N_("delete"),     delete_cmd,    _("delete [pool=<pool-name> | media volume=<volume-name>]")},
+ { N_("disable"),    disable_cmd,   _("disable <job=name> -- disable a job")},
+ { N_("enable"),     enable_cmd,    _("enable <job=name> -- enable a job")},
  { N_("estimate"),   estimate_cmd,  _("performs FileSet estimate, listing gives full listing")},
  { N_("exit"),       quit_cmd,      _("exit = quit")},
  { N_("gui"),        gui_cmd,       _("gui [on|off] -- non-interactive gui mode")},
@@ -610,6 +614,49 @@ get_out:
 }
 
 
+static void do_en_disable_cmd(UAContext *ua, bool setting)
+{
+   JOB *job;
+   int i;
+
+   i = find_arg_with_value(ua, N_("job")); 
+   if (i < 0) { 
+      job = select_job_resource(ua);
+      if (!job) {
+         return;
+      }
+   } else {
+      LockRes();
+      job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+      UnlockRes();
+   } 
+   if (!job) {
+      bsendmsg(ua, _("Job \"%s\" not found.\n"), ua->argv[i]);
+      return;
+   }
+
+   if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
+      bsendmsg(ua, _("Illegal command from this console.\n"));
+      return;
+   }
+   job->enabled = setting;
+   bsendmsg(ua, _("Job \"%s\" %sabled\n"), job->hdr.name, setting?"en":"dis");
+   return;
+}
+
+static int enable_cmd(UAContext *ua, const char *cmd)
+{
+   do_en_disable_cmd(ua, true);
+   return 1;
+}
+
+static int disable_cmd(UAContext *ua, const char *cmd)
+{
+   do_en_disable_cmd(ua, false);
+   return 1;
+}
+
+
 static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trace_flag)
 {
    BSOCK *sd;
index 4e33a4523b47b5c926620078b40e5935a12c2726..747d7ff4add1b81883f721dd8872121bed4d5557 100644 (file)
@@ -11,7 +11,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Copyright (C) 2002-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -258,8 +258,12 @@ static int defaultscmd(UAContext *ua, const char *cmd)
    STORE *storage;
    POOL *pool;
 
+   if (ua->argc != 2) {
+      return 1;
+   }
+
    /* Job defaults */   
-   if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) {
+   if (strcmp(ua->argk[1], "job") == 0) {
       job = (JOB *)GetResWithName(R_JOB, ua->argv[1]);
       if (job) {
          STORE *store;
@@ -273,10 +277,11 @@ static int defaultscmd(UAContext *ua, const char *cmd)
          bsendmsg(ua, "level=%s", level_to_str(job->JobLevel));
          bsendmsg(ua, "type=%s", job_type_to_str(job->JobType));
          bsendmsg(ua, "fileset=%s", job->fileset->hdr.name);
+         bsendmsg(ua, "enabled=%d", job->enabled);
       }
    } 
    /* Client defaults */
-   else if(ua->argc == 2 && strcmp(ua->argk[1], "client") == 0) {
+   else if (strcmp(ua->argk[1], "client") == 0) {
      client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[1]);
      if (client) {
        bsendmsg(ua, "client=%s", client->hdr.name);
@@ -288,22 +293,25 @@ static int defaultscmd(UAContext *ua, const char *cmd)
      }
    }
    /* Storage defaults */
-   else if(ua->argc == 2 && strcmp(ua->argk[1], "storage") == 0) {
+   else if (strcmp(ua->argk[1], "storage") == 0) {
      storage = (STORE *)GetResWithName(R_STORAGE, ua->argv[1]);
-     DEVICE *device = (DEVICE *)storage->device->first();
+     DEVICE *device;
      if (storage) {
        bsendmsg(ua, "storage=%s", storage->hdr.name);
        bsendmsg(ua, "address=%s", storage->address);
+       bsendmsg(ua, "enabled=%d", storage->enabled);
        bsendmsg(ua, "media_type=%s", storage->media_type);
        bsendmsg(ua, "sdport=%d", storage->SDport);
+       device = (DEVICE *)storage->device->first();
        bsendmsg(ua, "device=%s", device->hdr.name);
-       if (storage->device->size() > 1)
-        while ((device = (DEVICE *)storage->device->next()))
-          bsendmsg(ua, ",%s", device->hdr.name);
+       if (storage->device->size() > 1) {
+         while ((device = (DEVICE *)storage->device->next()))
+           bsendmsg(ua, ",%s", device->hdr.name);
+       }
      }
    }
    /* Pool defaults */
-   else if(ua->argc == 2 && strcmp(ua->argk[1], "pool") == 0) {
+   else if (strcmp(ua->argk[1], "pool") == 0) {
      pool = (POOL *)GetResWithName(R_POOL, ua->argv[1]);
      if (pool) {
        bsendmsg(ua, "pool=%s", pool->hdr.name);
index a0bdd945adf229792a8302c377881804c06ce6d6..7b9778ef8d9e96236fa2d0e0840a9f9b4526a135 100644 (file)
@@ -7,7 +7,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2003-2005 Kern Sibbald
+   Copyright (C) 2003-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -171,6 +171,7 @@ int update_slots(UAContext *ua)
    scan = find_arg(ua, N_("scan")) >= 0;
 
    max_slots = get_num_slots_from_SD(ua);
+   Dmsg1(100, "max_slots=%d\n", max_slots);
    if (max_slots <= 0) {
       bsendmsg(ua, _("No slots in changer to scan.\n"));
       return 1;
@@ -188,6 +189,9 @@ int update_slots(UAContext *ua)
       goto bail_out;
    }
 
+   /* First zap out any InChanger with StorageId=0 */
+   db_sql_query(ua->db, "UPDATE Media SET InChanger=0 WHERE StorageId=0", NULL, NULL);
+
    /* Walk through the list updating the media records */
    for (vl=vol_list; vl; vl=vl->next) {
       if (vl->Slot > max_slots) {
@@ -220,7 +224,7 @@ int update_slots(UAContext *ua)
       db_unlock(ua->db);
       if (!vl->VolName) {
          Dmsg1(000, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot);
-         bsendmsg(ua, _("No VolName for Slot=%d set InChanger to zero.\n"), vl->Slot);
+         bsendmsg(ua, _("No VolName for Slot=%d InChanger set to zero.\n"), vl->Slot);
          continue;
       }
       memset(&mr, 0, sizeof(mr));
@@ -245,7 +249,7 @@ int update_slots(UAContext *ua)
          db_unlock(ua->db);
          continue;
       } else {
-         bsendmsg(ua, _("Volume \"%s\" not found in catalog. Slot=%d set InChanger to zero.\n"),
+         bsendmsg(ua, _("Volume \"%s\" not found in catalog. Slot=%d InChanger set to zero.\n"),
              mr.VolumeName, vl->Slot);
       }
       db_unlock(ua->db);
index b8ade96e21b56a808347f265b426dfc309ced0d6..95e3abb740e4f5aef8eeea89f3e6f36a9dfd6142 100644 (file)
@@ -457,7 +457,7 @@ static void list_scheduled_jobs(UAContext *ua)
    /* Loop through all jobs */
    LockRes();
    foreach_res(job, R_JOB) {
-      if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
+      if (!acl_access_ok(ua, Job_ACL, job->hdr.name) || !job->enabled) {
          continue;
       }
       for (run=NULL; (run = find_next_run(run, job, runtime, days)); ) {
index ffc795eb2311805bfc19ec4c797f42772d8404a9..a95057209a8ecb23aec804ea3e9b2b8157108ea8 100644 (file)
@@ -8,7 +8,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License