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

[Bacula-devel] Patch: Update Volume Command


Hi,

The RecyclePoolId field in the Media table has a default value
of 0, which means the pool should be left unchanged when the volume
is recycled.

Currently, if RecyclePoolId is changed, there is no way to change it
back to zero again using the director (it can be done by changing the
database table, of course).

The attached patch makes the director accept e.g.

update volume=volumename recyclepool=""

to set RecyclePoolId to 0.

Allan

Index: src/dird/ua_update.c
===================================================================
--- src/dird/ua_update.c	(revision 6502)
+++ 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,7 +771,7 @@
          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;
-------------------------------------------------------------------------
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 Copilot Consulting.