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::{
api, api,
RpcEnvironment, RpcEnvironment,
RpcEnvironmentType,
Router, Router,
}, },
}; };
@ -75,11 +76,13 @@ pub fn backup(
// early check before starting worker // early check before starting worker
check_drive_exists(&drive_config, &pool_config.drive)?; 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( let upid_str = WorkerTask::new_thread(
"tape-backup", "tape-backup",
Some(store.clone()), Some(store.clone()),
auth_id, auth_id,
true, to_stdout,
move |worker| { move |worker| {
backup_worker(&worker, datastore, &pool_config)?; backup_worker(&worker, datastore, &pool_config)?;
Ok(()) Ok(())

View File

@ -13,6 +13,7 @@ use proxmox::{
api::{ api::{
api, api,
RpcEnvironment, RpcEnvironment,
RpcEnvironmentType,
Router, Router,
SubdirMap, SubdirMap,
}, },
@ -220,11 +221,13 @@ pub fn erase_media(
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; 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( let upid_str = WorkerTask::new_thread(
"erase-media", "erase-media",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |_worker| { move |_worker| {
let mut drive = open_drive(&config, &drive)?; let mut drive = open_drive(&config, &drive)?;
drive.erase_media(fast.unwrap_or(true))?; 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 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( let upid_str = WorkerTask::new_thread(
"rewind-media", "rewind-media",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |_worker| { move |_worker| {
let mut drive = open_drive(&config, &drive)?; let mut drive = open_drive(&config, &drive)?;
drive.rewind()?; drive.rewind()?;
@ -347,11 +352,13 @@ pub fn label_media(
let (config, _digest) = config::drive::config()?; let (config, _digest) = config::drive::config()?;
let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false };
let upid_str = WorkerTask::new_thread( let upid_str = WorkerTask::new_thread(
"label-media", "label-media",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |worker| { move |worker| {
let mut drive = open_drive(&config, &drive)?; 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 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( let upid_str = WorkerTask::new_thread(
"inventory-update", "inventory-update",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |worker| { move |worker| {
let (mut changer, changer_name) = required_media_changer(&config, &drive)?; 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 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( let upid_str = WorkerTask::new_thread(
"barcode-label-media", "barcode-label-media",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |worker| { move |worker| {
barcode_label_media_worker(worker, drive, pool) 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 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( let upid_str = WorkerTask::new_thread(
"catalog-media", "catalog-media",
Some(drive.clone()), Some(drive.clone()),
auth_id, auth_id,
true, to_stdout,
move |worker| { move |worker| {
let mut drive = open_drive(&config, &drive)?; let mut drive = open_drive(&config, &drive)?;