]> git.proxmox.com Git - proxmox-backup.git/commitdiff
fix compiler warnings, add storage/config.rs
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 30 Nov 2018 10:15:26 +0000 (11:15 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 30 Nov 2018 10:15:26 +0000 (11:15 +0100)
src/api/registry.rs
src/api/schema.rs
src/api3.rs
src/getopts.rs
src/lib.rs
src/section_config.rs
src/storage/config.rs [new file with mode: 0644]
src/storage/futures.rs

index 7f297ee77636e9fbc32ba6ecda11e15bb1ad81fb..a58562dd61611fec02ef72542ec94927ada82a08 100644 (file)
@@ -82,7 +82,8 @@ impl Registry {
 
 }
 
-fn verify_pve_node(value: &str) -> Result<(), Error> {
+fn verify_pve_node(_value: &str) -> Result<(), Error> {
 
+    // fixme: ??
     Ok(())
 }
index 6f4baaf348242019954ecda2013d13c732097124..c2a365e8a0c9bab372292823a7fa0f781a78749a 100644 (file)
@@ -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 {
index 93534ed299c3f8d6b551da026a5ae636462755a7..e1a78b031db2c98aeaf5eb336c069cc92818a7fb 100644 (file)
@@ -1,6 +1,5 @@
 use failure::*;
 use std::collections::HashMap;
-use std::sync::Arc;
 
 
 use crate::api::schema::*;
index e0fdcad53fc5382eb49b6cc892ef1f0a805f0746..69d682829de914122b4ad88764af3062d3ebca50 100644 (file)
@@ -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 {
index f67f20dff8353a8a544b4ad6f4809e3c39e6a34f..2a325225aa05efe094a4fc34f44523f862170afb 100644 (file)
@@ -27,6 +27,7 @@ pub mod section_config;
 
 pub mod storage {
 
+    pub mod config;
     pub mod futures;
 }
 
index 62ca86fe2589c79da33073c36026245d6daf53a1..25302cd7faae0fa7d272dc0842e0636f86712131 100644 (file)
@@ -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<String, Error> {
+    pub fn write(&self, _filename: &str, config: &SectionConfigData) -> Result<String, Error> {
 
         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 (file)
index 0000000..1d294c0
--- /dev/null
@@ -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)
+}
index 6a8fd8fd1e691900eaf8cb64c63470ec9ad7c49b..da64f936b24369fa5009e6d13c3e8aa7901b30be 100644 (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 }
     }