cleanup nodename()

This commit is contained in:
Dietmar Maurer 2019-01-18 10:13:45 +01:00
parent 74a69302a7
commit 0d38dcb43c
1 changed files with 13 additions and 6 deletions

View File

@ -234,12 +234,12 @@ pub fn nodename() -> &'static str {
lazy_static!{
static ref NODENAME: String = {
let utsname = nix::sys::utsname::uname();
let nodename = utsname.nodename();
let parts: Vec<&str> = nodename.split('.').collect();
parts[0].to_owned()
nix::sys::utsname::uname()
.nodename()
.split('.')
.next()
.unwrap()
.to_owned()
};
}
@ -252,3 +252,10 @@ pub fn required_string_param<'a>(param: &'a Value, name: &str) -> Result<&'a str
None => bail!("missing parameter '{}'", name),
}
}
pub fn required_integer_param<'a>(param: &'a Value, name: &str) -> Result<i64, Error> {
match param[name].as_i64() {
Some(s) => Ok(s),
None => bail!("missing parameter '{}'", name),
}
}