mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-06 18:51:23 +00:00
system-config-api: use cargo features to sparate functionality
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
770c5dbd03
commit
3e8b0ee567
@ -22,7 +22,21 @@ proxmox-schema = { workspace = true, features = ["api-macro", "api-types"] }
|
|||||||
proxmox-time = { workspace = true, optional = true }
|
proxmox-time = { workspace = true, optional = true }
|
||||||
proxmox-product-config = { workspace = true, optional = true }
|
proxmox-product-config = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "proxmox-product-config/default" ]
|
default = []
|
||||||
impl = [ "dep:proxmox-sys", "dep:proxmox-time", "proxmox-product-config/impl"]
|
dns = ["dep:proxmox-product-config"]
|
||||||
|
dns-impl = [
|
||||||
|
"dns",
|
||||||
|
"dep:proxmox-product-config",
|
||||||
|
"proxmox-product-config?/impl",
|
||||||
|
"dep:proxmox-sys",
|
||||||
|
"dep:proxmox-time",
|
||||||
|
]
|
||||||
|
time = []
|
||||||
|
time-impl = [
|
||||||
|
"time",
|
||||||
|
"dep:proxmox-product-config",
|
||||||
|
"proxmox-product-config?/impl",
|
||||||
|
"dep:proxmox-sys",
|
||||||
|
"dep:proxmox-time",
|
||||||
|
]
|
||||||
|
@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use proxmox_schema::api;
|
use proxmox_schema::api;
|
||||||
use proxmox_schema::api_types::IP_FORMAT;
|
use proxmox_schema::api_types::IP_FORMAT;
|
||||||
use proxmox_schema::api_types::TIME_ZONE_SCHEMA;
|
|
||||||
use proxmox_schema::Schema;
|
use proxmox_schema::Schema;
|
||||||
use proxmox_schema::StringSchema;
|
use proxmox_schema::StringSchema;
|
||||||
|
|
||||||
@ -93,28 +92,3 @@ pub enum DeletableResolvConfProperty {
|
|||||||
/// Delete third nameserver entry
|
/// Delete third nameserver entry
|
||||||
Dns3,
|
Dns3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
|
||||||
properties: {
|
|
||||||
timezone: {
|
|
||||||
schema: TIME_ZONE_SCHEMA,
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
type: i64,
|
|
||||||
description: "Seconds since 1970-01-01 00:00:00 UTC.",
|
|
||||||
minimum: 1_297_163_644,
|
|
||||||
},
|
|
||||||
localtime: {
|
|
||||||
type: i64,
|
|
||||||
description: "Seconds since 1970-01-01 00:00:00 UTC. (local time)",
|
|
||||||
minimum: 1_297_163_644,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)]
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
/// Server time and timezone.
|
|
||||||
pub struct ServerTimeInfo {
|
|
||||||
pub timezone: String,
|
|
||||||
pub time: i64,
|
|
||||||
pub localtime: i64,
|
|
||||||
}
|
|
7
proxmox-system-config-api/src/dns/mod.rs
Normal file
7
proxmox-system-config-api/src/dns/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod api_types;
|
||||||
|
pub use api_types::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "dns-impl")]
|
||||||
|
mod resolv_conf;
|
||||||
|
#[cfg(feature = "dns-impl")]
|
||||||
|
pub use resolv_conf::*;
|
@ -13,9 +13,9 @@ use proxmox_sys::fs::CreateOptions;
|
|||||||
|
|
||||||
use proxmox_schema::api_types::IPRE_STR;
|
use proxmox_schema::api_types::IPRE_STR;
|
||||||
|
|
||||||
use crate::DeletableResolvConfProperty;
|
use super::DeletableResolvConfProperty;
|
||||||
use crate::ResolvConf;
|
use super::ResolvConf;
|
||||||
use crate::ResolvConfWithDigest;
|
use super::ResolvConfWithDigest;
|
||||||
|
|
||||||
static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
|
static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
|
||||||
|
|
@ -1,13 +1,5 @@
|
|||||||
mod api_types;
|
#[cfg(feature = "dns")]
|
||||||
pub use api_types::ServerTimeInfo;
|
pub mod dns;
|
||||||
pub use api_types::{DeletableResolvConfProperty, ResolvConf, ResolvConfWithDigest};
|
|
||||||
pub use api_types::{
|
|
||||||
FIRST_DNS_SERVER_SCHEMA, SEARCH_DOMAIN_SCHEMA, SECOND_DNS_SERVER_SCHEMA,
|
|
||||||
THIRD_DNS_SERVER_SCHEMA,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "impl")]
|
#[cfg(feature = "time")]
|
||||||
pub mod resolv_conf;
|
|
||||||
|
|
||||||
#[cfg(feature = "impl")]
|
|
||||||
pub mod time;
|
pub mod time;
|
||||||
|
29
proxmox-system-config-api/src/time/api_types.rs
Normal file
29
proxmox-system-config-api/src/time/api_types.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use proxmox_schema::api;
|
||||||
|
use proxmox_schema::api_types::TIME_ZONE_SCHEMA;
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
properties: {
|
||||||
|
timezone: {
|
||||||
|
schema: TIME_ZONE_SCHEMA,
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: i64,
|
||||||
|
description: "Seconds since 1970-01-01 00:00:00 UTC.",
|
||||||
|
minimum: 1_297_163_644,
|
||||||
|
},
|
||||||
|
localtime: {
|
||||||
|
type: i64,
|
||||||
|
description: "Seconds since 1970-01-01 00:00:00 UTC. (local time)",
|
||||||
|
minimum: 1_297_163_644,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)]
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
/// Server time and timezone.
|
||||||
|
pub struct ServerTimeInfo {
|
||||||
|
pub timezone: String,
|
||||||
|
pub time: i64,
|
||||||
|
pub localtime: i64,
|
||||||
|
}
|
7
proxmox-system-config-api/src/time/mod.rs
Normal file
7
proxmox-system-config-api/src/time/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod api_types;
|
||||||
|
pub use api_types::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "time-impl")]
|
||||||
|
mod time_impl;
|
||||||
|
#[cfg(feature = "time-impl")]
|
||||||
|
pub use time_impl::*;
|
@ -3,7 +3,7 @@ use anyhow::{bail, format_err, Error};
|
|||||||
use proxmox_product_config::replace_system_config;
|
use proxmox_product_config::replace_system_config;
|
||||||
use proxmox_sys::fs::file_read_firstline;
|
use proxmox_sys::fs::file_read_firstline;
|
||||||
|
|
||||||
use crate::api_types::ServerTimeInfo;
|
use super::ServerTimeInfo;
|
||||||
|
|
||||||
pub fn read_etc_localtime() -> Result<String, Error> {
|
pub fn read_etc_localtime() -> Result<String, Error> {
|
||||||
// use /etc/timezone
|
// use /etc/timezone
|
Loading…
Reference in New Issue
Block a user