]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Tweak bdirjson tool to work with Storage Group Policy
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Tue, 25 May 2021 16:51:16 +0000 (18:51 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:02 +0000 (09:03 +0100)
bacula/src/dird/bdirjson.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/store_mngr.h
bacula/src/lib/bjson.c
bacula/src/lib/parse_conf.c
bacula/src/lib/parse_conf.h

index 0b6bf2e681cac24af694d31775adf8e059075687..e9ec825850b13f8ce834533237a39876ad990ff9 100644 (file)
@@ -1376,6 +1376,7 @@ static bool check_resources(bool apply_jobdefs)
                 * Handle strings and directory strings
                 */
                if (job_items[i].handler == store_str ||
+                   job_items[i].handler == store_storage_mngr ||
                    job_items[i].handler == store_dir) {
                   def_svalue = (char **)((char *)(job->jobdefs) + offset);
                   Dmsg5(400, "Job \"%s\", field \"%s\" def_svalue=%s item %d offset=%u\n",
index 353897d10ab01df5b077e17df0f889d0658a405c..aa9e4f25c86925d6a516cde42f23ee61d794a2d1 100644 (file)
@@ -134,28 +134,6 @@ BSOCK *CLIENT::getBSOCK(int timeout)
    return globals->socket->get(timeout);
 }
 
-/* Store a storage group policy */
-void store_storage_mngr(LEX *lc, RES_ITEM *item, int index, int pass)
-{
-   lex_get_token(lc, T_STRING);
-   if (pass == 1) {
-      if (*(item->value)) {
-         scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"),
-            item->name, *(item->value), lc->str, lc->line_no, lc->line);
-         return;
-      }
-
-      if (!StorageManager::check_policy(lc->str)) {
-         scan_err0(lc, _("Invalid storage policy!\n"));
-         return;
-      }
-
-      *(item->value) = bstrdup(lc->str);
-   }
-   scan_to_eol(lc);
-   set_bit(index, res_all.hdr.item_present);
-}
-
 bool CLIENT::getBSOCK_state(POOLMEM *&buf)
 {
    P(globals_mutex);
index cb9e276a142b3719483d4b248000f2a72d9f5080..d434905bba9eb07c3143075749847f8e3487b34a 100644 (file)
@@ -784,9 +784,6 @@ public:
 #define GetFileSetResWithName(x) ((FILESET *)GetResWithName(R_FILESET, (x)))
 #define GetCatalogResWithName(x) ((CAT *)GetResWithName(R_CATALOG, (x)))
 
-/* Director daemon's specific */
-void store_storage_mngr(LEX *lc, RES_ITEM *item, int index, int pass);
-
 /* Imported subroutines */
 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
index 876793bfb24783dcf28a736d454e2fe894bb5a63..fd0ec7e359211bc7530252439b0308ca64b8d004 100644 (file)
 /* Forward delcaration */
 class STORE;
 
-/* Not so many policies for now...
- * Some ideas for next ones:
- *    - Round robin
- *    - Most free space
- *    - Least CPU usage
- *    - Least network usage
- *    - A lot more
- *
- * Some protocol/interface changes will be needed to query all of the storages from
- * the list about it's current status, depending of policy used.
- */
-static char const *storage_mngmt_policy[] = {
-   "LeastUsed",
-   "ListedOrder",
-   NULL
-};
 
 /*
  * Helper class to make managing each storage type (write/read) easier.
@@ -142,17 +126,6 @@ class StorageManager : public SMARTALLOC {
 
       StorageManager(const char *policy);
 
-      /* Helper to validate if policy user wants to use is a valid one */
-      static bool check_policy(const char *policy) {
-         int i = 0;
-         while (storage_mngmt_policy[i]) {
-            if (strcasecmp(policy, storage_mngmt_policy[i]) == 0) {
-               return true;
-            }
-            i++;
-         }
-         return false;
-      }
 
       /************ READ STORAGE HELPERS ************/
       STORE *get_rstore();
index 5163c90cdb1dce36dbe730deac44e873af24fcc2..8b1c34372b154205d2cac8e0a04f84503ce0fbae 100644 (file)
@@ -228,6 +228,7 @@ int display_global_item(HPKT &hpkt)
       display_res(hpkt);
    } else if (hpkt.ritem->handler == store_str ||
               hpkt.ritem->handler == store_name ||
+              hpkt.ritem->handler == store_storage_mngr ||
               hpkt.ritem->handler == store_password ||
               hpkt.ritem->handler == store_strname ||
               hpkt.ritem->handler == store_dir) {
index ab5235b02112a2585ce2cf8f4671cbddd1e95ba0..89f6631b399c5a88cb157358c4efe771d6f0c31a 100644 (file)
@@ -1003,6 +1003,56 @@ void store_coll_type(LEX *lc, RES_ITEM *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
+/* Not so many policies for now...
+ * Some ideas for next ones:
+ *    - Most free space
+ *    - Least CPU usage
+ *    - Least network usage
+ *    - ...
+ *
+ * Some protocol/interface changes will be needed to query all of the storages from
+ * the list about it's current status, depending of policy used.
+ */
+static char const *storage_mngmt_policy[] = {
+   "LeastUsed",
+   "ListedOrder",
+   NULL
+};
+
+/* Helper to validate if policy user wants to use is a valid one */
+static bool check_policy(const char *policy) {
+   int i = 0;
+   while (storage_mngmt_policy[i]) {
+      if (strcasecmp(policy, storage_mngmt_policy[i]) == 0) {
+         return true;
+      }
+      i++;
+   }
+   return false;
+}
+
+/* Store a storage group policy */
+void store_storage_mngr(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+   lex_get_token(lc, T_STRING);
+   if (pass == 1) {
+      if (*(item->value)) {
+         scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"),
+            item->name, *(item->value), lc->str, lc->line_no, lc->line);
+         return;
+      }
+
+      if (!check_policy(lc->str)) {
+         scan_err0(lc, _("Invalid storage policy!\n"));
+         return;
+      }
+
+
+      *(item->value) = bstrdup(lc->str);
+   }
+   scan_to_eol(lc);
+   set_bit(index, res_all.hdr.item_present);
+}
 
 /*
  *
index 3af72eda315cb7f245e120d1634b82189a45256e..eed3d32e2772690a2e6ca2faf21ec62ba51eea4f 100644 (file)
@@ -379,6 +379,10 @@ void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_coll_type(LEX *lc, RES_ITEM *item, int index, int pass);
 
+
+/* Director daemon's specific routines */
+void store_storage_mngr(LEX *lc, RES_ITEM *item, int index, int pass);
+
 /* ***FIXME*** eliminate these globals */
 extern int32_t r_first;
 extern int32_t r_last;