use new proxmox::tools::nodename
This commit is contained in:
parent
7f66c29e5c
commit
f69adc81a6
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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(""));
|
||||
|
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
18
src/tools.rs
18
src/tools.rs
@ -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> {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user