From 327e93711f7eba528b2a36b5406ffe476dcfe78e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 4 Dec 2020 16:00:16 +0100 Subject: [PATCH] commit missing file: tape api type definitions --- src/api2/types/tape.rs | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/api2/types/tape.rs diff --git a/src/api2/types/tape.rs b/src/api2/types/tape.rs new file mode 100644 index 00000000..379e9102 --- /dev/null +++ b/src/api2/types/tape.rs @@ -0,0 +1,90 @@ +//! Types for tape backup API +//! +use serde::{Deserialize, Serialize}; + +use proxmox::api::{ + api, + schema::{Schema, StringSchema}, +}; + +use super::PROXMOX_SAFE_ID_FORMAT; + +pub const DRIVE_ID_SCHEMA: Schema = StringSchema::new("Drive Identifier.") + .format(&PROXMOX_SAFE_ID_FORMAT) + .min_length(3) + .max_length(32) + .schema(); + +pub const CHANGER_ID_SCHEMA: Schema = StringSchema::new("Tape Changer Identifier.") + .format(&PROXMOX_SAFE_ID_FORMAT) + .min_length(3) + .max_length(32) + .schema(); + +pub const LINUX_DRIVE_PATH_SCHEMA: Schema = StringSchema::new( + "The path to a LINUX non-rewinding SCSI tape device (i.e. '/dev/nst0')") + .schema(); + +pub const SCSI_CHANGER_PATH_SCHEMA: Schema = StringSchema::new( + "Path to Linux generic SCSI device (i.e. '/dev/sg4')") + .schema(); + +#[api( + properties: { + name: { + schema: DRIVE_ID_SCHEMA, + } + } +)] +#[derive(Serialize,Deserialize)] +/// Simulate tape drives (only for test and debug) +#[serde(rename_all = "kebab-case")] +pub struct VirtualTapeDrive { + pub name: String, + /// Path to directory + pub path: String, + /// Virtual tape size + #[serde(skip_serializing_if="Option::is_none")] + pub max_size: Option, +} + +#[api( + properties: { + name: { + schema: DRIVE_ID_SCHEMA, + }, + path: { + schema: LINUX_DRIVE_PATH_SCHEMA, + }, + changer: { + schema: CHANGER_ID_SCHEMA, + optional: true, + } + } +)] +#[derive(Serialize,Deserialize)] +/// Linux SCSI tape driver +pub struct LinuxTapeDrive { + pub name: String, + pub path: String, + /// Associated changer device + #[serde(skip_serializing_if="Option::is_none")] + pub changer: Option, +} + +#[api( + properties: { + name: { + schema: CHANGER_ID_SCHEMA, + }, + path: { + schema: SCSI_CHANGER_PATH_SCHEMA, + }, + } +)] +#[derive(Serialize,Deserialize)] +/// SCSI tape changer +pub struct ScsiTapeChanger { + pub name: String, + pub path: String, +}