]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/project-allvols.patch
ebl fix #946 about config test mode which was broken.
[bacula/bacula] / bacula / patches / testing / project-allvols.patch
1 Index: src/dird/ua_update.c
2 ===================================================================
3 --- src/dird/ua_update.c        (revision 5406)
4 +++ src/dird/ua_update.c        (working copy)
5 @@ -402,6 +402,42 @@
6     }
7  }
8  
9 +static void update_all_vols(UAContext *ua)
10 +{
11 +   int i, num_pools;
12 +   uint32_t *ids;
13 +   POOL_DBR pr;
14 +   MEDIA_DBR mr;
15 +
16 +   memset(&pr, 0, sizeof(pr));
17 +   memset(&mr, 0, sizeof(mr));
18 +   
19 +   if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) {
20 +      ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db));
21 +      return;
22 +   }
23 +
24 +   for (i=0; i<num_pools; i++) {
25 +      pr.PoolId = ids[i];
26 +      if (!db_get_pool_record(ua->jcr, ua->db, &pr)) { /* ***FIXME*** use acl? */
27 +         ua->warning_msg(_("Updating all pools, but skipped PoolId=%d. ERR=%s\n"), db_strerror(ua->db));
28 +         continue;
29 +      }
30 +
31 +      set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
32 +      mr.PoolId = pr.PoolId;
33 +
34 +      if (!db_update_media_defaults(ua->jcr, ua->db, &mr)) {
35 +         ua->error_msg(_("Error updating Volume records: ERR=%s"), db_strerror(ua->db));
36 +      } else {
37 +         ua->info_msg(_("All Volume defaults updated from \"%s\" Pool record.\n"),
38 +            pr.Name);
39 +      }
40 +   }
41 +
42 +   free(ids);
43 +}
44 +
45  static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr)
46  {
47     mr->Enabled = get_enabled(ua, val);
48 @@ -455,6 +491,7 @@
49     for (i=0; kw[i]; i++) {
50        int j;
51        POOL_DBR pr;
52 +
53        if ((j=find_arg_with_value(ua, kw[i])) > 0) {
54           /* If all from pool don't select a media record */
55           if (i != AllFromPool && !select_media_dbr(ua, &mr)) {
56 @@ -514,6 +551,12 @@
57        }
58     }
59  
60 +   /* Allow user to simply update all volumes */
61 +   if (find_arg(ua, NT_("allvolume")) > 0) {
62 +      update_all_vols(ua);
63 +      return 1;
64 +   }
65 +
66     for ( ; !done; ) {
67        start_prompt(ua, _("Parameters to modify:\n"));
68        add_prompt(ua, _("Volume Status"));              /* 0 */
69 @@ -529,13 +572,15 @@
70        add_prompt(ua, _("Pool"));                       /* 10 */
71        add_prompt(ua, _("Volume from Pool"));           /* 11 */
72        add_prompt(ua, _("All Volumes from Pool"));      /* 12 */
73 -      add_prompt(ua, _("Enabled")),                    /* 13 */
74 -      add_prompt(ua, _("RecyclePool")),                /* 14 */
75 -      add_prompt(ua, _("Done"));                       /* 15 */
76 +      add_prompt(ua, _("Volumes from all Pools"));     /* 13 */
77 +      add_prompt(ua, _("Enabled")),                    /* 14 */
78 +      add_prompt(ua, _("RecyclePool")),                /* 15 */
79 +      add_prompt(ua, _("Done"));                       /* 16 */
80        i = do_prompt(ua, "", _("Select parameter to modify"), NULL, 0);  
81  
82 -      /* For All Volumes from Pool and Done, we don't need a Volume record */
83 -      if (i != 12 && i != 15) {
84 +      /* For All Volumes, All Volumes from Pool, and Done, we don't need
85 +          * a Volume record */
86 +      if ( i != 12 && i != 13 && i != 16) {
87           if (!select_media_dbr(ua, &mr)) {  /* Get Volume record */
88              return 0;
89           }
90 @@ -692,6 +737,10 @@
91           return 1;
92  
93        case 13:
94 +         update_all_vols(ua);
95 +         return 1;
96 +
97 +      case 14:
98           ua->info_msg(_("Current Enabled is: %d\n"), mr.Enabled);
99           if (!get_cmd(ua, _("Enter new Enabled: "))) {
100              return 0;
101 @@ -708,7 +757,7 @@
102           update_volenabled(ua, ua->cmd, &mr);
103           break;
104  
105 -      case 14:
106 +      case 15:
107           memset(&pr, 0, sizeof(POOL_DBR));
108           pr.PoolId = mr.RecyclePoolId;
109           if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
110 Index: src/qt-console/medialist/medialist.h
111 ===================================================================
112 --- src/qt-console/medialist/medialist.h        (revision 5406)
113 +++ src/qt-console/medialist/medialist.h        (working copy)
114 @@ -60,6 +60,7 @@
115     void pruneVolume();
116     void relabelVolume();
117     void allVolumesFromPool();
118 +   void allVolumes();
119     void volumeFromPool();
120  
121  private:
122 Index: src/qt-console/medialist/medialist.ui
123 ===================================================================
124 --- src/qt-console/medialist/medialist.ui       (revision 5406)
125 +++ src/qt-console/medialist/medialist.ui       (working copy)
126 @@ -99,6 +99,23 @@
127      <string>Update all Volumes From Pool</string>
128     </property>
129    </action>
130 +  <action name="actionAllVolumes" >
131 +   <property name="icon" >
132 +    <iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
133 +   </property>
134 +   <property name="text" >
135 +    <string>Update all Volumes from Pool</string>
136 +   </property>
137 +   <property name="iconText" >
138 +    <string>Update all Volumes from Pool</string>
139 +   </property>
140 +   <property name="toolTip" >
141 +    <string>Update all Volumes from Pool</string>
142 +   </property>
143 +   <property name="statusTip" >
144 +    <string>Update all Volumes from Pool</string>
145 +   </property>
146 +  </action>
147    <action name="actionVolumeFromPool" >
148     <property name="icon" >
149      <iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
150 Index: src/qt-console/medialist/medialist.cpp
151 ===================================================================
152 --- src/qt-console/medialist/medialist.cpp      (revision 5406)
153 +++ src/qt-console/medialist/medialist.cpp      (working copy)
154 @@ -251,6 +251,7 @@
155     /* connect to the action specific to this pages class */
156     connect(actionRefreshMediaList, SIGNAL(triggered()), this,
157                  SLOT(populateTree()));
158 +   connect(actionAllVolumes, SIGNAL(triggered()), this, SLOT(allVolumes()));
159     connect(actionAllVolumesFromPool, SIGNAL(triggered()), this, SLOT(allVolumesFromPool()));
160     connect(actionVolumeFromPool, SIGNAL(triggered()), this, SLOT(volumeFromPool()));
161  }
162 @@ -340,6 +341,13 @@
163     populateTree();
164  }
165  
166 +void MediaList::allVolumes()
167 +{
168 +   QString cmd = "update volume allvolume";
169 +   consoleCommand(cmd);
170 +   populateTree();
171 +}
172 +
173  /*
174   * Called from the signal of the context sensitive menu to purge!
175   */