fix compiler warnings, add storage/config.rs

This commit is contained in:
Dietmar Maurer
2018-11-30 11:15:26 +01:00
parent 9131286246
commit bfb1d69abc
8 changed files with 51 additions and 13 deletions

42
src/storage/config.rs Normal file
View File

@ -0,0 +1,42 @@
use failure::*;
use crate::api::schema::*;
use crate::section_config::*;
use lazy_static::lazy_static;
lazy_static!{
static ref STORAGE_SECTION_CONFIG: SectionConfig = register_storage_plugins();
}
fn register_storage_plugins() -> SectionConfig {
let plugin = SectionConfigPlugin::new(
"lvmthin".to_string(),
ObjectSchema::new("lvmthin properties")
.required("thinpool", StringSchema::new("LVM thin pool name."))
.required("vgname", StringSchema::new("LVM volume group name."))
.optional("content", StringSchema::new("Storage content types."))
);
let id_schema = StringSchema::new("Storage ID schema.")
.min_length(3)
.into();
let mut config = SectionConfig::new(id_schema);
config.register_plugin(plugin);
config
}
pub fn parse_config(filename: &str, raw: &str) -> Result<SectionConfigData, Error> {
let res = STORAGE_SECTION_CONFIG.parse(filename, raw);
res
}
pub fn write_config(filename: &str, config: &SectionConfigData) -> Result<String, Error> {
STORAGE_SECTION_CONFIG.write(filename, config)
}

View File

@ -3,14 +3,14 @@ use std::sync::{Arc, Mutex};
use failure::*;
use tokio::prelude::*;
struct StorageOperation {
pub struct StorageOperation {
state: Arc<Mutex<bool>>,
running: bool,
}
impl StorageOperation {
fn new() -> Self {
pub fn new() -> Self {
StorageOperation { state: Arc::new(Mutex::new(false)), running: false }
}