proxmox-sys: moved nodename from proxmox crate

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2021-11-24 07:13:11 +01:00
parent ec3965fdad
commit ee4e56e372
2 changed files with 16 additions and 16 deletions

View File

@ -13,3 +13,19 @@ pub mod systemd;
mod 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
}

View File

@ -129,19 +129,3 @@ fn test_hex() {
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");
}
/// 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
}