tape: implement MediaPool flag to consider offline media
For standalone tape drives.
This commit is contained in:
@ -109,9 +109,11 @@ fn backup_worker(
|
||||
let _lock = MediaPool::lock(status_path, &pool_config.name)?;
|
||||
|
||||
worker.log("update media online status");
|
||||
update_media_online_status(&pool_config.drive)?;
|
||||
let has_changer = update_media_online_status(&pool_config.drive)?;
|
||||
|
||||
let pool = MediaPool::with_config(status_path, &pool_config)?;
|
||||
let use_offline_media = !has_changer;
|
||||
|
||||
let pool = MediaPool::with_config(status_path, &pool_config, use_offline_media)?;
|
||||
|
||||
let mut pool_writer = PoolWriter::new(pool, &pool_config.drive)?;
|
||||
|
||||
@ -138,12 +140,16 @@ fn backup_worker(
|
||||
}
|
||||
|
||||
// Try to update the the media online status
|
||||
fn update_media_online_status(drive: &str) -> Result<(), Error> {
|
||||
fn update_media_online_status(drive: &str) -> Result<bool, Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
let mut has_changer = false;
|
||||
|
||||
if let Ok(Some((changer, changer_name))) = media_changer(&config, drive) {
|
||||
|
||||
has_changer = true;
|
||||
|
||||
let changer_id_list = changer.list_media_changer_ids()?;
|
||||
|
||||
let status_path = Path::new(TAPE_STATUS_DIR);
|
||||
@ -159,7 +165,7 @@ fn update_media_online_status(drive: &str) -> Result<(), Error> {
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(has_changer)
|
||||
}
|
||||
|
||||
pub fn backup_snapshot(
|
||||
|
@ -81,7 +81,8 @@ pub async fn list_media(pool: Option<String>) -> Result<Vec<MediaListEntry>, Err
|
||||
|
||||
let config: MediaPoolConfig = config.lookup("pool", pool_name)?;
|
||||
|
||||
let pool = MediaPool::with_config(status_path, &config)?;
|
||||
let use_offline_media = true; // does not matter here
|
||||
let pool = MediaPool::with_config(status_path, &config, use_offline_media)?;
|
||||
|
||||
let current_time = proxmox::tools::time::epoch_i64();
|
||||
|
||||
|
Reference in New Issue
Block a user