use anyhow::{bail, Error};
use serde_json::Value;
-use proxmox::{
- api::{
- api,
- cli::*,
- RpcEnvironment,
- },
- tools::Uuid,
+use proxmox_router::{cli::*, RpcEnvironment};
+use proxmox_schema::api;
+use proxmox_uuid::Uuid;
+
+use pbs_api_types::{
+ Fingerprint, LTO_DRIVE_PATH_SCHEMA, DRIVE_NAME_SCHEMA, TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
+ MEDIA_SET_UUID_SCHEMA, LtoTapeDrive,
};
-use pbs_api_types::Fingerprint;
+use pbs_tape::linux_list_drives::{open_lto_tape_device, check_tape_is_lto_tape_device};
use proxmox_backup::{
- config,
- api2::types::{
- LTO_DRIVE_PATH_SCHEMA,
- DRIVE_NAME_SCHEMA,
- TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
- MEDIA_SET_UUID_SCHEMA,
- LtoTapeDrive,
- },
tape::{
drive::{
TapeDriver,
LtoTapeHandle,
- open_lto_tape_device,
- check_tape_is_lto_tape_device,
+ open_lto_tape_drive,
},
},
};
fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
let handle = if let Some(name) = param["drive"].as_str() {
- let (config, _digest) = config::drive::config()?;
- let drive: LtoTapeDrive = config.lookup("lto", &name)?;
+ let (config, _digest) = pbs_config::drive::config()?;
+ let drive: LtoTapeDrive = config.lookup("lto", name)?;
eprintln!("using device {}", drive.path);
- drive.open()?
+ open_lto_tape_drive(&drive)?
} else if let Some(device) = param["device"].as_str() {
eprintln!("using device {}", device);
- LtoTapeHandle::new(open_lto_tape_device(&device)?)?
+ LtoTapeHandle::new(open_lto_tape_device(device)?)?
} else if let Some(true) = param["stdin"].as_bool() {
eprintln!("using stdin");
let fd = std::io::stdin().as_raw_fd();
check_tape_is_lto_tape_device(&file)?;
LtoTapeHandle::new(file)?
} else if let Ok(name) = std::env::var("PROXMOX_TAPE_DRIVE") {
- let (config, _digest) = config::drive::config()?;
+ let (config, _digest) = pbs_config::drive::config()?;
let drive: LtoTapeDrive = config.lookup("lto", &name)?;
eprintln!("using device {}", drive.path);
- drive.open()?
+ open_lto_tape_drive(&drive)?
} else {
- let (config, _digest) = config::drive::config()?;
+ let (config, _digest) = pbs_config::drive::config()?;
let mut drive_names = Vec::new();
for (name, (section_type, _)) in config.sections.iter() {
if drive_names.len() == 1 {
let name = drive_names[0];
- let drive: LtoTapeDrive = config.lookup("lto", &name)?;
+ let drive: LtoTapeDrive = config.lookup("lto", name)?;
eprintln!("using device {}", drive.path);
- drive.open()?
+ open_lto_tape_drive(&drive)?
} else {
bail!("no drive/device specified");
}
param: Value,
) -> Result<(), Error> {
- let result = proxmox::try_block!({
+ let result = proxmox_lang::try_block!({
let mut handle = get_tape_handle(¶m)?;
match (fingerprint, uuid) {