MaxVolBytes BIGINT UNSIGNED NOT NULL,
VolCapacityBytes BIGINT UNSIGNED NOT NULL,
VolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',
- 'Read-Only', 'Disabled', 'Error', 'Busy', 'Used') NOT NULL,
+ 'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,
Recycle TINYINT NOT NULL,
VolRetention BIGINT UNSIGNED NOT NULL,
VolUseDuration BIGINT UNSIGNED NOT NULL,
{"description", store_str, ITEM(res_pool.hdr.desc), 0, 0, 0},
{"pooltype", store_strname, ITEM(res_pool.pool_type), 0, ITEM_REQUIRED, 0},
{"labelformat", store_strname, ITEM(res_pool.label_format), 0, 0, 0},
+ {"cleaningprefix", store_strname, ITEM(res_pool.cleaning_prefix), 0, 0, 0},
{"usecatalog", store_yesno, ITEM(res_pool.use_catalog), 1, ITEM_DEFAULT, 1},
{"usevolumeonce", store_yesno, ITEM(res_pool.use_volume_once), 1, 0, 0},
{"recycleoldestvolume", store_yesno, ITEM(res_pool.recycle_oldest_volume), 1, 0, 0},
res->res_pool.VolRetention);
sendit(sock, " recycle=%d LabelFormat=%s\n", res->res_pool.Recycle,
NPRT(res->res_pool.label_format));
+ sendit(sock, " CleaningPrefix=%s\n",
+ NPRT(res->res_pool.cleaning_prefix));
sendit(sock, " recyleOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
res->res_pool.recycle_oldest_volume,
res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
if (res->res_pool.label_format) {
free(res->res_pool.label_format);
}
+ if (res->res_pool.cleaning_prefix) {
+ free(res->res_pool.cleaning_prefix);
+ }
break;
case R_SCHEDULE:
if (res->res_sch.run) {
static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
POOL_DBR *pr, int relabel);
static vol_list_t *get_slot_list_from_SD(UAContext *ua);
+static int is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr);
/*
vol_list = get_slot_list_from_SD(ua);
-
if (!vol_list) {
bsendmsg(ua, _("No Volumes found to label, or no barcodes.\n"));
goto bail_out;
vl->Slot, mr.VolumeName);
continue;
}
+ if (is_cleaning_tape(ua, &mr, &pr)) {
+ set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
+ if (db_create_media_record(ua->jcr, ua->db, &mr)) {
+ bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
+ mr.VolumeName);
+ } else {
+ bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
+ }
+ continue;
+ }
bstrncpy(mr.MediaType, store->media_type, sizeof(mr.MediaType));
if (ua->jcr->store_bsock) {
bnet_sig(ua->jcr->store_bsock, BNET_TERMINATE);
} else {
bnet_fsend(sd, _("label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d"),
dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot);
- bsendmsg(ua, _("Sending label command for Volume \"%s\" ...\n"), mr->VolumeName);
+ bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"),
+ mr->VolumeName, mr->Slot);
Dmsg5(200, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d\n",
dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot);
}
if (ok) {
set_pool_dbr_defaults_in_media_dbr(mr, pr);
if (db_create_media_record(ua->jcr, ua->db, mr)) {
- bsendmsg(ua, _("Media record for Volume \"%s\" successfully created.\n"),
- mr->VolumeName);
+ bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d successfully created.\n"),
+ mr->VolumeName, mr->Slot);
} else {
bsendmsg(ua, "%s", db_strerror(ua->db));
ok = FALSE;
}
return vol_list;
}
+
+/*
+ * Check if this is a cleaning tape by comparing the Volume name
+ * with the Cleaning Prefix. If they match, this is a cleaning
+ * tape.
+ */
+static int is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr)
+{
+ if (!ua->jcr->pool) {
+ /* Find Pool resource */
+ ua->jcr->pool = (POOL *)GetResWithName(R_POOL, pr->Name);
+ if (!ua->jcr->pool) {
+ bsendmsg(ua, _("Pool %s resource not found!\n"), pr->Name);
+ return 1;
+ }
+ }
+ if (ua->jcr->pool->cleaning_prefix == NULL) {
+ return 0;
+ }
+ return strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix,
+ strlen(ua->jcr->pool->cleaning_prefix)) == 0;
+}