From b2b3485d5fbd1f2c5b98d20f576eb0d62e5c63e7 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 23 Jan 2019 13:05:32 +0100 Subject: [PATCH] src/api2/node: start node configuration api --- src/api2.rs | 3 ++- src/api2/config.rs | 2 +- src/api2/node.rs | 23 +++++++++++++++++++++++ src/api2/node/dns.rs | 27 +++++++++++++++++++++++++++ src/api2/node/network.rs | 22 ++++++++++++++++++++++ src/api2/node/time.rs | 26 ++++++++++++++++++++++++++ www/SystemConfiguration.js | 9 +++++---- 7 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 src/api2/node.rs create mode 100644 src/api2/node/dns.rs create mode 100644 src/api2/node/network.rs create mode 100644 src/api2/node/time.rs diff --git a/src/api2.rs b/src/api2.rs index b9a76456..80be53d7 100644 --- a/src/api2.rs +++ b/src/api2.rs @@ -6,6 +6,7 @@ use serde_json::{json, Value}; pub mod config; pub mod admin; +pub mod node; mod version; mod subscription; @@ -48,7 +49,7 @@ pub fn router() -> Router { .subdir("subdir3", route4); let nodes = Router::new() - .match_all("node", nodeinfo); + .subdir("localhost", node::router()); let route = Router::new() diff --git a/src/api2/config.rs b/src/api2/config.rs index ccdd2784..da4177ae 100644 --- a/src/api2/config.rs +++ b/src/api2/config.rs @@ -12,7 +12,7 @@ pub fn router() -> Router { let route = Router::new() .get(ApiMethod::new( |_,_| Ok(json!([ - {"subdir": "datastore"} + {"subdir": "datastore"}, ])), ObjectSchema::new("Directory index."))) .subdir("datastore", datastore::router()); diff --git a/src/api2/node.rs b/src/api2/node.rs new file mode 100644 index 00000000..cb51f056 --- /dev/null +++ b/src/api2/node.rs @@ -0,0 +1,23 @@ +use crate::api::schema::*; +use crate::api::router::*; +use serde_json::{json}; + +mod time; +mod network; +mod dns; + +pub fn router() -> Router { + + let route = Router::new() + .get(ApiMethod::new( + |_,_| Ok(json!([ + {"subdir": "network"}, + {"subdir": "time"}, + ])), + ObjectSchema::new("Directory index."))) + .subdir("dns", dns::router()) + .subdir("network", network::router()) + .subdir("time", time::router()); + + route +} diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs new file mode 100644 index 00000000..7dfb1f33 --- /dev/null +++ b/src/api2/node/dns.rs @@ -0,0 +1,27 @@ +use failure::*; + +use crate::tools; +use crate::api::schema::*; +use crate::api::router::*; +use serde_json::{json, Value}; + + +fn get_dns(_param: Value, _info: &ApiMethod) -> Result { + + Ok(json!({ + "search": "test.com", + "dns1": "1.2.3.4", + "dns2": "1.2.3.4", + "dns3": "1.2.3.4", + })) +} + +pub fn router() -> Router { + + let route = Router::new() + .get(ApiMethod::new( + get_dns, + ObjectSchema::new("Read DNS settings."))); + + route +} diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs new file mode 100644 index 00000000..220bc4bd --- /dev/null +++ b/src/api2/node/network.rs @@ -0,0 +1,22 @@ +use failure::*; + +use crate::tools; +use crate::api::schema::*; +use crate::api::router::*; +use serde_json::{json, Value}; + + +fn get_network_config(_param: Value, _info: &ApiMethod) -> Result { + + Ok(json!({})) +} + +pub fn router() -> Router { + + let route = Router::new() + .get(ApiMethod::new( + get_network_config, + ObjectSchema::new("Read network configuration."))); + + route +} diff --git a/src/api2/node/time.rs b/src/api2/node/time.rs new file mode 100644 index 00000000..1714cdc1 --- /dev/null +++ b/src/api2/node/time.rs @@ -0,0 +1,26 @@ +use failure::*; + +use crate::tools; +use crate::api::schema::*; +use crate::api::router::*; +use serde_json::{json, Value}; + + +fn get_time(_param: Value, _info: &ApiMethod) -> Result { + + Ok(json!({ + "timezone": "Europe/Vienna", + "time": 1297163644, + "localtime": 1297163644, + })) +} + +pub fn router() -> Router { + + let route = Router::new() + .get(ApiMethod::new( + get_time, + ObjectSchema::new("Read server time and time zone settings."))); + + route +} diff --git a/www/SystemConfiguration.js b/www/SystemConfiguration.js index d8e67ac2..9b300134 100644 --- a/www/SystemConfiguration.js +++ b/www/SystemConfiguration.js @@ -31,23 +31,24 @@ Ext.define('PBS.SystemConfiguration', { title: gettext('Interfaces'), xtype: 'proxmoxNodeNetworkView', types: ['bond'], - nodename: Proxmox.NodeName + nodename: 'localhost' }, { title: gettext('DNS'), xtype: 'proxmoxNodeDNSView', - nodename: Proxmox.NodeName + nodename: 'localhost' }, { title: gettext('Time'), xtype: 'proxmoxNodeTimeView', - nodename: Proxmox.NodeName + nodename: 'localhost' } ] // }, // { // itemId: 'options', -// title: gettext('Options'), +// title: gettext('Options'), +// html: "TESWT" // xtype: 'pbsSystemOptions' } ],