uint32_t MaxVolJobs; /* Max Jobs on Volume */
uint32_t MaxVolFiles; /* Max files on Volume */
uint64_t MaxVolBytes; /* Max bytes on Volume */
+ DBId_t RecyclePoolId; /* RecyclePool destination when media is purged */
char PoolType[MAX_NAME_LENGTH];
char LabelFormat[MAX_NAME_LENGTH];
/* Extra stuff not in DB */
db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
bool stat;
- char ed1[30], ed2[30], ed3[50];
+ char ed1[30], ed2[30], ed3[50], ed4[50];
Dmsg0(200, "In create pool\n");
db_lock(mdb);
Mmsg(mdb->cmd,
"INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,"
"AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,"
-"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelType,LabelFormat) "
-"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s',%d,'%s')",
+"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId) "
+"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s',%d,'%s',%s)",
pr->Name,
pr->NumVols, pr->MaxVols,
pr->UseOnce, pr->UseCatalog,
edit_uint64(pr->VolUseDuration, ed2),
pr->MaxVolJobs, pr->MaxVolFiles,
edit_uint64(pr->MaxVolBytes, ed3),
- pr->PoolType, pr->LabelType, pr->LabelFormat);
+ pr->PoolType, pr->LabelType, pr->LabelFormat,
+ edit_int64(pr->RecyclePoolId,ed4));
Dmsg1(200, "Create Pool: %s\n", mdb->cmd);
if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"),
Mmsg(mdb->cmd,
"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-"MaxVolBytes,PoolType,LabelType,LabelFormat FROM Pool WHERE Pool.PoolId=%s",
+"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.PoolId=%s",
edit_int64(pdbr->PoolId, ed1));
} else { /* find by name */
Mmsg(mdb->cmd,
"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-"MaxVolBytes,PoolType,LabelType,LabelFormat FROM Pool WHERE Pool.Name='%s'",
+"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.Name='%s'",
pdbr->Name);
}
bstrncpy(pdbr->PoolType, row[14]!=NULL?row[14]:"", sizeof(pdbr->PoolType));
pdbr->LabelType = str_to_int64(row[15]);
bstrncpy(pdbr->LabelFormat, row[16]!=NULL?row[16]:"", sizeof(pdbr->LabelFormat));
+ pdbr->RecyclePoolId = str_to_int64(row[17]);
ok = true;
}
}
db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
int stat;
- char ed1[50], ed2[50], ed3[50], ed4[50];
+ char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
db_lock(mdb);
Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s",
"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d,"
"AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s',"
"MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d,"
-"AutoPrune=%d,LabelType=%d,LabelFormat='%s' WHERE PoolId=%s",
+"AutoPrune=%d,LabelType=%d,LabelFormat='%s',RecyclePoolId=%s WHERE PoolId=%s",
pr->NumVols, pr->MaxVols, pr->UseOnce, pr->UseCatalog,
pr->AcceptAnyVolume, edit_uint64(pr->VolRetention, ed1),
edit_uint64(pr->VolUseDuration, ed2),
pr->MaxVolJobs, pr->MaxVolFiles,
edit_uint64(pr->MaxVolBytes, ed3),
pr->Recycle, pr->AutoPrune, pr->LabelType,
- pr->LabelFormat,
+ pr->LabelFormat, edit_int64(pr->RecyclePoolId,ed5),
ed4);
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
{"storage", store_alist_res, ITEM(res_pool.storage), R_STORAGE, 0, 0},
{"autoprune", store_bool, ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true},
{"recycle", store_bool, ITEM(res_pool.Recycle), 0, ITEM_DEFAULT, true},
-// {"recyclepool", store_res, ITEM(res_pool.RecyclePool), R_POOL, 0, 0},
+ {"recyclepool", store_res, ITEM(res_pool.RecyclePool), R_POOL, 0, 0},
{NULL, NULL, {0}, 0, 0, 0}
};
edit_uint64(res->res_pool.MigrationHighBytes, ed2),
edit_uint64(res->res_pool.MigrationLowBytes, ed3));
if (res->res_pool.NextPool) {
- sendit(sock, _(" NextPool=%s\n"), res->res_pool.NextPool->hdr.name);
+ sendit(sock, _(" NextPool=%s\n"), res->res_pool.NextPool->name());
+ }
+ if (res->res_pool.RecyclePool) {
+ sendit(sock, _(" RecyclePool=%s\n"), res->res_pool.RecyclePool->name());
}
if (res->res_pool.storage) {
STORE *store;
}
/* Explicitly copy resource pointers from this pass (res_all) */
res->res_pool.NextPool = res_all.res_pool.NextPool;
+ res->res_pool.RecyclePool = res_all.res_pool.RecyclePool;
res->res_pool.storage = res_all.res_pool.storage;
break;
case R_CONSOLE:
bool recycle_current_volume; /* attempt recycle of current volume */
bool AutoPrune; /* default for pool auto prune */
bool Recycle; /* default for media recycle yes/no */
-
+ POOL *RecyclePool; /* RecyclePool destination when media is purged */
/* Methods */
char *name() const;
};
};
int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op);
void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr);
+bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool);
void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op);
/* ua_input.c */
mr->Recycle = pr->Recycle;
mr->VolRetention = pr->VolRetention;
mr->VolUseDuration = pr->VolUseDuration;
+ mr->RecyclePoolId = pr->RecyclePoolId;
mr->MaxVolJobs = pr->MaxVolJobs;
mr->MaxVolFiles = pr->MaxVolFiles;
mr->MaxVolBytes = pr->MaxVolBytes;
* 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 (updage).
+ * simply bringing it into agreement with the resource (update).
+ *
+ * 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)
{
}
}
+bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool)
+{
+ POOL_DBR rpool;
+ bool ret = true;
+
+ if (pool->RecyclePool) {
+ memset(&rpool, 0, sizeof(POOL_DBR));
+
+ bstrncpy(rpool.Name, pool->RecyclePool->name(), sizeof(rpool.Name));
+ if (db_get_pool_record(jcr, db, &rpool)) {
+ 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;
+ }
+ } else { /* no RecyclePool used, set it to 0 */
+ pr->RecyclePoolId = 0;
+ }
+ return ret;
+}
/*
* Create a pool record from a given Pool resource
}
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 */
}
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) {