src/api2/node: start node configuration api

This commit is contained in:
Dietmar Maurer 2019-01-23 13:05:32 +01:00
parent d15009c0ce
commit b2b3485d5f
7 changed files with 106 additions and 6 deletions

View File

@ -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()

View File

@ -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());

23
src/api2/node.rs Normal file
View File

@ -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
}

27
src/api2/node/dns.rs Normal file
View File

@ -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<Value, Error> {
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
}

22
src/api2/node/network.rs Normal file
View File

@ -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<Value, Error> {
Ok(json!({}))
}
pub fn router() -> Router {
let route = Router::new()
.get(ApiMethod::new(
get_network_config,
ObjectSchema::new("Read network configuration.")));
route
}

26
src/api2/node/time.rs Normal file
View File

@ -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<Value, Error> {
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
}

View File

@ -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'
}
],