]> git.sur5r.net Git - bacula/bacula/commitdiff
Implement Enabled on update slots
authorKern Sibbald <kern@sibbald.com>
Mon, 4 Sep 2006 21:18:25 +0000 (21:18 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 4 Sep 2006 21:18:25 +0000 (21:18 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3410 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/dird/protos.h
bacula/src/dird/ua_input.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_update.c
bacula/src/version.h
bacula/technotes-1.39

index 4b5e303f54aefb040053826ad07c3cb762b27d04..ca5f74a2d78e72dedb940e2b0582f6c5ad1cdeea 100644 (file)
@@ -62,13 +62,6 @@ For 1.39:
 - Print warning message if LANG environment variable does not specify
   UTF-8.
 - New dot commands from Arno.
-  .update volume [enabled|disabled|*see below]
-    > However, I could easily imagine an option to "update slots" that says 
-    > "enable=yes|no" that would automatically enable or disable all the Volumes 
-    > found in the autochanger.  This will permit the user to optionally mark all 
-    > the Volumes in the magazine disabled prior to taking them offsite, and mark 
-    > them all enabled when bringing them back on site.   Coupled with the options 
-    > to the slots keyword, you can apply the enable/disable to any or all volumes.
   .show device=xxx lists information from one storage device, including 
      devices (I'm not even sure that information exists in the DIR...)
   .move eject device=xxx mostly the same as 'unmount xxx' but perhaps with 
@@ -1658,4 +1651,11 @@ Block Position: 0
   daemon it was trying to connect to.
 - Freespace on DVD requested over and over even with no intervening
   writes.
+- .update volume [enabled|disabled|*see below]
+    > However, I could easily imagine an option to "update slots" that says 
+    > "enable=yes|no" that would automatically enable or disable all the Volumes 
+    > found in the autochanger.  This will permit the user to optionally mark all 
+    > the Volumes in the magazine disabled prior to taking them offsite, and mark 
+    > them all enabled when bringing them back on site.   Coupled with the options 
+    > to the slots keyword, you can apply the enable/disable to any or all volumes.
 
index d7c040fbb245993e35e1cdc0ea3fc177a56dd0e2..f25fac5c789032c3c3b37fd98e9a265ac9b48b96 100644 (file)
@@ -170,6 +170,7 @@ int get_cmd(UAContext *ua, const char *prompt);
 bool get_pint(UAContext *ua, const char *prompt);
 bool get_yesno(UAContext *ua, const char *prompt);
 bool is_yesno(char *val, int *ret);
+int get_enabled(UAContext *ua, const char *val);
 void parse_ua_args(UAContext *ua);
 
 /* ua_label.c */
index 9472af92713d14bb89de706b94d1b2626e1ec4bf..183e5028701857762c67cbcca7736d7f0908955f 100644 (file)
@@ -149,6 +149,31 @@ bool get_yesno(UAContext *ua, const char *prompt)
    }
 }
 
+/* 
+ *  Gets an Enabled value => 0, 1, 2, yes, no, archived
+ *  Returns: 0, 1, 2 if OK
+ *           -1 on error
+ */
+int get_enabled(UAContext *ua, const char *val) 
+{
+   int Enabled = -1;
+
+   if (strcasecmp(val, "yes") == 0 || strcasecmp(val, "true") == 0) {
+     Enabled = 1;
+   } else if (strcasecmp(val, "no") == 0 || strcasecmp(val, "false") == 0) {
+      Enabled = 0;
+   } else if (strcasecmp(val, "archived") == 0) { 
+      Enabled = 2;
+   } else {
+      Enabled = atoi(val);
+   }
+   if (Enabled < 0 || Enabled > 2) {
+      bsendmsg(ua, _("Invalid Enabled value, it must be yes, no, archived, 0, 1, or 2\n"));
+      return -1;     
+   }
+   return Enabled;
+}
+
 void parse_ua_args(UAContext *ua)
 {
    parse_args(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS);
index b60ba3df9329b9098c9942b26569ebdcc7177a50..89a1c30c5172675f8cbb0dd7cd4d35b1044cacc5 100644 (file)
@@ -156,6 +156,9 @@ void update_slots(UAContext *ua)
    bool scan;
    int max_slots;
    int drive;
+   int Enabled = 1;
+   bool have_enabled;
+   int i;
 
 
    if (!open_db(ua)) {
@@ -169,6 +172,15 @@ void update_slots(UAContext *ua)
    drive = get_storage_drive(ua, store);
 
    scan = find_arg(ua, NT_("scan")) >= 0;
+   if ((i=find_arg_with_value(ua, NT_("Enabled"))) >= 0) {
+      Enabled = get_enabled(ua, ua->argv[i]);
+      if (Enabled < 0) {
+         return;
+      }
+      have_enabled = true;
+   } else {
+      have_enabled = false;
+   }
 
    max_slots = get_num_slots_from_SD(ua);
    Dmsg1(100, "max_slots=%d\n", max_slots);
@@ -235,6 +247,9 @@ void update_slots(UAContext *ua)
             mr.Slot = vl->Slot;
             mr.InChanger = 1;
             mr.StorageId = store->StorageId;
+            if (have_enabled) {
+               mr.Enabled = Enabled;
+            }
             if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
                bsendmsg(ua, "%s", db_strerror(ua->db));
             } else {
index aa5d80b598fb9acb786b04921bd691ee53008914..2eaf0617e7747a8972e477433b7816c4602b8da3 100644 (file)
@@ -364,17 +364,8 @@ static void update_all_vols_from_pool(UAContext *ua)
 
 static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr)
 {
-   if (strcasecmp(val, "yes") == 0 || strcasecmp(val, "true") == 0) {
-      mr->Enabled = 1;
-   } else if (strcasecmp(val, "no") == 0 || strcasecmp(val, "false") == 0) {
-      mr->Enabled = 0;
-   } else if (strcasecmp(val, "archived") == 0) { 
-      mr->Enabled = 2;
-   } else {
-      mr->Enabled = atoi(val);
-   }
-   if (mr->Enabled < 0 || mr->Enabled > 2) {
-      bsendmsg(ua, _("Invalid Enabled, it must be 0, 1, or 2\n"));
+   mr->Enabled = get_enabled(ua, val);
+   if (mr->Enabled < 0) {
       return;
    }
    if (!db_update_media_record(ua->jcr, ua->db, mr)) {
index b15923ae6d6d12f338875d58cb86d3d3d3c3e72d..ef3500c71c921819089fa4797e9e5f43823c8ab3 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.21"
-#define BDATE   "02 Septermber 2006"
-#define LSMDATE "02Sep06"
+#define BDATE   "04 Septermber 2006"
+#define LSMDATE "04Sep06"
 #define BYEAR "2006"       /* year for copyright messages in progs */
 
 /* Debug flags */
index c35abe0968623e423b1c45eb9eab3ac59b10c126..d021daad5c1d762df0c2ad119502aa1e2aae750a 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 1.39  
 
 General:
+04Sep06
+kes  Implement Enabled on update slots.
 02Sep06
 kes  When doing a label, pass the VolBytes back to the Director,
      which puts it in the catalog.