}
-fn verify_pve_node(value: &str) -> Result<(), Error> {
+fn verify_pve_node(_value: &str) -> Result<(), Error> {
+ // fixme: ??
Ok(())
}
}
}
-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.");
}
}
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 {
use failure::*;
use std::collections::HashMap;
-use std::sync::Arc;
use crate::api::schema::*;
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 {
pub mod storage {
+ pub mod config;
pub mod futures;
}
use failure::*;
-use std::fs::File;
-use std::io::Read;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
self.plugins.insert(plugin.type_name.clone(), plugin);
}
- pub fn write(&self, filename: &str, config: &SectionConfigData) -> Result<String, Error> {
+ pub fn write(&self, _filename: &str, config: &SectionConfigData) -> Result<String, Error> {
let mut list = VecDeque::new();
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);
}
--- /dev/null
+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)
+}
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 }
}