fix compiler warnings, add storage/config.rs
This commit is contained in:
parent
9131286246
commit
bfb1d69abc
|
@ -82,7 +82,8 @@ impl Registry {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_pve_node(value: &str) -> Result<(), Error> {
|
fn verify_pve_node(_value: &str) -> Result<(), Error> {
|
||||||
|
|
||||||
|
// fixme: ??
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
if !data.is_boolean() {
|
||||||
bail!("Expected boolean value.");
|
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> {
|
pub fn verify_json_integer(data: &Value, schema: &IntegerSchema) -> Result<(), Error> {
|
||||||
|
|
||||||
if let Some(value) = data.as_i64() {
|
if let Some(value) = data.as_i64() {
|
||||||
schema.check_constraints(value as isize)
|
schema.check_constraints(value as isize)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
|
|
||||||
use crate::api::schema::*;
|
use crate::api::schema::*;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use crate::api::schema::*;
|
use crate::api::schema::*;
|
||||||
|
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use serde_json::{json, Value};
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum RawArgument {
|
enum RawArgument {
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub mod section_config;
|
||||||
|
|
||||||
pub mod storage {
|
pub mod storage {
|
||||||
|
|
||||||
|
pub mod config;
|
||||||
pub mod futures;
|
pub mod futures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use failure::*;
|
use failure::*;
|
||||||
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Read;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
@ -76,7 +74,7 @@ impl SectionConfig {
|
||||||
self.plugins.insert(plugin.type_name.clone(), plugin);
|
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();
|
let mut list = VecDeque::new();
|
||||||
|
|
||||||
|
@ -232,7 +230,7 @@ impl SectionConfig {
|
||||||
Ok(result)
|
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);
|
return format!("{}: {}\n", type_name, section_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
|
@ -3,14 +3,14 @@ use std::sync::{Arc, Mutex};
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
|
|
||||||
struct StorageOperation {
|
pub struct StorageOperation {
|
||||||
state: Arc<Mutex<bool>>,
|
state: Arc<Mutex<bool>>,
|
||||||
running: bool,
|
running: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StorageOperation {
|
impl StorageOperation {
|
||||||
|
|
||||||
fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
StorageOperation { state: Arc::new(Mutex::new(false)), running: false }
|
StorageOperation { state: Arc::new(Mutex::new(false)), running: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue