cleanup: move scan changers API implementation

This commit is contained in:
Dietmar Maurer
2021-01-27 09:58:16 +01:00
parent 16b4d78400
commit 887f1cb90c
4 changed files with 42 additions and 28 deletions

View File

@ -1,8 +1,21 @@
//! Tape Backup Management
use proxmox::api::router::SubdirMap;
use proxmox::api::Router;
use proxmox::list_subdirs_api_method;
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_changer_list,
};
pub mod drive;
pub mod changer;
@ -10,7 +23,27 @@ pub mod media;
pub mod backup;
pub mod restore;
pub const SUBDIRS: SubdirMap = &[
#[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 = &[
("backup", &backup::ROUTER),
("changer", &changer::ROUTER),
("drive", &drive::ROUTER),
@ -19,7 +52,7 @@ pub const SUBDIRS: SubdirMap = &[
(
"scan-changers",
&Router::new()
.get(&changer::API_METHOD_SCAN_CHANGERS),
.get(&API_METHOD_SCAN_CHANGERS),
),
];