tape: only log to stdout in CLI environment

This commit is contained in:
Dietmar Maurer 2020-12-30 19:01:39 +01:00
parent 75656a78c6
commit cb022525ff
2 changed files with 23 additions and 7 deletions

View File

@ -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(())

View File

@ -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)?;