proxmox-backup/src/api2/tape/mod.rs

90 lines
1.7 KiB
Rust
Raw Normal View History

//! Tape Backup Management
use anyhow::Error;
use serde_json::Value;
use proxmox::{
api::{
api,
router::SubdirMap,
Router,
},
list_subdirs_api_method,
};
use crate::{
api2::types::TapeDeviceInfo,
tape::{
linux_tape_device_list,
linux_tape_changer_list,
},
};
pub mod drive;
pub mod changer;
2020-12-14 06:55:57 +00:00
pub mod media;
2020-12-18 14:32:12 +00:00
pub mod backup;
pub mod restore;
#[api(
input: {
properties: {},
},
returns: {
description: "The list of autodetected tape drives.",
type: Array,
items: {
type: TapeDeviceInfo,
},
},
)]
/// Scan tape drives
pub fn scan_drives(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
let list = linux_tape_device_list();
Ok(list)
}
#[api(
input: {
properties: {},
},
returns: {
description: "The list of autodetected tape changers.",
type: Array,
items: {
type: TapeDeviceInfo,
},
},
)]
/// Scan for SCSI tape changers
pub fn scan_changers(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
let list = linux_tape_changer_list();
Ok(list)
}
const SUBDIRS: SubdirMap = &[
2020-12-18 14:32:12 +00:00
("backup", &backup::ROUTER),
("changer", &changer::ROUTER),
("drive", &drive::ROUTER),
2020-12-14 06:55:57 +00:00
("media", &media::ROUTER),
2020-12-31 09:26:48 +00:00
("restore", &restore::ROUTER),
(
"scan-changers",
&Router::new()
.get(&API_METHOD_SCAN_CHANGERS),
),
(
"scan-drives",
&Router::new()
.get(&API_METHOD_SCAN_DRIVES),
),
];
pub const ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(SUBDIRS))
.subdirs(SUBDIRS);