mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-30 16:35:00 +00:00
proxmox-sys: moved nodename from proxmox crate
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
ec3965fdad
commit
ee4e56e372
@ -13,3 +13,19 @@ pub mod systemd;
|
|||||||
|
|
||||||
mod worker_task_context;
|
mod worker_task_context;
|
||||||
pub use worker_task_context::*;
|
pub use worker_task_context::*;
|
||||||
|
|
||||||
|
/// Returns the hosts node name (UTS node name)
|
||||||
|
pub fn nodename() -> &'static str {
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
static ref NODENAME: String = {
|
||||||
|
nix::sys::utsname::uname()
|
||||||
|
.nodename()
|
||||||
|
.split('.')
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.to_owned()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
&NODENAME
|
||||||
|
}
|
||||||
|
@ -129,19 +129,3 @@ fn test_hex() {
|
|||||||
hex_to_bin_exact("abca01239fa", &mut out).expect_err("parsed invalid hex string");
|
hex_to_bin_exact("abca01239fa", &mut out).expect_err("parsed invalid hex string");
|
||||||
hex_to_bin_exact("abca0x239f", &mut out).expect_err("parsed invalid hex string");
|
hex_to_bin_exact("abca0x239f", &mut out).expect_err("parsed invalid hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the hosts node name (UTS node name)
|
|
||||||
pub fn nodename() -> &'static str {
|
|
||||||
lazy_static! {
|
|
||||||
static ref NODENAME: String = {
|
|
||||||
nix::sys::utsname::uname()
|
|
||||||
.nodename()
|
|
||||||
.split('.')
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.to_owned()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
&NODENAME
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user