-/*
- *
- * Bacula Director -- Update command processing
- * Split from ua_cmds.c March 2005
- *
- * Kern Sibbald, September MM
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Director -- Update command processing
+ * Split from ua_cmds.c March 2005
+ *
+ * Kern Sibbald, September MM
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "dird.h"
NT_("slots"), /* 3 */
NULL};
- if (!open_db(ua)) {
+ if (!open_client_db(ua)) {
return 1;
}
NT_("Cleaning"),
NT_("Recycle"),
NT_("Read-Only"),
+ NT_("Error"),
NULL};
bool found = false;
int i;
}
/* Modify the Pool in which this Volume is located */
-static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr)
+void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr)
{
POOL_DBR pr;
POOLMEM *query;
free_pool_memory(query);
}
+/* Modify the RecyclePool of a Volume */
+void update_vol_recyclepool(UAContext *ua, char *val, MEDIA_DBR *mr)
+{
+ POOL_DBR pr;
+ POOLMEM *query;
+ char ed1[50], ed2[50];
+
+ 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 */
+
+ query = get_pool_memory(PM_MESSAGE);
+ db_lock(ua->db);
+ Mmsg(query, "UPDATE Media SET RecyclePoolId=%s WHERE MediaId=%s",
+ edit_int64(mr->RecyclePoolId, ed1),
+ edit_int64(mr->MediaId, ed2));
+ if (!db_sql_query(ua->db, query, NULL, NULL)) {
+ bsendmsg(ua, "%s", db_strerror(ua->db));
+ } else {
+ bsendmsg(ua, _("New RecyclePool is: %s\n"), pr.Name);
+ }
+ db_unlock(ua->db);
+ free_pool_memory(query);
+}
+
/*
* Refresh the Volume information from the Pool record
*/
_("FromPool"), /* 10 */
_("AllFromPool"), /* 11 !!! see below !!! */
_("Enabled"), /* 12 */
+ _("RecyclePool"), /* 13 */
NULL };
#define AllFromPool 11 /* keep this updated with above */
case 12:
update_volenabled(ua, ua->argv[j], &mr);
break;
+ case 13:
+ update_vol_recyclepool(ua, ua->argv[j], &mr);
+ break;
}
done = true;
}
add_prompt(ua, _("Volume from Pool")); /* 11 */
add_prompt(ua, _("All Volumes from Pool")); /* 12 */
add_prompt(ua, _("Enabled")), /* 13 */
- add_prompt(ua, _("Done")); /* 14 */
+ add_prompt(ua, _("RecyclePool")), /* 14 */
+ add_prompt(ua, _("Done")); /* 15 */
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 != 14) {
+ if (i != 12 && i != 15) {
if (!select_media_dbr(ua, &mr)) { /* Get Volume record */
return 0;
}
update_volenabled(ua, ua->cmd, &mr);
break;
+ case 14:
+ memset(&pr, 0, sizeof(POOL_DBR));
+ pr.PoolId = mr.RecyclePoolId;
+ if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
+ bsendmsg(ua, _("Current RecyclePool is: %s\n"), pr.Name);
+ } else {
+ bsendmsg(ua, _("No current RecyclePool\n"));
+ }
+ if (!get_cmd(ua, _("Enter new RecyclePool name: "))) {
+ return 0;
+ }
+ update_vol_recyclepool(ua, ua->cmd, &mr);
+ return 1;
+
default: /* Done or error */
bsendmsg(ua, _("Selection terminated.\n"));
return 1;
}
set_pooldbr_from_poolres(&pr, pool, POOL_OP_UPDATE); /* update */
+ set_pooldbr_recyclepoolid(ua->jcr, ua->db, &pr, pool);
id = db_update_pool_record(ua->jcr, ua->db, &pr);
if (id <= 0) {