diff --git a/src/api/registry.rs b/src/api/registry.rs index 7f297ee7..a58562dd 100644 --- a/src/api/registry.rs +++ b/src/api/registry.rs @@ -82,7 +82,8 @@ impl Registry { } -fn verify_pve_node(value: &str) -> Result<(), Error> { +fn verify_pve_node(_value: &str) -> Result<(), Error> { + // fixme: ?? Ok(()) } diff --git a/src/api/schema.rs b/src/api/schema.rs index 6f4baaf3..c2a365e8 100644 --- a/src/api/schema.rs +++ b/src/api/schema.rs @@ -574,7 +574,7 @@ pub fn verify_json_string(data: &Value, schema: &StringSchema) -> Result<(), Err } } -pub fn verify_json_boolean(data: &Value, schema: &BooleanSchema) -> Result<(), Error> { +pub fn verify_json_boolean(data: &Value, _schema: &BooleanSchema) -> Result<(), Error> { if !data.is_boolean() { bail!("Expected boolean value."); } @@ -582,7 +582,6 @@ pub fn verify_json_boolean(data: &Value, schema: &BooleanSchema) -> Result<(), E } pub fn verify_json_integer(data: &Value, schema: &IntegerSchema) -> Result<(), Error> { - if let Some(value) = data.as_i64() { schema.check_constraints(value as isize) } else { diff --git a/src/api3.rs b/src/api3.rs index 93534ed2..e1a78b03 100644 --- a/src/api3.rs +++ b/src/api3.rs @@ -1,6 +1,5 @@ use failure::*; use std::collections::HashMap; -use std::sync::Arc; use crate::api::schema::*; diff --git a/src/getopts.rs b/src/getopts.rs index e0fdcad5..69d68282 100644 --- a/src/getopts.rs +++ b/src/getopts.rs @@ -1,10 +1,8 @@ use crate::api::schema::*; use failure::*; -use std::collections::HashMap; -use std::sync::Arc; -use serde_json::{json, Value}; +use serde_json::Value; #[derive(Debug)] enum RawArgument { diff --git a/src/lib.rs b/src/lib.rs index f67f20df..2a325225 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,7 @@ pub mod section_config; pub mod storage { + pub mod config; pub mod futures; } diff --git a/src/section_config.rs b/src/section_config.rs index 62ca86fe..25302cd7 100644 --- a/src/section_config.rs +++ b/src/section_config.rs @@ -1,7 +1,5 @@ use failure::*; -use std::fs::File; -use std::io::Read; use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; @@ -76,7 +74,7 @@ impl SectionConfig { self.plugins.insert(plugin.type_name.clone(), plugin); } - pub fn write(&self, filename: &str, config: &SectionConfigData) -> Result { + pub fn write(&self, _filename: &str, config: &SectionConfigData) -> Result { let mut list = VecDeque::new(); @@ -232,7 +230,7 @@ impl SectionConfig { Ok(result) } - pub fn default_format_section_header(type_name: &str, section_id: &str, data: &Value) -> String { + pub fn default_format_section_header(type_name: &str, section_id: &str, _data: &Value) -> String { return format!("{}: {}\n", type_name, section_id); } diff --git a/src/storage/config.rs b/src/storage/config.rs new file mode 100644 index 00000000..1d294c04 --- /dev/null +++ b/src/storage/config.rs @@ -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 { + + let res = STORAGE_SECTION_CONFIG.parse(filename, raw); + + res +} + +pub fn write_config(filename: &str, config: &SectionConfigData) -> Result { + + STORAGE_SECTION_CONFIG.write(filename, config) +} diff --git a/src/storage/futures.rs b/src/storage/futures.rs index 6a8fd8fd..da64f936 100644 --- a/src/storage/futures.rs +++ b/src/storage/futures.rs @@ -3,14 +3,14 @@ use std::sync::{Arc, Mutex}; use failure::*; use tokio::prelude::*; -struct StorageOperation { +pub struct StorageOperation { state: Arc>, running: bool, } impl StorageOperation { - fn new() -> Self { + pub fn new() -> Self { StorageOperation { state: Arc::new(Mutex::new(false)), running: false } }