use new proxmox::tools::nodename

This commit is contained in:
Dietmar Maurer 2019-08-03 17:06:23 +02:00
parent 7f66c29e5c
commit f69adc81a6
5 changed files with 5 additions and 25 deletions

View File

@ -38,7 +38,7 @@ lazy_static!{
StringSchema::new("Node name (or 'localhost')")
.format(
Arc::new(ApiStringFormat::VerifyFn(|node| {
if node == "localhost" || node == crate::tools::nodename() {
if node == "localhost" || node == proxmox::tools::nodename() {
Ok(())
} else {
bail!("no such node '{}'", node);

View File

@ -469,7 +469,7 @@ fn create_backup(
let keyfile = param["keyfile"].as_str().map(|p| PathBuf::from(p));
let backup_id = param["backup-id"].as_str().unwrap_or(&tools::nodename());
let backup_id = param["backup-id"].as_str().unwrap_or(&proxmox::tools::nodename());
let backup_type = param["backup-type"].as_str().unwrap_or("host");
@ -553,7 +553,7 @@ fn create_backup(
println!("Starting backup: {}/{}/{}", backup_type, backup_id, BackupDir::backup_time_to_string(backup_time));
println!("Client name: {}", tools::nodename());
println!("Client name: {}", proxmox::tools::nodename());
let start_time = Local::now();

View File

@ -343,7 +343,7 @@ pub fn handle_async_api_request<Env: RpcEnvironment>(
fn get_index(username: Option<String>, token: Option<String>) -> Response<Body> {
let nodename = tools::nodename();
let nodename = proxmox::tools::nodename();
let username = username.unwrap_or(String::from(""));
let token = token.unwrap_or(String::from(""));

View File

@ -5,8 +5,6 @@ use chrono::Local;
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::tools;
/// Unique Process/Task Identifier
///
/// We use this to uniquely identify worker task. UPIDs have a short
@ -68,7 +66,7 @@ impl UPID {
worker_type: worker_type.to_owned(),
worker_id,
username: username.to_owned(),
node: tools::nodename().to_owned(),
node: proxmox::tools::nodename().to_owned(),
})
}

View File

@ -2,7 +2,6 @@
//!
//! This is a collection of small and useful tools.
use failure::*;
use lazy_static::lazy_static;
use std::fs::{File, OpenOptions};
use std::path::Path;
@ -215,23 +214,6 @@ pub fn getpwnam_ugid(username: &str) -> Result<(libc::uid_t,libc::gid_t), Error>
Ok((info.pw_uid, info.pw_gid))
}
// 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
}
pub fn json_object_to_query(data: Value) -> Result<String, Error> {