mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-28 18:15:28 +00:00
add nodename helper (copied from proxmox-backup)
This commit is contained in:
parent
ce18d8c035
commit
d6d65be42e
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user