diff --git a/proxmox-sys/Cargo.toml b/proxmox-sys/Cargo.toml index d79d11da..d422a7c3 100644 --- a/proxmox-sys/Cargo.toml +++ b/proxmox-sys/Cargo.toml @@ -10,7 +10,7 @@ authors = [ [dependencies] failure = "0.1" libc = "0.2" -nix = "0.13" +nix = "0.14" proxmox-tools = { path = "../proxmox-tools" } lazy_static = "1.1" regex = "1.0" diff --git a/proxmox-tools/src/lib.rs b/proxmox-tools/src/lib.rs index f2a4cd1d..8ee04515 100644 --- a/proxmox-tools/src/lib.rs +++ b/proxmox-tools/src/lib.rs @@ -1,6 +1,7 @@ //! This is a general utility crate used by all our rust projects. use failure::*; +use lazy_static::lazy_static; pub mod common_regex; pub mod io; @@ -146,3 +147,21 @@ pub fn hex_to_digest(hex: &str) -> Result<[u8; 32], Error> { Ok(digest) } + +/// 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 +}