From cb022525ff8727c57af73898b00b3d2bfa19b84b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 30 Dec 2020 19:01:39 +0100 Subject: [PATCH] tape: only log to stdout in CLI environment --- src/api2/tape/backup.rs | 5 ++++- src/api2/tape/drive.rs | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index 3e8f6d4b..56667ad7 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -8,6 +8,7 @@ use proxmox::{ api::{ api, RpcEnvironment, + RpcEnvironmentType, Router, }, }; @@ -75,11 +76,13 @@ pub fn backup( // early check before starting worker check_drive_exists(&drive_config, &pool_config.drive)?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "tape-backup", Some(store.clone()), auth_id, - true, + to_stdout, move |worker| { backup_worker(&worker, datastore, &pool_config)?; Ok(()) diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 2a360710..198acab6 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -13,6 +13,7 @@ use proxmox::{ api::{ api, RpcEnvironment, + RpcEnvironmentType, Router, SubdirMap, }, @@ -220,11 +221,13 @@ pub fn erase_media( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "erase-media", Some(drive.clone()), auth_id, - true, + to_stdout, move |_worker| { let mut drive = open_drive(&config, &drive)?; drive.erase_media(fast.unwrap_or(true))?; @@ -259,11 +262,13 @@ pub fn rewind( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "rewind-media", Some(drive.clone()), auth_id, - true, + to_stdout, move |_worker| { let mut drive = open_drive(&config, &drive)?; drive.rewind()?; @@ -347,11 +352,13 @@ pub fn label_media( let (config, _digest) = config::drive::config()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "label-media", Some(drive.clone()), auth_id, - true, + to_stdout, move |worker| { let mut drive = open_drive(&config, &drive)?; @@ -604,11 +611,13 @@ pub fn update_inventory( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "inventory-update", Some(drive.clone()), auth_id, - true, + to_stdout, move |worker| { let (mut changer, changer_name) = required_media_changer(&config, &drive)?; @@ -704,11 +713,13 @@ pub fn barcode_label_media( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "barcode-label-media", Some(drive.clone()), auth_id, - true, + to_stdout, move |worker| { barcode_label_media_worker(worker, drive, pool) } @@ -883,11 +894,13 @@ pub fn catalog_media( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false }; + let upid_str = WorkerTask::new_thread( "catalog-media", Some(drive.clone()), auth_id, - true, + to_stdout, move |worker| { let mut drive = open_drive(&config, &drive)?;