]> git.sur5r.net Git - bacula/bacula/commitdiff
27Feb06
authorKern Sibbald <kern@sibbald.com>
Mon, 27 Feb 2006 11:21:44 +0000 (11:21 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 27 Feb 2006 11:21:44 +0000 (11:21 +0000)
- Modify the Python class examples to inherit object -- new way
  of defining classes. Patch from Felix Schwartz.
- Implement jobuid to replace old usage of job in keywords as
  suggested by Eric Bollengier.
- Apply patch for enhancing wait from Eric Bollengier. On can now:
   wait  (wait for all jobs to stop)
   wait jobid=nn
   wait jobuid=unique id
   wait job=job-name
- Implement write variables for Python to set Priority (anytime), and
  Job Level, only during JobInit event.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2820 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/examples/python/DirStartUp.py
bacula/examples/python/FDStartUp.py
bacula/examples/python/SDStartUp.py
bacula/kes-1.39
bacula/src/cats/sql_list.c
bacula/src/dird/pythondir.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_select.c
bacula/src/version.h

index 5433ad8b872c32981b43abcd5258e7e0feebf015..a6f39956007980a710c1a980e1fabddb2c3ff654 100644 (file)
@@ -7,7 +7,7 @@ import sys, bacula
 
 # This is the list of Bacula daemon events that you
 #  can receive.
-class BaculaEvents:
+class BaculaEvents(object):
   def __init__(self):
      # Called here when a new Bacula Events class is
      #  is created. Normally not used 
@@ -43,7 +43,7 @@ bacula.set_events(BaculaEvents()) # register daemon events desired
 """
   There are the Job events that you can receive.
 """
-class JobEvents:
+class JobEvents(object):
   def __init__(self):
      # Called here when you instantiate the Job. Not
      # normally used
index 0c274c8c0fe668f19d761cb9cd5b92d1938fd83a..4d53e33bfc987463154dc79803fb72d6aea8673f 100644 (file)
@@ -6,7 +6,7 @@ import sys, bacula
 
 # This is the list of Bacula daemon events that you
 #  can receive.
-class BaculaEvents:
+class BaculaEvents(object):
   def __init__(self):
      # Called here when a new Bacula Events class is
      #  is created. Normally not used 
@@ -44,7 +44,7 @@ bacula.set_events(BaculaEvents()) # register daemon events desired
 """
   There are the Job events that you can receive.
 """
-class JobEvents:
+class JobEvents(object):
   def __init__(self):
      # Called here when you instantiate the Job. Not
      # normally used
index 8430e4f1ceec5f3ccc128f438973c4e30816a4bd..1f08beda4ca6cd17443106b4f0489b9f755a66e2 100644 (file)
@@ -6,7 +6,7 @@ import sys, bacula
 
 # This is the list of Bacula daemon events that you
 #  can receive.
-class BaculaEvents:
+class BaculaEvents(object):
   def __init__(self):
      # Called here when a new Bacula Events class is
      #  is created. Normally not used 
@@ -45,7 +45,7 @@ bacula.set_events(BaculaEvents()) # register daemon events desired
 """
   There are the Job events that you can receive.
 """
-class JobEvents:
+class JobEvents(object):
   def __init__(self):
      # Called here when you instantiate the Job. Not
      # normally used
index f9f5da2f2a38b2486681caa5fc4cb11f415e402f..5f3add35036f05597f671dfa8a5a52aa93198a4d 100644 (file)
@@ -3,6 +3,19 @@
 
 General:
 
+27Feb06
+- Modify the Python class examples to inherit object -- new way
+  of defining classes. Patch from Felix Schwartz.
+- Implement jobuid to replace old usage of job in keywords as
+  suggested by Eric Bollengier.
+- Apply patch for enhancing wait from Eric Bollengier. On can now:
+   wait  (wait for all jobs to stop)
+   wait jobid=nn
+   wait jobuid=unique id
+   wait job=job-name
+- Implement write variables for Python to set Priority (anytime), and
+  Job Level, only during JobInit event.
+
 26Feb06
 - Fix the block listing bug pointed out by Arno.
 - Update the po files at Eric's request.
index 8d180198dc420b207ed897740b1bb22335ec0c4f..c1b451e3196176b742e921400909f64b322b905d 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
@@ -282,7 +282,7 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
          Mmsg(mdb->cmd, 
             "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
             "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1));
-      } else {                           /* single record */
+      } else {                           /* all records */
          Mmsg(mdb->cmd,
            "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
            "FROM Job ORDER BY StartTime,JobId ASC%s", limit);
index 17e2f58984062fad96eded91da308bc6d7576b2e..57557fbfaacbebbd040fdee4ec7f2df4725b7934 100644 (file)
@@ -30,6 +30,7 @@
 #include <Python.h>
 
 extern char *configfile;
+extern struct s_jl joblevels[];
 extern JCR *get_jcr_from_PyObject(PyObject *self);
 extern PyObject *find_method(PyObject *eventsObject, PyObject *method, 
          const char *name);
@@ -82,6 +83,7 @@ static struct s_vars setvars[] = {
    { "JobReport",   "s"},
    { "VolumeName",  "s"},
    { "Priority",    "i"},
+   { "JobLevel",    "s"},
 
    { NULL,             NULL}
 };
@@ -235,7 +237,27 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
       break;
    case 2:                            /* Priority */
       Dmsg1(000, "Set priority=%d\n", intval);
-      return 0;
+      if (intval >= 1 && intval <= 100) {
+         jcr->JobPriority = intval;
+      } else {
+         PyErr_SetString(PyExc_ValueError, _("Priority must be 1-100"));
+         return -1;
+      }
+   case 3:                            /* Job Level */
+      if (strcmp("JobInit", jcr->event) != 0) {
+         PyErr_SetString(PyExc_RuntimeError, _("Job Level can be set only during JobInit"));
+         return -1;
+      }
+      for (i=0; joblevels[i].level_name; i++) {
+         if (strcmp(strval, joblevels[i].level_name) == 0) {
+            if (joblevels[i].job_type == jcr->JobType) {
+               jcr->JobLevel = joblevels[i].level;
+               return 0;
+            }
+         }
+      }
+      PyErr_SetString(PyExc_ValueError, _("Bad JobLevel string"));
+      return -1;
    }
 bail_out:
    PyErr_SetString(PyExc_AttributeError, attrname);
index 1ecc80c8193ae11af06a331d56e2b02be8bcbade..d50a3c7be9c49588a9aca931172fd338337641e1 100644 (file)
@@ -396,7 +396,18 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
             bstrncpy(jcr->Job, ua->argv[i], sizeof(jcr->Job));
          }
          break;
+      } else if (strcasecmp(ua->argk[i], _("jobuid")) == 0) {
+         if (!ua->argv[i]) {
+            break;
+         }
+         if (!(jcr=get_jcr_by_full_name(ua->argv[i]))) {
+            bsendmsg(ua, _("Warning Job %s is not running. Continuing anyway ...\n"), ua->argv[i]);
+            jcr = new_jcr(sizeof(JCR), dird_free_jcr);
+            bstrncpy(jcr->Job, ua->argv[i], sizeof(jcr->Job));
+         }
+         break;
       }
+
    }
    /* If we still do not have a jcr,
     *   throw up a list and ask the user to select one.
@@ -435,7 +446,6 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
             return 1;
          }
       }
-      /* NOTE! This increments the ref_count */
       sscanf(buf, "JobId=%d Job=%127s", &njobs, JobName);
       jcr = get_jcr_by_full_name(JobName);
       if (!jcr) {
index c3f1ac1883a37bbb4bd0d8e2c711018d8d063ad7..039a1db9c02b2393b3ae5961f0764360e62378b0 100644 (file)
@@ -202,7 +202,9 @@ bail_out:
  *
  *  list jobs           - lists all jobs run
  *  list jobid=nnn      - list job data for jobid
- *  list job=name       - list job data for job
+ *  list jobuid=uname   - list job data for unique jobid
+ *  list job=name       - list all jobs with "name"   
+ *  list jobname=name   - same as above 
  *  list jobmedia jobid=<nn>
  *  list jobmedia job=name
  *  list files jobid=<nn> - list files saved for job nn
@@ -277,23 +279,23 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
          }
 
       /* List JOB=xxx */
-      } else if (strcasecmp(ua->argk[i], N_("job")) == 0 && ua->argv[i]) {
-         bstrncpy(jr.Job, ua->argv[i], MAX_NAME_LENGTH);
+      } else if ((strcasecmp(ua->argk[i], N_("job")) == 0 ||
+                  strcasecmp(ua->argk[i], N_("jobname")) == 0) && ua->argv[i]) {
+         bstrncpy(jr.Name, ua->argv[i], MAX_NAME_LENGTH);
          jr.JobId = 0;
          db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist);
 
-      /* List JOBNAME=xxx */
-      } else if (strcasecmp(ua->argk[i], N_("job")) == 0 && ua->argv[i]) {
-         bstrncpy(jr.Name, ua->argv[i], MAX_NAME_LENGTH);
+      /* List JOBUID=xxx */
+      } else if (strcasecmp(ua->argk[i], N_("jobuid")) == 0 && ua->argv[i]) {
+         bstrncpy(jr.Job, ua->argv[i], MAX_NAME_LENGTH);
          jr.JobId = 0;
          db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist);
 
-
       /* List FILES */
       } else if (strcasecmp(ua->argk[i], N_("files")) == 0) {
 
          for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], N_("job")) == 0 && ua->argv[j]) {
+            if (strcasecmp(ua->argk[j], N_("jobuid")) == 0 && ua->argv[j]) {
                bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
                jr.JobId = 0;
                db_get_job_record(ua->jcr, ua->db, &jr);
@@ -312,7 +314,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
       } else if (strcasecmp(ua->argk[i], N_("jobmedia")) == 0) {
          int done = FALSE;
          for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], N_("job")) == 0 && ua->argv[j]) {
+            if (strcasecmp(ua->argk[j], N_("jobuid")) == 0 && ua->argv[j]) {
                bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
                jr.JobId = 0;
                db_get_job_record(ua->jcr, ua->db, &jr);
@@ -350,7 +352,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
                  strcasecmp(ua->argk[i], N_("volumes")) == 0) {
          bool done = false;
          for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], N_("job")) == 0 && ua->argv[j]) {
+            if (strcasecmp(ua->argk[j], N_("jobuid")) == 0 && ua->argv[j]) {
                bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
                jr.JobId = 0;
                db_get_job_record(ua->jcr, ua->db, &jr);
index 17f9e1de7f7db5369f6fb26e2fce938a4ee73e7b..29c9efd9970e4fca0694cfc8c0c7da2b9d40e9c9 100644 (file)
@@ -626,7 +626,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr)
    int i;
 
    for (i=1; i<ua->argc; i++) {
-      if (strcasecmp(ua->argk[i], N_("job")) == 0 && ua->argv[i]) {
+      if (strcasecmp(ua->argk[i], N_("jobuid")) == 0 && ua->argv[i]) {
          jr->JobId = 0;
          bstrncpy(jr->Job, ua->argv[i], sizeof(jr->Job));
       } else if (strcasecmp(ua->argk[i], N_("jobid")) == 0 && ua->argv[i]) {
@@ -648,7 +648,8 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr)
    jr->Job[0] = 0;
 
    for (i=1; i<ua->argc; i++) {
-      if (strcasecmp(ua->argk[i], N_("jobname")) == 0 && ua->argv[i]) {
+      if ((strcasecmp(ua->argk[i], N_("jobname")) == 0 ||
+           strcasecmp(ua->argk[i], N_("job")) == 0) && ua->argv[i]) {
          jr->JobId = 0;
          bstrncpy(jr->Name, ua->argv[i], sizeof(jr->Name));
          break;
@@ -831,7 +832,8 @@ STORE *get_storage_resource(UAContext *ua, bool use_default)
             free_jcr(jcr);
             break;
 
-         } else if (strcasecmp(ua->argk[i], N_("job")) == 0) {
+         } else if (strcasecmp(ua->argk[i], N_("job")) == 0 ||
+                    strcasecmp(ua->argk[i], N_("jobname")) == 0) {
             if (!ua->argv[i]) {
                bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]);
                return NULL;
@@ -843,6 +845,18 @@ STORE *get_storage_resource(UAContext *ua, bool use_default)
             store = jcr->store;
             free_jcr(jcr);
             break;
+         } else if (strcasecmp(ua->argk[i], N_("jobuid")) == 0) {
+            if (!ua->argv[i]) {
+               bsendmsg(ua, _("Expecting jobuid=xxx, got: %s.\n"), ua->argk[i]);
+               return NULL;
+            }
+            if (!(jcr=get_jcr_by_full_name(ua->argv[i]))) {
+               bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]);
+               return NULL;
+            }
+            store = jcr->store;
+            free_jcr(jcr);
+            break;
         }
       }
    }
index f660ead03f167f36d616fc9c70e8e859e2a297d4..6b8ec0a68a691d592a2a3eb78e9d4b4de9d1d87b 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.6"
-#define BDATE   "26 February 2006"
-#define LSMDATE "26Feb06"
+#define BDATE   "27 February 2006"
+#define LSMDATE "27Feb06"
 
 /* Debug flags */
 #undef  DEBUG