From: Dietmar Maurer Date: Wed, 27 Jan 2021 08:58:16 +0000 (+0100) Subject: cleanup: move scan changers API implementation X-Git-Tag: v1.0.7~106 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=887f1cb90cc0be9ffa309dbe2a322d3b04ec5a9a;p=proxmox-backup.git cleanup: move scan changers API implementation --- diff --git a/src/api2.rs b/src/api2.rs index 4783df63..b7230f75 100644 --- a/src/api2.rs +++ b/src/api2.rs @@ -1,3 +1,5 @@ +//! The Proxmox Backup Server API + pub mod access; pub mod admin; pub mod backup; @@ -18,7 +20,7 @@ use proxmox::list_subdirs_api_method; const NODES_ROUTER: Router = Router::new().match_all("node", &node::ROUTER); -pub const SUBDIRS: SubdirMap = &[ +const SUBDIRS: SubdirMap = &[ ("access", &access::ROUTER), ("admin", &admin::ROUTER), ("backup", &backup::ROUTER), diff --git a/src/api2/tape/changer.rs b/src/api2/tape/changer.rs index 03e92a0e..8239e041 100644 --- a/src/api2/tape/changer.rs +++ b/src/api2/tape/changer.rs @@ -12,7 +12,6 @@ use crate::{ CHANGER_NAME_SCHEMA, DriveListEntry, ScsiTapeChanger, - TapeDeviceInfo, MtxStatusEntry, MtxEntryKind, }, @@ -137,26 +136,6 @@ pub async fn transfer( }).await? } -#[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, Error> { - - let list = linux_tape_changer_list(); - - Ok(list) -} - #[api( input: { properties: {}, diff --git a/src/api2/tape/mod.rs b/src/api2/tape/mod.rs index 6fbf902a..05cdb693 100644 --- a/src/api2/tape/mod.rs +++ b/src/api2/tape/mod.rs @@ -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, 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), ), ]; diff --git a/src/bin/proxmox_tape/changer.rs b/src/bin/proxmox_tape/changer.rs index 0479771e..e3bb7bb3 100644 --- a/src/bin/proxmox_tape/changer.rs +++ b/src/bin/proxmox_tape/changer.rs @@ -149,7 +149,7 @@ fn scan_for_changers( ) -> Result<(), Error> { let output_format = get_output_format(¶m); - let info = &api2::tape::changer::API_METHOD_SCAN_CHANGERS; + let info = &api2::tape::API_METHOD_SCAN_CHANGERS; let mut data = match info.handler { ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, _ => unreachable!(),