update to first proxmox crate split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-10-08 11:19:37 +02:00
parent e3f3359c86
commit 6ef1b649d9
265 changed files with 880 additions and 1036 deletions

View File

@ -18,7 +18,16 @@ bitflags = "1.2.1"
regex = "1.2"
udev = ">= 0.3, <0.5"
proxmox = { version = "0.14.0", default-features = false, features = [] }
proxmox = "0.14.0"
proxmox-io = "1"
proxmox-lang = "1"
# api-macro is only used by the binaries, so maybe we should split them out
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-time = "1"
proxmox-uuid = "1"
# router::cli is only used by binaries, so maybe we should split them out
proxmox-router = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-tools = { path = "../pbs-tools" }

View File

@ -18,19 +18,9 @@ use std::convert::TryInto;
use anyhow::{bail, Error};
use serde_json::Value;
use proxmox::{
api::{
api,
cli::*,
schema::{
Schema,
IntegerSchema,
StringSchema,
ArraySchema,
},
RpcEnvironment,
},
};
use proxmox_schema::{api, ArraySchema, IntegerSchema, Schema, StringSchema};
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use pbs_api_types::{
LTO_DRIVE_PATH_SCHEMA, DRIVE_NAME_SCHEMA, LtoTapeDrive,

View File

@ -17,13 +17,9 @@ use std::fs::File;
use anyhow::{bail, Error};
use serde_json::Value;
use proxmox::{
api::{
api,
cli::*,
RpcEnvironment,
},
};
use proxmox_schema::api;
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use pbs_config::drive::complete_changer_name;
use pbs_api_types::{
@ -93,7 +89,7 @@ fn inquiry(
let output_format = get_output_format(&param);
let result: Result<_, Error> = proxmox::try_block!({
let result: Result<_, Error> = proxmox_lang::try_block!({
let mut file = get_changer_handle(&param)?;
let info = scsi_inquiry(&mut file)?;
Ok(info)
@ -281,7 +277,7 @@ fn status(
let output_format = get_output_format(&param);
let result: Result<_, Error> = proxmox::try_block!({
let result: Result<_, Error> = proxmox_lang::try_block!({
let mut file = get_changer_handle(&param)?;
let status = sg_pt_changer::read_element_status(&mut file)?;
Ok(status)

View File

@ -1,4 +1,4 @@
use proxmox::tools::vec;
use proxmox_io::vec;
use crate::{
TapeWrite,

View File

@ -1,6 +1,6 @@
use std::io::Read;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::{BlockRead, BlockReadError, PROXMOX_TAPE_BLOCK_SIZE};

View File

@ -6,8 +6,8 @@ use endian_trait::Endian;
use serde::{Serialize, Deserialize};
use serde_json::Value;
use proxmox::tools::Uuid;
use proxmox::api::schema::parse_property_string;
use proxmox_schema::parse_property_string;
use proxmox_uuid::Uuid;
use pbs_api_types::{ScsiTapeChanger, SLOT_ARRAY_SCHEMA};
@ -119,13 +119,13 @@ impl MediaContentHeader {
/// Create a new instance with autogenerated Uuid
pub fn new(content_magic: [u8; 8], size: u32) -> Self {
let uuid = *proxmox::tools::uuid::Uuid::generate()
let uuid = *Uuid::generate()
.into_inner();
Self {
magic: PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
content_magic,
uuid,
ctime: proxmox::tools::time::epoch_i64(),
ctime: proxmox_time::epoch_i64(),
size,
part_number: 0,
reserved_0: 0,

View File

@ -8,7 +8,7 @@ use std::fs::{OpenOptions, File};
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::ScsiTapeChanger;
@ -139,7 +139,7 @@ fn read_element_address_assignment<F: AsRawFd>(
let data = execute_scsi_command(&mut sg_raw, &cmd, "read element address assignment", true)?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: AddressAssignmentPage = unsafe { reader.read_be_value()? };
@ -662,7 +662,7 @@ fn decode_element_status_page(
start_element_address: u16,
) -> Result<DecodedStatusPage, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut result = DecodedStatusPage {
last_element_address: None,

View File

@ -25,10 +25,8 @@ pub use mam::*;
mod report_density;
pub use report_density::*;
use proxmox::{
sys::error::SysResult,
tools::io::{ReadExt, WriteExt},
};
use proxmox::sys::error::SysResult;
use proxmox_io::{ReadExt, WriteExt};
use pbs_api_types::{MamAttribute, Lp17VolumeStatistics, LtoDriveAndMediaStatus};
@ -386,7 +384,7 @@ impl SgTape {
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("read position failed - {}", err))?;
let page = proxmox::try_block!({
let page = proxmox_lang::try_block!({
if data.len() != expected_size {
bail!("got unexpected data len ({} != {}", data.len(), expected_size);
}
@ -793,7 +791,7 @@ impl SgTape {
let (head, block_descriptor, page): (_,_, MediumConfigurationModePage)
= scsi_mode_sense(&mut self.file, false, 0x1d, 0)?;
proxmox::try_block!({
proxmox_lang::try_block!({
if (page.page_code & 0b0011_1111) != 0x1d {
bail!("wrong page code {}", page.page_code);
}
@ -817,7 +815,7 @@ impl SgTape {
let (head, block_descriptor, page): (_,_, DataCompressionModePage)
= scsi_mode_sense(&mut self.file, false, 0x0f, 0)?;
proxmox::try_block!({
proxmox_lang::try_block!({
if (page.page_code & 0b0011_1111) != 0x0f {
bail!("wrong page code {}", page.page_code);
}

View File

@ -4,7 +4,7 @@ use std::io::Write;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::{ReadExt, WriteExt};
use proxmox_io::{ReadExt, WriteExt};
use crate::sgutils2::{SgRaw, alloc_page_aligned_buffer};
@ -216,7 +216,7 @@ struct SspDataEncryptionAlgorithmDescriptor {
// Returns the algorythm_index for AES-CGM
fn decode_spin_data_encryption_caps(data: &[u8]) -> Result<u8, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let _page: SspDataEncryptionCapabilityPage = unsafe { reader.read_be_value()? };
@ -267,7 +267,7 @@ struct SspDataEncryptionStatusPage {
fn decode_spin_data_encryption_status(data: &[u8]) -> Result<DataEncryptionStatus, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: SspDataEncryptionStatusPage = unsafe { reader.read_be_value()? };

View File

@ -5,7 +5,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::MamAttribute;
@ -211,7 +211,7 @@ pub fn mam_extract_media_usage(mam: &[MamAttribute]) -> Result<MediaUsageInfo, E
let mon: i32 = date_str[4..6].parse()?;
let mday: i32 = date_str[6..8].parse()?;
use proxmox::tools::time::TmEditor;
use proxmox_time::TmEditor;
let mut t = TmEditor::new(true);
t.set_year(year)?;
t.set_mon(mon)?;

View File

@ -3,7 +3,7 @@ use std::io::Read;
use endian_trait::Endian;
use std::os::unix::io::AsRawFd;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::sgutils2::SgRaw;
@ -38,7 +38,7 @@ pub fn report_density<F: AsRawFd>(file: &mut F) -> Result<u8, Error> {
let mut max_density = 0u8;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page_len: u16 = unsafe { reader.read_be_value()? };

View File

@ -3,7 +3,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::sgutils2::SgRaw;
@ -106,7 +106,7 @@ fn sg_read_tape_alert_flags<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, Error>
fn decode_tape_alert_flags(data: &[u8]) -> Result<TapeAlertFlags, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
if !((data[0] & 0x7f) == 0x12 && data[1] == 0) {
bail!("invalid response");
}

View File

@ -4,7 +4,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::Lp17VolumeStatistics;
@ -71,7 +71,7 @@ fn decode_volume_statistics(data: &[u8]) -> Result<Lp17VolumeStatistics, Error>
Ok(value)
};
proxmox::try_block!({
proxmox_lang::try_block!({
if !((data[0] & 0x7f) == 0x17 && data[1] == 0) {
bail!("invalid response");
}

View File

@ -6,16 +6,16 @@
//!
//! The SCSI Commands Reference Manual also contains some useful information.
use std::ffi::CStr;
use std::os::unix::io::AsRawFd;
use std::ptr::NonNull;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use serde::{Deserialize, Serialize};
use libc::{c_char, c_int};
use std::ffi::CStr;
use serde::{Deserialize, Serialize};
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
#[derive(thiserror::Error, Debug)]
pub struct SenseInfo {
@ -379,7 +379,7 @@ pub fn get_asc_ascq_string(asc: u8, ascq: u8) -> String {
)
};
proxmox::try_block!({
proxmox_lang::try_block!({
if res.is_null() { // just to be safe
bail!("unexpected NULL ptr");
}
@ -675,7 +675,7 @@ pub fn scsi_inquiry<F: AsRawFd>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("SCSI inquiry failed - {}", err))?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: InquiryPage = unsafe { reader.read_be_value()? };
@ -724,7 +724,7 @@ pub fn scsi_mode_sense<F: AsRawFd, P: Endian>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("mode sense failed - {}", err))?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let head: ModeParameterHeader = unsafe { reader.read_be_value()? };
@ -777,7 +777,7 @@ pub fn scsi_request_sense<F: AsRawFd>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("request sense failed - {}", err))?;
let sense = proxmox::try_block!({
let sense = proxmox_lang::try_block!({
let data_len = data.len();
if data_len < std::mem::size_of::<RequestSenseFixed>() {