]>
Commit | Line | Data |
---|---|---|
bf78f708 DM |
1 | //! Tape Backup Management |
2 | ||
887f1cb9 DM |
3 | use anyhow::Error; |
4 | use serde_json::Value; | |
5 | ||
6 | use proxmox::{ | |
7 | api::{ | |
8 | api, | |
9 | router::SubdirMap, | |
10 | Router, | |
11 | }, | |
12 | list_subdirs_api_method, | |
13 | }; | |
14 | ||
6227654a DM |
15 | use pbs_api_types::TapeDeviceInfo; |
16 | ||
887f1cb9 | 17 | use crate::{ |
9586ce2f | 18 | tape::{ |
a79082a0 | 19 | lto_tape_device_list, |
9586ce2f DM |
20 | linux_tape_changer_list, |
21 | }, | |
887f1cb9 | 22 | }; |
5d908606 DM |
23 | |
24 | pub mod drive; | |
25 | pub mod changer; | |
fba0b774 | 26 | pub mod media; |
88356646 | 27 | pub mod backup; |
b017bbc4 | 28 | pub mod restore; |
5d908606 | 29 | |
9586ce2f DM |
30 | #[api( |
31 | input: { | |
32 | properties: {}, | |
33 | }, | |
34 | returns: { | |
35 | description: "The list of autodetected tape drives.", | |
36 | type: Array, | |
37 | items: { | |
38 | type: TapeDeviceInfo, | |
39 | }, | |
40 | }, | |
41 | )] | |
42 | /// Scan tape drives | |
43 | pub fn scan_drives(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> { | |
44 | ||
a79082a0 | 45 | let list = lto_tape_device_list(); |
9586ce2f DM |
46 | |
47 | Ok(list) | |
48 | } | |
49 | ||
887f1cb9 DM |
50 | #[api( |
51 | input: { | |
52 | properties: {}, | |
53 | }, | |
54 | returns: { | |
55 | description: "The list of autodetected tape changers.", | |
56 | type: Array, | |
57 | items: { | |
58 | type: TapeDeviceInfo, | |
59 | }, | |
60 | }, | |
61 | )] | |
62 | /// Scan for SCSI tape changers | |
63 | pub fn scan_changers(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> { | |
64 | ||
65 | let list = linux_tape_changer_list(); | |
66 | ||
67 | Ok(list) | |
68 | } | |
69 | ||
70 | const SUBDIRS: SubdirMap = &[ | |
88356646 | 71 | ("backup", &backup::ROUTER), |
5d908606 DM |
72 | ("changer", &changer::ROUTER), |
73 | ("drive", &drive::ROUTER), | |
fba0b774 | 74 | ("media", &media::ROUTER), |
b9b4b312 | 75 | ("restore", &restore::ROUTER), |
740dc9d1 DC |
76 | ( |
77 | "scan-changers", | |
78 | &Router::new() | |
887f1cb9 | 79 | .get(&API_METHOD_SCAN_CHANGERS), |
740dc9d1 | 80 | ), |
5fdaecf6 DC |
81 | ( |
82 | "scan-drives", | |
83 | &Router::new() | |
9586ce2f | 84 | .get(&API_METHOD_SCAN_DRIVES), |
5fdaecf6 | 85 | ), |
5d908606 DM |
86 | ]; |
87 | ||
88 | pub const ROUTER: Router = Router::new() | |
89 | .get(&list_subdirs_api_method!(SUBDIRS)) | |
90 | .subdirs(SUBDIRS); |