tape: move scan_drives API code to correct file

This commit is contained in:
Dietmar Maurer 2021-01-30 08:03:17 +01:00
parent b8d526f18d
commit 9586ce2f46
3 changed files with 26 additions and 24 deletions

View File

@ -34,7 +34,6 @@ use crate::{
Authid, Authid,
DriveListEntry, DriveListEntry,
LinuxTapeDrive, LinuxTapeDrive,
TapeDeviceInfo,
MediaIdFlat, MediaIdFlat,
LabelUuidMap, LabelUuidMap,
MamAttribute, MamAttribute,
@ -179,26 +178,6 @@ pub async fn unload(
}).await? }).await?
} }
#[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( #[api(
input: { input: {
properties: { properties: {

View File

@ -14,7 +14,10 @@ use proxmox::{
use crate::{ use crate::{
api2::types::TapeDeviceInfo, api2::types::TapeDeviceInfo,
tape::linux_tape_changer_list, tape::{
linux_tape_device_list,
linux_tape_changer_list,
},
}; };
pub mod drive; pub mod drive;
@ -23,6 +26,26 @@ pub mod media;
pub mod backup; pub mod backup;
pub mod restore; 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( #[api(
input: { input: {
properties: {}, properties: {},
@ -57,7 +80,7 @@ const SUBDIRS: SubdirMap = &[
( (
"scan-drives", "scan-drives",
&Router::new() &Router::new()
.get(&drive::API_METHOD_SCAN_DRIVES), .get(&API_METHOD_SCAN_DRIVES),
), ),
]; ];

View File

@ -116,7 +116,7 @@ fn scan_for_drives(
) -> Result<(), Error> { ) -> Result<(), Error> {
let output_format = get_output_format(&param); let output_format = get_output_format(&param);
let info = &api2::tape::drive::API_METHOD_SCAN_DRIVES; let info = &api2::tape::API_METHOD_SCAN_DRIVES;
let mut data = match info.handler { let mut data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(), _ => unreachable!(),