-/*
- *
- * Bacula Director -- User Agent Commands
- *
- * 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 -- User Agent Commands
+ *
+ * Kern Sibbald, September MM
+ *
+ * Version $Id$
+ */
+
#include "bacula.h"
#include "dird.h"
{
unsigned int i;
int len, stat;
+ bool ok = false;
bool found = false;
+ BSOCK *user = ua->UA_sock;
stat = 1;
!acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
break;
}
- stat = (*commands[i].func)(ua, cmd); /* go execute command */
+ if (ua->api) user->signal(BNET_CMD_BEGIN);
+ ok = (*commands[i].func)(ua, cmd); /* go execute command */
found = true;
break;
}
}
if (!found) {
- bnet_fsend(ua->UA_sock, _("%s: is an invalid command.\n"), ua->argk[0]);
+ user->fsend(_("%s: is an invalid command.\n"), ua->argk[0]);
}
- return stat;
+ if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED);
+ return ok;
}
/*
* Pool DB base record from a Pool Resource. We handle
* the setting of MaxVols and NumVols slightly differently
* depending on if we are creating the Pool or we are
- * simply bringing it into agreement with the resource (update).
+ * simply bringing it into agreement with the resource (updage).
*
* Caution : RecyclePoolId isn't setup in this function.
* You can use set_pooldbr_recyclepoolid();
- *
+ *
*/
void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op)
{
}
}
+/* set/update Pool.RecyclePoolId in Catalog */
+int update_pool_recyclepool(JCR *jcr, B_DB *db, POOL *pool)
+{
+ POOL_DBR pr;
+
+ if (!pool->RecyclePool) {
+ return 1;
+ }
+
+ memset(&pr, 0, sizeof(POOL_DBR));
+ bstrncpy(pr.Name, pool->name(), sizeof(pr.Name));
+
+ if (!db_get_pool_record(jcr, db, &pr)) {
+ return -1; /* not exists in database */
+ }
+
+ set_pooldbr_from_poolres(&pr, pool, POOL_OP_UPDATE);
+
+ if (!set_pooldbr_recyclepoolid(jcr, db, &pr, pool)) {
+ return -1; /* error */
+ }
+
+ if (!db_update_pool_record(jcr, db, &pr)) {
+ return -1; /* error */
+ }
+ return 1;
+}
+
+/* set POOL_DBR.RecyclePoolId from Pool resource
+ * works with set_pooldbr_from_poolres
+ */
bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool)
{
POOL_DBR rpool;
bstrncpy(rpool.Name, pool->RecyclePool->name(), sizeof(rpool.Name));
if (db_get_pool_record(jcr, db, &rpool)) {
- pr->RecyclePoolId = rpool.PoolId;
+ pr->RecyclePoolId = rpool.PoolId;
} else {
- Jmsg(jcr, M_WARNING, 0,
- _("Can't set %s RecyclePool to %s, %s is not in database, try to update it with 'update pool=%s'\n"),pool->name(),rpool.Name, rpool.Name,pool->name());
-
- ret = false;
+ Jmsg(jcr, M_WARNING, 0,
+ _("Can't set %s RecyclePool to %s, %s is not in database.\n" \
+ "Try to update it with 'update pool=%s'\n"),
+ pool->name(), rpool.Name, rpool.Name,pool->name());
+
+ ret = false;
}
- } else { /* no RecyclePool used, set it to 0 */
+ } else { /* no RecyclePool used, set it to 0 */
pr->RecyclePoolId = 0;
}
return ret;
}
+
/*
* Create a pool record from a given Pool resource
* Also called from backup.c
}
set_pooldbr_from_poolres(&pr, pool, op);
- set_pooldbr_recyclepoolid(jcr, db, &pr, pool);
if (!db_create_pool_record(jcr, db, &pr)) {
return -1; /* error */
int quit_cmd(UAContext *ua, const char *cmd)
{
- ua->quit = TRUE;
+ ua->quit = true;
return 1;
}