update to proxmox-sys 0.2 crate

- imported pbs-api-types/src/common_regex.rs from old proxmox crate
- use hex crate to generate/parse hex digest
- remove all reference to proxmox crate (use proxmox-sys and
  proxmox-serde instead)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer
2021-11-23 17:57:00 +01:00
parent bd00ff10e4
commit 25877d05ac
201 changed files with 627 additions and 1535 deletions

View File

@ -23,7 +23,7 @@ use pbs_api_types::{
Fingerprint, MamAttribute, LtoDriveAndMediaStatus, LtoTapeDrive, Lp17VolumeStatistics,
};
use pbs_config::key_config::KeyConfig;
use pbs_tools::run_command;
use proxmox_sys::command::run_command;
use pbs_tape::{
TapeWrite, TapeRead, BlockReadError, MediaContentHeader,
sg_tape::{SgTape, TapeAlertFlags},

View File

@ -13,21 +13,18 @@ use serde_json::Value;
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
use proxmox::{
tools::{
fs::{
lock_file,
atomic_open_or_create_file,
file_read_optional_string,
replace_file,
CreateOptions,
}
},
use proxmox_sys::fs::{
lock_file,
atomic_open_or_create_file,
file_read_optional_string,
replace_file,
CreateOptions,
};
use proxmox_io::ReadExt;
use proxmox_section_config::SectionConfigData;
use proxmox_uuid::Uuid;
use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
use proxmox_sys::{task_log, WorkerTaskContext};
use pbs_api_types::{VirtualTapeDrive, LtoTapeDrive, Fingerprint};
use pbs_config::key_config::KeyConfig;
@ -602,7 +599,7 @@ pub struct DeviceLockGuard(std::fs::File);
// Uses systemd escape_unit to compute a file name from `device_path`, the try
// to lock `/var/lock/<name>`.
fn open_device_lock(device_path: &str) -> Result<std::fs::File, Error> {
let lock_name = proxmox::tools::systemd::escape_unit(device_path, true);
let lock_name = proxmox_sys::systemd::escape_unit(device_path, true);
let mut path = std::path::PathBuf::from(crate::tape::DRIVE_LOCK_DIR);
path.push(lock_name);

View File

@ -6,7 +6,7 @@ use std::io;
use anyhow::{bail, format_err, Error};
use serde::{Serialize, Deserialize};
use proxmox::tools::{
use proxmox_sys::{
fs::{replace_file, CreateOptions},
};
@ -48,7 +48,7 @@ pub fn open_virtual_tape_drive(config: &VirtualTapeDrive) -> Result<VirtualTapeH
let options = CreateOptions::new();
let timeout = std::time::Duration::new(10, 0);
let lock = proxmox::tools::fs::open_file_locked(&lock_path, timeout, true, options)?;
let lock = proxmox_sys::fs::open_file_locked(&lock_path, timeout, true, options)?;
Ok(VirtualTapeHandle {
_lock: lock,
@ -104,7 +104,7 @@ impl VirtualTapeHandle {
fn load_tape_index(&self, tape_name: &str) -> Result<TapeIndex, Error> {
let path = self.tape_index_path(tape_name);
let raw = proxmox::tools::fs::file_get_contents(&path)?;
let raw = proxmox_sys::fs::file_get_contents(&path)?;
if raw.is_empty() {
return Ok(TapeIndex { files: 0 });
}
@ -147,7 +147,7 @@ impl VirtualTapeHandle {
current_tape: None,
})?;
let data = proxmox::tools::fs::file_get_json(&path, Some(default))?;
let data = proxmox_sys::fs::file_get_json(&path, Some(default))?;
let status: VirtualDriveStatus = serde_json::from_value(data)?;
Ok(status)
}
@ -309,7 +309,7 @@ impl TapeDriver for VirtualTapeHandle {
Ok(Box::new(reader))
}
None => {
return Err(BlockReadError::Error(proxmox::io_format_err!("drive is empty (no tape loaded).")));
return Err(BlockReadError::Error(proxmox_sys::io_format_err!("drive is empty (no tape loaded).")));
}
}
}
@ -362,7 +362,7 @@ impl TapeDriver for VirtualTapeHandle {
Ok(writer)
}
None => proxmox::io_bail!("drive is empty (no tape loaded)."),
None => proxmox_sys::io_bail!("drive is empty (no tape loaded)."),
}
}