mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-29 22:58:59 +00:00
add nodename helper (copied from proxmox-backup)
This commit is contained in:
parent
ce18d8c035
commit
d6d65be42e
@ -10,7 +10,7 @@ authors = [
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
nix = "0.13"
|
nix = "0.14"
|
||||||
proxmox-tools = { path = "../proxmox-tools" }
|
proxmox-tools = { path = "../proxmox-tools" }
|
||||||
lazy_static = "1.1"
|
lazy_static = "1.1"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! This is a general utility crate used by all our rust projects.
|
//! This is a general utility crate used by all our rust projects.
|
||||||
|
|
||||||
use failure::*;
|
use failure::*;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
pub mod common_regex;
|
pub mod common_regex;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
@ -146,3 +147,21 @@ pub fn hex_to_digest(hex: &str) -> Result<[u8; 32], Error> {
|
|||||||
|
|
||||||
Ok(digest)
|
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