From: Kern Sibbald Date: Wed, 11 Jan 2006 09:21:55 +0000 (+0000) Subject: Fix merge collision X-Git-Tag: Release-1.38.4~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cded12aa4bebff6b183645c1a606808b7b188e0d;p=bacula%2Fbacula Fix merge collision git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2735 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index bf15f6d3f5..446f9478a5 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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); diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 3fb7128856..4e95147f46 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -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 */ diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index a2a977ebb5..80c72f7f0d 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -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); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 8a224741f7..df9593c377 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -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 [ | ] -- cancel a job")}, { N_("create"), create_cmd, _("create DB Pool from resource")}, { N_("delete"), delete_cmd, _("delete [pool= | media volume=]")}, + { N_("disable"), disable_cmd, _("disable -- disable a job")}, + { N_("enable"), enable_cmd, _("enable -- 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; diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 4e33a4523b..747d7ff4ad 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -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); diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index a0bdd945ad..7b9778ef8d 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -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); diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index b8ade96e21..95e3abb740 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -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)); ) { diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index ffc795eb23..a95057209a 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -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