From b1bedca314058afa008043f743e6aca50bfabb50 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 17 Sep 2007 20:36:39 +0000 Subject: [PATCH] ebl Add an option to operate on all pools with update vol parameters. This complete the project 20. Patch from Nigel Stepp. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5589 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/patches/testing/project-allvols.patch | 175 ------------------ bacula/patches/testing/project-allvols.readme | 8 - bacula/src/dird/ua_update.c | 61 +++++- bacula/src/qt-console/medialist/medialist.cpp | 8 + bacula/src/qt-console/medialist/medialist.h | 1 + bacula/src/qt-console/medialist/medialist.ui | 17 ++ bacula/technotes-2.3 | 2 + 7 files changed, 83 insertions(+), 189 deletions(-) delete mode 100644 bacula/patches/testing/project-allvols.patch delete mode 100644 bacula/patches/testing/project-allvols.readme diff --git a/bacula/patches/testing/project-allvols.patch b/bacula/patches/testing/project-allvols.patch deleted file mode 100644 index 3d6e1a3f57..0000000000 --- a/bacula/patches/testing/project-allvols.patch +++ /dev/null @@ -1,175 +0,0 @@ -Index: src/dird/ua_update.c -=================================================================== ---- src/dird/ua_update.c (revision 5406) -+++ src/dird/ua_update.c (working copy) -@@ -402,6 +402,42 @@ - } - } - -+static void update_all_vols(UAContext *ua) -+{ -+ int i, num_pools; -+ uint32_t *ids; -+ POOL_DBR pr; -+ MEDIA_DBR mr; -+ -+ memset(&pr, 0, sizeof(pr)); -+ memset(&mr, 0, sizeof(mr)); -+ -+ if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { -+ ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); -+ return; -+ } -+ -+ for (i=0; ijcr, ua->db, &pr)) { /* ***FIXME*** use acl? */ -+ ua->warning_msg(_("Updating all pools, but skipped PoolId=%d. ERR=%s\n"), db_strerror(ua->db)); -+ continue; -+ } -+ -+ set_pool_dbr_defaults_in_media_dbr(&mr, &pr); -+ mr.PoolId = pr.PoolId; -+ -+ if (!db_update_media_defaults(ua->jcr, ua->db, &mr)) { -+ ua->error_msg(_("Error updating Volume records: ERR=%s"), db_strerror(ua->db)); -+ } else { -+ ua->info_msg(_("All Volume defaults updated from \"%s\" Pool record.\n"), -+ pr.Name); -+ } -+ } -+ -+ free(ids); -+} -+ - static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr) - { - mr->Enabled = get_enabled(ua, val); -@@ -455,6 +491,7 @@ - for (i=0; kw[i]; i++) { - int j; - POOL_DBR pr; -+ - if ((j=find_arg_with_value(ua, kw[i])) > 0) { - /* If all from pool don't select a media record */ - if (i != AllFromPool && !select_media_dbr(ua, &mr)) { -@@ -514,6 +551,12 @@ - } - } - -+ /* Allow user to simply update all volumes */ -+ if (find_arg(ua, NT_("fromallpools")) > 0) { -+ update_all_vols(ua); -+ return 1; -+ } -+ - for ( ; !done; ) { - start_prompt(ua, _("Parameters to modify:\n")); - add_prompt(ua, _("Volume Status")); /* 0 */ -@@ -529,13 +572,15 @@ - add_prompt(ua, _("Pool")); /* 10 */ - add_prompt(ua, _("Volume from Pool")); /* 11 */ - add_prompt(ua, _("All Volumes from Pool")); /* 12 */ -- add_prompt(ua, _("Enabled")), /* 13 */ -- add_prompt(ua, _("RecyclePool")), /* 14 */ -- add_prompt(ua, _("Done")); /* 15 */ -+ add_prompt(ua, _("All Volumes from all Pools")); /* 13 */ -+ add_prompt(ua, _("Enabled")), /* 14 */ -+ add_prompt(ua, _("RecyclePool")), /* 15 */ -+ add_prompt(ua, _("Done")); /* 16 */ - i = do_prompt(ua, "", _("Select parameter to modify"), NULL, 0); - -- /* For All Volumes from Pool and Done, we don't need a Volume record */ -- if (i != 12 && i != 15) { -+ /* For All Volumes, All Volumes from Pool, and Done, we don't need -+ * a Volume record */ -+ if ( i != 12 && i != 13 && i != 16) { - if (!select_media_dbr(ua, &mr)) { /* Get Volume record */ - return 0; - } -@@ -692,6 +737,10 @@ - return 1; - - case 13: -+ update_all_vols(ua); -+ return 1; -+ -+ case 14: - ua->info_msg(_("Current Enabled is: %d\n"), mr.Enabled); - if (!get_cmd(ua, _("Enter new Enabled: "))) { - return 0; -@@ -708,7 +757,7 @@ - update_volenabled(ua, ua->cmd, &mr); - break; - -- case 14: -+ case 15: - memset(&pr, 0, sizeof(POOL_DBR)); - pr.PoolId = mr.RecyclePoolId; - if (db_get_pool_record(ua->jcr, ua->db, &pr)) { -Index: src/qt-console/medialist/medialist.h -=================================================================== ---- src/qt-console/medialist/medialist.h (revision 5406) -+++ src/qt-console/medialist/medialist.h (working copy) -@@ -60,6 +60,7 @@ - void pruneVolume(); - void relabelVolume(); - void allVolumesFromPool(); -+ void allVolumes(); - void volumeFromPool(); - - private: -Index: src/qt-console/medialist/medialist.ui -=================================================================== ---- src/qt-console/medialist/medialist.ui (revision 5406) -+++ src/qt-console/medialist/medialist.ui (working copy) -@@ -99,6 +99,23 @@ - Update all Volumes From Pool - - -+ -+ -+ :/images/cartridge-edit.png -+ -+ -+ Update all Volumes from all Pools -+ -+ -+ Update all Volumes from all Pools -+ -+ -+ Update all Volumes from all Pools -+ -+ -+ Update all Volumes from all Pools -+ -+ - - - :/images/cartridge-edit.png -Index: src/qt-console/medialist/medialist.cpp -=================================================================== ---- src/qt-console/medialist/medialist.cpp (revision 5406) -+++ src/qt-console/medialist/medialist.cpp (working copy) -@@ -251,6 +251,7 @@ - /* connect to the action specific to this pages class */ - connect(actionRefreshMediaList, SIGNAL(triggered()), this, - SLOT(populateTree())); -+ connect(actionAllVolumes, SIGNAL(triggered()), this, SLOT(allVolumes())); - connect(actionAllVolumesFromPool, SIGNAL(triggered()), this, SLOT(allVolumesFromPool())); - connect(actionVolumeFromPool, SIGNAL(triggered()), this, SLOT(volumeFromPool())); - } -@@ -340,6 +341,13 @@ - populateTree(); - } - -+void MediaList::allVolumes() -+{ -+ QString cmd = "update volume allvolume"; -+ consoleCommand(cmd); -+ populateTree(); -+} -+ - /* - * Called from the signal of the context sensitive menu to purge! - */ diff --git a/bacula/patches/testing/project-allvols.readme b/bacula/patches/testing/project-allvols.readme deleted file mode 100644 index 30666efd05..0000000000 --- a/bacula/patches/testing/project-allvols.readme +++ /dev/null @@ -1,8 +0,0 @@ -From: Nigel Stepp - -This patch implements the all volumes project. - -*update volume allvolume - -TODO: - - wrote documentation diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index da87a02fed..2526bcd2ed 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -402,6 +402,42 @@ static void update_all_vols_from_pool(UAContext *ua, const char *pool_name) } } +static void update_all_vols(UAContext *ua) +{ + int i, num_pools; + uint32_t *ids; + POOL_DBR pr; + MEDIA_DBR mr; + + memset(&pr, 0, sizeof(pr)); + memset(&mr, 0, sizeof(mr)); + + if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { + ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); + return; + } + + for (i=0; ijcr, ua->db, &pr)) { /* ***FIXME*** use acl? */ + ua->warning_msg(_("Updating all pools, but skipped PoolId=%d. ERR=%s\n"), db_strerror(ua->db)); + continue; + } + + set_pool_dbr_defaults_in_media_dbr(&mr, &pr); + mr.PoolId = pr.PoolId; + + if (!db_update_media_defaults(ua->jcr, ua->db, &mr)) { + ua->error_msg(_("Error updating Volume records: ERR=%s"), db_strerror(ua->db)); + } else { + ua->info_msg(_("All Volume defaults updated from \"%s\" Pool record.\n"), + pr.Name); + } + } + + free(ids); +} + static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr) { mr->Enabled = get_enabled(ua, val); @@ -455,6 +491,7 @@ static int update_volume(UAContext *ua) for (i=0; kw[i]; i++) { int j; POOL_DBR pr; + if ((j=find_arg_with_value(ua, kw[i])) > 0) { /* If all from pool don't select a media record */ if (i != AllFromPool && !select_media_dbr(ua, &mr)) { @@ -514,6 +551,12 @@ static int update_volume(UAContext *ua) } } + /* Allow user to simply update all volumes */ + if (find_arg(ua, NT_("fromallpools")) > 0) { + update_all_vols(ua); + return 1; + } + for ( ; !done; ) { start_prompt(ua, _("Parameters to modify:\n")); add_prompt(ua, _("Volume Status")); /* 0 */ @@ -529,13 +572,15 @@ static int update_volume(UAContext *ua) add_prompt(ua, _("Pool")); /* 10 */ add_prompt(ua, _("Volume from Pool")); /* 11 */ add_prompt(ua, _("All Volumes from Pool")); /* 12 */ - add_prompt(ua, _("Enabled")), /* 13 */ - add_prompt(ua, _("RecyclePool")), /* 14 */ - add_prompt(ua, _("Done")); /* 15 */ + add_prompt(ua, _("All Volumes from all Pools")); /* 13 */ + add_prompt(ua, _("Enabled")), /* 14 */ + add_prompt(ua, _("RecyclePool")), /* 15 */ + add_prompt(ua, _("Done")); /* 16 */ i = do_prompt(ua, "", _("Select parameter to modify"), NULL, 0); - /* For All Volumes from Pool and Done, we don't need a Volume record */ - if (i != 12 && i != 15) { + /* For All Volumes, All Volumes from Pool, and Done, we don't need + * a Volume record */ + if ( i != 12 && i != 13 && i != 16) { if (!select_media_dbr(ua, &mr)) { /* Get Volume record */ return 0; } @@ -692,6 +737,10 @@ static int update_volume(UAContext *ua) return 1; case 13: + update_all_vols(ua); + return 1; + + case 14: ua->info_msg(_("Current Enabled is: %d\n"), mr.Enabled); if (!get_cmd(ua, _("Enter new Enabled: "))) { return 0; @@ -708,7 +757,7 @@ static int update_volume(UAContext *ua) update_volenabled(ua, ua->cmd, &mr); break; - case 14: + case 15: memset(&pr, 0, sizeof(POOL_DBR)); pr.PoolId = mr.RecyclePoolId; if (db_get_pool_record(ua->jcr, ua->db, &pr)) { diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 6cda1e5a1b..4d033d4f74 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -251,6 +251,7 @@ void MediaList::createContextMenu() /* connect to the action specific to this pages class */ connect(actionRefreshMediaList, SIGNAL(triggered()), this, SLOT(populateTree())); + connect(actionAllVolumes, SIGNAL(triggered()), this, SLOT(allVolumes())); connect(actionAllVolumesFromPool, SIGNAL(triggered()), this, SLOT(allVolumesFromPool())); connect(actionVolumeFromPool, SIGNAL(triggered()), this, SLOT(volumeFromPool())); } @@ -340,6 +341,13 @@ void MediaList::allVolumesFromPool() populateTree(); } +void MediaList::allVolumes() +{ + QString cmd = "update volume allvolume"; + consoleCommand(cmd); + populateTree(); +} + /* * Called from the signal of the context sensitive menu to purge! */ diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 823d87137c..c8cb0a5f53 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -60,6 +60,7 @@ private slots: void pruneVolume(); void relabelVolume(); void allVolumesFromPool(); + void allVolumes(); void volumeFromPool(); private: diff --git a/bacula/src/qt-console/medialist/medialist.ui b/bacula/src/qt-console/medialist/medialist.ui index b4117bb5f4..058a4f8251 100644 --- a/bacula/src/qt-console/medialist/medialist.ui +++ b/bacula/src/qt-console/medialist/medialist.ui @@ -99,6 +99,23 @@ Update all Volumes From Pool + + + :/images/cartridge-edit.png + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + :/images/cartridge-edit.png diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 0f24bd9d7c..39d628241b 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,8 @@ General: 17Sep07 +ebl Add an option to operate on all pools with update vol parameters. + This complete the project 20. Patch from Nigel Stepp. ebl Add history support to bconsole when using readline. Using Ctrl-D to exit doesn't update .bconsole_history kes Modify new volume algorithm to use max MediaId for generating next -- 2.39.5