]> git.proxmox.com Git - proxmox-backup.git/blob - src/storage/config.rs
2f04fd4226804ec415307ade3c9eb883d932749f
[proxmox-backup.git] / src / storage / config.rs
1 use failure::*;
2
3 use crate::api_schema::*;
4 use crate::section_config::*;
5
6 use lazy_static::lazy_static;
7
8 lazy_static!{
9 static ref STORAGE_SECTION_CONFIG: SectionConfig = register_storage_plugins();
10 }
11
12 fn register_storage_plugins() -> SectionConfig {
13
14 let plugin = SectionConfigPlugin::new(
15 "lvmthin".to_string(),
16 ObjectSchema::new("lvmthin properties")
17 .required("thinpool", StringSchema::new("LVM thin pool name."))
18 .required("vgname", StringSchema::new("LVM volume group name."))
19 .optional("content", StringSchema::new("Storage content types."))
20 );
21
22 let id_schema = StringSchema::new("Storage ID schema.")
23 .min_length(3)
24 .into();
25
26 let mut config = SectionConfig::new(id_schema);
27 config.register_plugin(plugin);
28
29 config
30 }
31
32 pub fn parse_config(filename: &str, raw: &str) -> Result<SectionConfigData, Error> {
33
34 STORAGE_SECTION_CONFIG.parse(filename, raw)
35 }
36
37 pub fn write_config(filename: &str, config: &SectionConfigData) -> Result<String, Error> {
38
39 STORAGE_SECTION_CONFIG.write(filename, config)
40 }