]> git.sur5r.net Git - bacula/bacula/commitdiff
Modify enable/disable commands to show only appropriate Jobs.
authorKern Sibbald <kern@sibbald.com>
Thu, 30 Jul 2009 13:34:26 +0000 (13:34 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 30 Jul 2009 13:34:26 +0000 (13:34 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@9124 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/protos.h
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_select.c
bacula/technotes

index 2ae354104c3e671572f8603940e70ba081fbf112..f3114d625f8c1c26ff2d8952af631a4b42cb9288 100644 (file)
@@ -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);
index 112f7da0cdcfaa6fdd200ad01db4e2981a5fe4fe..80fa7233e6594487288a15651a2637b90fccff3f 100644 (file)
@@ -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;
       }
index 3d5fc1dfba81ddcd34896651524623516f13e570..c93ad9d2d42f36ba11d09859e1283a51fc10b42c 100644 (file)
@@ -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 <resource-keyword-name>  e.g. show directors
  *  show <resource-keyword-name>=<name> 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; i<ua->argc; 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? */
index d048861f00ec2ec62a69d7ee3d7806f741cdc64e..aebdaa0b8be6ec3b4b0d66ce38bc8cff86f1635c 100644 (file)
@@ -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
  */
index 250fc23c67fca07d4fade24217d5b7dbfacb70ba..839133e1e8e1252831d05a67a772b01867c07a57 100644 (file)
@@ -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