From: Kern Sibbald Date: Thu, 30 Jul 2009 13:34:26 +0000 (+0000) Subject: Modify enable/disable commands to show only appropriate Jobs. X-Git-Tag: Release-5.0.0~438 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=931c26010865e4526ff2bcb2a6ef569097b7b53f;p=bacula%2Fbacula Modify enable/disable commands to show only appropriate Jobs. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@9124 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 2ae354104c..f3114d625f 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -241,6 +241,7 @@ void free_ua_context(UAContext *ua); /* ua_select.c */ STORE *select_storage_resource(UAContext *ua); JOB *select_job_resource(UAContext *ua); +JOB *select_enable_disable_job_resource(UAContext *ua, bool enable); JOB *select_restore_job_resource(UAContext *ua); CLIENT *select_client_resource(UAContext *ua); FILESET *select_fileset_resource(UAContext *ua); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 112f7da0cd..80fa7233e6 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -803,7 +803,7 @@ static void do_en_disable_cmd(UAContext *ua, bool setting) i = find_arg_with_value(ua, NT_("job")); if (i < 0) { - job = select_job_resource(ua); + job = select_enable_disable_job_resource(ua, setting); if (!job) { return; } diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 3d5fc1dfba..c93ad9d2d4 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -96,7 +96,29 @@ int gui_cmd(UAContext *ua, const char *cmd) return 1; } - +/* + * Enter with Resources locked + */ +static void show_disabled_jobs(UAContext *ua) +{ + JOB *job; + bool first = true; + foreach_res(job, R_JOB) { + if (!acl_access_ok(ua, Job_ACL, job->name())) { + continue; + } + if (!job->enabled) { + if (first) { + first = false; + ua->send_msg(_("Disabled Jobs:\n")); + } + ua->send_msg(" %s\n", job->name()); + } + } + if (first) { + ua->send_msg(_("No disabled Jobs.\n")); + } +} struct showstruct {const char *res_name; int type;}; static struct showstruct reses[] = { @@ -123,6 +145,7 @@ static struct showstruct reses[] = { * show all * show e.g. show directors * show = e.g. show director=HeadMan + * show disabled shows disabled jobs * */ int show_cmd(UAContext *ua, const char *cmd) @@ -137,6 +160,10 @@ int show_cmd(UAContext *ua, const char *cmd) LockRes(); for (i=1; iargc; i++) { + if (strcasecmp(ua->argk[i], _("disabled")) == 0) { + show_disabled_jobs(ua); + goto bail_out; + } type = 0; res_name = ua->argk[i]; if (!ua->argv[i]) { /* was a name given? */ diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index d048861f00..aebdaa0b8b 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -244,6 +244,33 @@ CAT *get_catalog_resource(UAContext *ua) } +/* + * Select a job to enable or disable + */ +JOB *select_enable_disable_job_resource(UAContext *ua, bool enable) +{ + char name[MAX_NAME_LENGTH]; + JOB *job; + + LockRes(); + start_prompt(ua, _("The defined Job resources are:\n")); + foreach_res(job, R_JOB) { + if (!acl_access_ok(ua, Job_ACL, job->name())) { + continue; + } + if (job->enabled == enable) { /* Already enabled/disabled? */ + continue; /* yes, skip */ + } + add_prompt(ua, job->name()); + } + UnlockRes(); + if (do_prompt(ua, _("Job"), _("Select Job resource"), name, sizeof(name)) < 0) { + return NULL; + } + job = (JOB *)GetResWithName(R_JOB, name); + return job; +} + /* * Select a Job resource from prompt list */ diff --git a/bacula/technotes b/bacula/technotes index 250fc23c67..839133e1e8 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -2,6 +2,9 @@ General: +30Jul09 +kes Add 'show disabled' command that lists the disabled jobs. +kes Modify enable/disable commands to show only appropriate Jobs. 29Jul09 kes Add ACL check for client in estimate commande ebl Change time_t by utime_t in accurate function