[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bacula-devel] Patch: Update Volume Command


Kern Sibbald wrote:
On Friday 29 February 2008 00.33:23 Allan Black wrote:
Eric Bollengier wrote:
Good idea, but it would be much greater if this option was available in
user interface (menu). Direct command line is always
optional/obscure/undocumented.

OK, I have done that, and the patch is attached.

update -> Volume -> RecyclePool
1. Default
2. Scratch
3. ...
4. *None*     <----

[ Anyone have any preferences for where the *None* choice goes?
  Beginning or end? :-) ]

My preference is the beginning.

And so was mine, which was why I asked in the first place :-)

What happens with the patch applied is this:

*up
Update choice:
   1: Volume parameters
   2: Pool from resource
   3: Slots from autochanger
Choose catalog item to update (1-3): 1
Parameters to modify:
   1: Volume Status
   2: Volume Retention Period
   3: Volume Use Duration
   4: Maximum Volume Jobs
   5: Maximum Volume Files
   6: Maximum Volume Bytes
   7: Recycle Flag
   8: Slot
   9: InChanger Flag
  10: Volume Files
  11: Pool
  12: Volume from Pool
  13: All Volumes from Pool
  14: All Volumes from all Pools
  15: Enabled
  16: RecyclePool
  17: Done
Select parameter to modify (1-17): 16
Defined Pools:
   1: Default
   2: Full
   3: Inc
   4: Scratch
Select the Pool (1-4): 2
+---------+---------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+
| MediaId | VolumeName | VolStatus | Enabled | VolBytes | VolFiles | VolRetention | Recycle | Slot | InChanger | MediaType | LastWritten |
+---------+---------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+
| 1 | TestVolume001 | Append | 1 | 199 | 0 | 31,536,000 | 1 | 1 | 1 | DDS-4 | 0000-00-00 00:00:00 |
+---------+---------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+
Enter MediaId or Volume name: 1
Updating Volume "TestVolume001"
No current RecyclePool
Defined Pools:
   1: *none*
   2: Default
   3: Full
   4: Inc
   5: Scratch
Select the Pool (1-5):

The main difference here is that the prompt
	Enter new RecyclePool name:
has gone and the menu of valid pools appears immediately.

I had to remove the free-form prompt because hitting return in
response to this prompt was being interpreted as "no recyclepool",
which meant that the only way to get to the menu was deliberately
to enter an invalid pool name. (This happens because it was the
same code that interpreted both the response to the prompt, and
the recyclepool="" value.)

Previously, you had to hit return in response to the prompt to get
the menu of pools to use as RecyclePool.

Allan
Index: src/dird/ua_update.c
===================================================================
--- src/dird/ua_update.c	(revision 6530)
+++ src/dird/ua_update.c	(working copy)
@@ -333,15 +333,23 @@
 {
    POOL_DBR pr;
    POOL_MEM query(PM_MESSAGE);
-   char ed1[50], ed2[50];
+   char ed1[50], ed2[50], *poolname;
 
-   memset(&pr, 0, sizeof(pr));
-   bstrncpy(pr.Name, val, sizeof(pr.Name));
-   if (!get_pool_dbr(ua, &pr, NT_("recyclepool"))) {
-      return;
-   }
-   /* pool = select_pool_resource(ua);  */
-   mr->RecyclePoolId = pr.PoolId;            /* get the PoolId */
+   if(val != NULL && *val != '\0') {
+     /* If a pool name is given, look up the PoolId */
+     memset(&pr, 0, sizeof(pr));
+     bstrncpy(pr.Name, val, sizeof(pr.Name));
+     if (!get_pool_dbr(ua, &pr, NT_("recyclepool"))) {
+        return;
+     }
+     /* pool = select_pool_resource(ua);  */
+     mr->RecyclePoolId = pr.PoolId;            /* get the PoolId */
+     poolname = pr.Name;
+  } else {
+    /* If no pool name is given, set the PoolId to 0 (the default) */
+     mr->RecyclePoolId = 0;
+     poolname = "none";
+  }
 
    db_lock(ua->db);
    Mmsg(query, "UPDATE Media SET RecyclePoolId=%s WHERE MediaId=%s",
@@ -349,7 +357,7 @@
    if (!db_sql_query(ua->db, query.c_str(), NULL, NULL)) {
       ua->error_msg("%s", db_strerror(ua->db));
    } else {
-      ua->info_msg(_("New RecyclePool is: %s\n"), pr.Name);
+      ua->info_msg(_("New RecyclePool is: %s\n"), poolname);
    }
    db_unlock(ua->db);
 }
@@ -763,12 +771,12 @@
          if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
             ua->info_msg(_("Current RecyclePool is: %s\n"), pr.Name);
          } else {
-            ua->warning_msg(_("No current RecyclePool\n"));
+            ua->info_msg(_("No current RecyclePool\n"));
          }
-         if (!get_cmd(ua, _("Enter new RecyclePool name: "))) {
-            return 0;
-         }
-         update_vol_recyclepool(ua, ua->cmd, &mr);
+	 if (!select_pool_dbr(ua, &pr, NT_("recyclepool"))) {
+	    return 0;
+	 }
+         update_vol_recyclepool(ua, pr.Name, &mr);
          return 1;
 
       default:                        /* Done or error */
Index: src/dird/ua_select.c
===================================================================
--- src/dird/ua_select.c	(revision 6530)
+++ src/dird/ua_select.c	(working copy)
@@ -494,6 +494,9 @@
    }
 
    start_prompt(ua, _("Defined Pools:\n"));
+   if (bstrcmp(argk, NT_("recyclepool"))) {
+      add_prompt(ua, _("*none*"));
+   }
    for (i=0; i < num_pools; i++) {
       opr.PoolId = ids[i];
       if (!db_get_pool_record(ua->jcr, ua->db, &opr) ||
@@ -506,13 +509,21 @@
    if (do_prompt(ua, _("Pool"),  _("Select the Pool"), name, sizeof(name)) < 0) {
       return false;
    }
+
    memset(&opr, 0, sizeof(opr));
-   bstrncpy(opr.Name, name, sizeof(opr.Name));
+   /* *none* is only returned when selecting a recyclepool, and in that case
+    * the calling code is only interested in opr.Name, so then we can leave
+    * pr as all zero.
+    */
+   if (strcmp(name, _("*none*")) != 0) {
+     bstrncpy(opr.Name, name, sizeof(opr.Name));
 
-   if (!db_get_pool_record(ua->jcr, ua->db, &opr)) {
-      ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db));
-      return false;
+     if (!db_get_pool_record(ua->jcr, ua->db, &opr)) {
+        ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db));
+        return false;
+     }
    }
+
    memcpy(pr, &opr, sizeof(opr));
    return true;
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.