cleanup nodename()
This commit is contained in:
parent
74a69302a7
commit
0d38dcb43c
19
src/tools.rs
19
src/tools.rs
@ -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),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user