* 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
{"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},
{"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},
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);
* 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
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;
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 */
* 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
/* Wait until we have something in the
* next hour or so.
*/
+again:
while (jobs_to_run->empty()) {
find_runs();
if (!jobs_to_run->empty()) {
}
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);
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);
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);
{ 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")},
}
+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;
* 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
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;
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);
}
}
/* 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);
* 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
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;
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) {
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));
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);
/* 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)); ) {
* 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