update to proxmox-sys 0.2 crate
- imported pbs-api-types/src/common_regex.rs from old proxmox crate - use hex crate to generate/parse hex digest - remove all reference to proxmox crate (use proxmox-sys and proxmox-serde instead) Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
@ -2,7 +2,7 @@ use anyhow::{Error, bail, format_err};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, RpcEnvironment, RpcEnvironmentType, Permission, Router, SubdirMap
|
||||
};
|
||||
@ -277,7 +277,7 @@ fn apt_get_changelog(
|
||||
command.arg("changelog");
|
||||
command.arg("-qq"); // don't display download progress
|
||||
command.arg(name);
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
Ok(json!(output))
|
||||
}
|
||||
}
|
||||
@ -447,7 +447,7 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
|
||||
/// Get APT repository information.
|
||||
pub fn get_repositories() -> Result<Value, Error> {
|
||||
let (files, errors, digest) = proxmox_apt::repositories::repositories()?;
|
||||
let digest = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest = hex::encode(&digest);
|
||||
|
||||
let suite = proxmox_apt::repositories::get_current_release_codename()?;
|
||||
|
||||
@ -493,7 +493,7 @@ pub fn add_repository(handle: APTRepositoryHandle, digest: Option<String>) -> Re
|
||||
let suite = proxmox_apt::repositories::get_current_release_codename()?;
|
||||
|
||||
if let Some(expected_digest) = digest {
|
||||
let current_digest = proxmox::tools::digest_to_hex(¤t_digest);
|
||||
let current_digest = hex::encode(¤t_digest);
|
||||
crate::tools::assert_if_modified(&expected_digest, ¤t_digest)?;
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ pub fn change_repository(
|
||||
let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
|
||||
|
||||
if let Some(expected_digest) = digest {
|
||||
let current_digest = proxmox::tools::digest_to_hex(¤t_digest);
|
||||
let current_digest = hex::encode(¤t_digest);
|
||||
crate::tools::assert_if_modified(&expected_digest, ¤t_digest)?;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ impl TryFrom<&cert::CertInfo> for CertificateInfo {
|
||||
|
||||
fn get_certificate_pem() -> Result<String, Error> {
|
||||
let cert_path = configdir!("/proxy.pem");
|
||||
let cert_pem = proxmox::tools::fs::file_get_contents(&cert_path)?;
|
||||
let cert_pem = proxmox_sys::fs::file_get_contents(&cert_path)?;
|
||||
String::from_utf8(cert_pem)
|
||||
.map_err(|_| format_err!("certificate in {:?} is not a valid PEM file", cert_path))
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use anyhow::Error;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Permission, Router, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
@ -29,7 +30,7 @@ pub const ROUTER: Router = Router::new()
|
||||
/// Get the node configuration
|
||||
pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<NodeConfig, Error> {
|
||||
let (config, digest) = crate::config::node::config()?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ pub fn update_node_config(
|
||||
if let Some(digest) = digest {
|
||||
// FIXME: GUI doesn't handle our non-inlined digest part here properly...
|
||||
if !digest.is_empty() {
|
||||
let digest = proxmox::tools::hex_to_digest(&digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(&digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
let basedir = "/etc/systemd/system";
|
||||
for item in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
|
||||
for item in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
|
||||
let item = item?;
|
||||
let name = item.file_name().to_string_lossy().to_string();
|
||||
|
||||
@ -243,7 +243,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
// disable systemd mount-unit
|
||||
let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&path, true);
|
||||
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&path, true);
|
||||
mount_unit_name.push_str(".mount");
|
||||
crate::tools::systemd::disable_unit(&mount_unit_name)?;
|
||||
|
||||
@ -256,7 +256,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
|
||||
// try to unmount, if that fails tell the user to reboot or unmount manually
|
||||
let mut command = std::process::Command::new("umount");
|
||||
command.arg(&path);
|
||||
match pbs_tools::run_command(command, None) {
|
||||
match proxmox_sys::command::run_command(command, None) {
|
||||
Err(_) => bail!(
|
||||
"Could not umount '{}' since it is busy. It will stay mounted \
|
||||
until the next reboot or until unmounted manually!",
|
||||
@ -282,7 +282,7 @@ fn create_datastore_mount_unit(
|
||||
what: &str,
|
||||
) -> Result<String, Error> {
|
||||
|
||||
let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&mount_point, true);
|
||||
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&mount_point, true);
|
||||
mount_unit_name.push_str(".mount");
|
||||
|
||||
let mount_unit_path = format!("/etc/systemd/system/{}", mount_unit_name);
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap, Permission,
|
||||
};
|
||||
|
@ -265,11 +265,11 @@ pub fn create_zpool(
|
||||
|
||||
task_log!(worker, "# {:?}", command);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
task_log!(worker, "{}", output);
|
||||
|
||||
if std::path::Path::new("/lib/systemd/system/zfs-import@.service").exists() {
|
||||
let import_unit = format!("zfs-import@{}.service", proxmox::tools::systemd::escape_unit(&name, false));
|
||||
let import_unit = format!("zfs-import@{}.service", proxmox_sys::systemd::escape_unit(&name, false));
|
||||
crate::tools::systemd::enable_unit(&import_unit)?;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ pub fn create_zpool(
|
||||
let mut command = std::process::Command::new("zfs");
|
||||
command.args(&["set", &format!("compression={}", compression), &name]);
|
||||
task_log!(worker, "# {:?}", command);
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
task_log!(worker, "{}", output);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ use ::serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use proxmox::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
|
||||
use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use pbs_api_types::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
|
||||
|
||||
use pbs_api_types::{
|
||||
PROXMOX_CONFIG_DIGEST_SCHEMA, FIRST_DNS_SERVER_SCHEMA, SECOND_DNS_SERVER_SCHEMA,
|
||||
@ -41,7 +41,7 @@ pub fn read_etc_resolv_conf() -> Result<Value, Error> {
|
||||
|
||||
let raw = file_get_contents(RESOLV_CONF_FN)?;
|
||||
|
||||
result["digest"] = Value::from(proxmox::tools::digest_to_hex(&sha::sha256(&raw)));
|
||||
result["digest"] = Value::from(hex::encode(&sha::sha256(&raw)));
|
||||
|
||||
let data = String::from_utf8(raw)?;
|
||||
|
||||
|
@ -12,8 +12,8 @@ use hyper::Request;
|
||||
use serde_json::{json, Value};
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox::tools::fd::fd_change_cloexec;
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_sys::fd::fd_change_cloexec;
|
||||
|
||||
use proxmox_router::{
|
||||
ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment, Router, SubdirMap,
|
||||
@ -319,7 +319,7 @@ fn upgrade_to_websocket(
|
||||
#[api]
|
||||
/// List Nodes (only for compatiblity)
|
||||
fn list_nodes() -> Result<Value, Error> {
|
||||
Ok(json!([ { "node": proxmox::tools::nodename().to_string() } ]))
|
||||
Ok(json!([ { "node": proxmox_sys::nodename().to_string() } ]))
|
||||
}
|
||||
|
||||
pub const SUBDIRS: SubdirMap = &[
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{Error, bail};
|
||||
use serde_json::{Value, to_value};
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::{api, parse_property_string};
|
||||
@ -92,7 +93,7 @@ pub fn list_network_devices(
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let (config, digest) = network::config()?;
|
||||
let digest = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest = hex::encode(&digest);
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
@ -136,7 +137,7 @@ pub fn read_interface(iface: String) -> Result<Value, Error> {
|
||||
let interface = config.lookup(&iface)?;
|
||||
|
||||
let mut data: Value = to_value(interface)?;
|
||||
data["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
data["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
@ -528,7 +529,7 @@ pub fn update_interface(
|
||||
let (mut config, expected_digest) = network::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -668,7 +669,7 @@ pub fn delete_interface(iface: String, digest: Option<String>) -> Result<(), Err
|
||||
let (mut config, expected_digest) = network::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::process::{Command, Stdio};
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{list_subdirs_api_method, Router, Permission, RpcEnvironment, SubdirMap};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||
use anyhow::{Error, format_err, bail};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::sys::linux::procfs;
|
||||
use proxmox_sys::linux::procfs;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
|
@ -4,7 +4,7 @@ use std::io::{BufRead, BufReader};
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_router::{list_subdirs_api_method, Router, RpcEnvironment, Permission, SubdirMap};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::tools::fs::{file_read_firstline, replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{file_read_firstline, replace_file, CreateOptions};
|
||||
use proxmox_router::{Router, Permission};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
Reference in New Issue
Block a user