another import cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-09-01 14:37:11 +02:00
parent 42dad3abd3
commit 4c1b776168
20 changed files with 42 additions and 41 deletions

View File

@ -121,6 +121,8 @@ const_regex! {
DNS_NAME!(), "|", IPRE_BRACKET!(),
"):)?(?:([0-9]{1,5}):)?(", PROXMOX_SAFE_ID_REGEX_STR!(), r")$"
);
pub BLOCKDEVICE_NAME_REGEX = r"^(:?(:?h|s|x?v)d[a-z]+)|(:?nvme\d+n\d+)$";
}
pub const IP_V4_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&IP_V4_REGEX);

View File

@ -273,7 +273,7 @@ fn apt_get_changelog(
command.arg("changelog");
command.arg("-qq"); // don't display download progress
command.arg(name);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
Ok(json!(output))
}
}

View File

@ -244,7 +244,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 crate::tools::run_command(command, None) {
match pbs_tools::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!",

View File

@ -356,7 +356,7 @@ pub fn create_zpool(
worker.log(format!("# {:?}", command));
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
worker.log(output);
if std::path::Path::new("/lib/systemd/system/zfs-import@.service").exists() {
@ -368,7 +368,7 @@ pub fn create_zpool(
let mut command = std::process::Command::new("zfs");
command.args(&["set", &format!("compression={}", compression), &name]);
worker.log(format!("# {:?}", command));
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
worker.log(output);
}

View File

@ -39,8 +39,6 @@ const_regex!{
pub SUBSCRIPTION_KEY_REGEX = concat!(r"^pbs(?:[cbsp])-[0-9a-f]{10}$");
pub BLOCKDEVICE_NAME_REGEX = r"^(:?(:?h|s|x?v)d[a-z]+)|(:?nvme\d+n\d+)$";
pub ZPOOL_NAME_REGEX = r"^[a-zA-Z][a-z0-9A-Z\-_.:]+$";
pub DATASTORE_MAP_REGEX = concat!(r"(:?", PROXMOX_SAFE_ID_REGEX_STR!(), r"=)?", PROXMOX_SAFE_ID_REGEX_STR!());

View File

@ -1,8 +1,6 @@
///! Daemon binary to run inside a micro-VM for secure single file restore of disk images
use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use log::{error, info};
use std::fs::File;
use std::io::prelude::*;
use std::os::unix::{
io::{FromRawFd, RawFd},
net,
@ -10,16 +8,16 @@ use std::os::unix::{
use std::path::Path;
use std::sync::{Arc, Mutex};
use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use log::{error, info};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use pbs_client::DEFAULT_VSOCK_PORT;
use proxmox::api::RpcEnvironmentType;
use proxmox_backup::server::{rest::*, ApiConfig};
use std::fs::File;
use std::io::prelude::*;
use pbs_client::DEFAULT_VSOCK_PORT;
mod proxmox_restore_daemon;
use proxmox_restore_daemon::*;

View File

@ -9,10 +9,10 @@ use futures::FutureExt;
use hyper::http::request::Parts;
use hyper::{header, Body, Response, StatusCode};
use log::error;
use pathpatterns::{MatchEntry, MatchPattern, MatchType, Pattern};
use serde_json::Value;
use tokio::sync::Semaphore;
use pathpatterns::{MatchEntry, MatchPattern, MatchType, Pattern};
use proxmox::api::{
api, schema::*, ApiHandler, ApiMethod, ApiResponseFuture, Permission, Router, RpcEnvironment,
SubdirMap,

View File

@ -1,10 +1,11 @@
//! Authentication via a static ticket file
use anyhow::{bail, format_err, Error};
use std::fs::File;
use std::io::prelude::*;
use proxmox_backup::api2::types::Authid;
use anyhow::{bail, format_err, Error};
use pbs_api_types::Authid;
use proxmox_backup::config::cached_user_info::CachedUserInfo;
use proxmox_backup::server::auth::{ApiAuth, AuthError};

View File

@ -1,18 +1,19 @@
//! Low-level disk (image) access functions for file restore VMs.
use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use log::{info, warn};
use std::collections::HashMap;
use std::fs::{create_dir_all, File};
use std::io::{BufRead, BufReader};
use std::path::{Component, Path, PathBuf};
use std::process::Command;
use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use log::{info, warn};
use proxmox::const_regex;
use proxmox::tools::fs;
use proxmox_backup::api2::types::BLOCKDEVICE_NAME_REGEX;
use proxmox_backup::tools::run_command;
use pbs_api_types::BLOCKDEVICE_NAME_REGEX;
use pbs_tools::run_command;
const_regex! {
VIRTIO_PART_REGEX = r"^vd[a-z]+(\d+)$";

View File

@ -1,5 +1,6 @@
//! Tokio-based watchdog that shuts down the VM if not pinged for TIMEOUT
use std::sync::atomic::{AtomicI64, Ordering};
use proxmox::tools::time::epoch_i64;
const TIMEOUT: i64 = 600; // seconds

View File

@ -188,7 +188,7 @@ pub fn compute_file_diff(filename: &str, shadow: &str) -> Result<String, Error>
.output()
.map_err(|err| format_err!("failed to execute diff - {}", err))?;
let diff = crate::tools::command_output_as_string(output, Some(|c| c == 0 || c == 1))
let diff = pbs_tools::command_output_as_string(output, Some(|c| c == 0 || c == 1))
.map_err(|err| format_err!("diff failed: {}", err))?;
Ok(diff)
@ -209,7 +209,7 @@ pub fn network_reload() -> Result<(), Error> {
.output()
.map_err(|err| format_err!("failed to execute 'ifreload' - {}", err))?;
crate::tools::command_output(output, None)
pbs_tools::command_output(output, None)
.map_err(|err| format_err!("ifreload failed: {}", err))?;

View File

@ -1,7 +1,8 @@
use anyhow::Error;
use pbs_tools::run_command;
use crate::{
tools::run_command,
api2::types::ScsiTapeChanger,
tape::changer::{
MtxStatus,

View File

@ -29,10 +29,10 @@ use proxmox::{
use pbs_api_types::Fingerprint;
use pbs_datastore::key_derivation::KeyConfig;
use pbs_tools::run_command;
use crate::{
config,
tools::run_command,
api2::types::{
MamAttribute,
LtoDriveAndMediaStatus,

View File

@ -101,7 +101,7 @@ fn get_changelog_url(
command.arg("changelog");
command.arg("--print-uris");
command.arg(package);
let output = crate::tools::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
let output = pbs_tools::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
let output = match output.splitn(2, ' ').next() {
Some(output) => {
if output.len() < 2 {

View File

@ -27,7 +27,7 @@ pub fn get_lvm_devices(
let mut command = std::process::Command::new(PVS_BIN_PATH);
command.args(&["--reportformat", "json", "--noheadings", "--readonly", "-o", "pv_name"]);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
let mut device_set: HashSet<u64> = HashSet::new();

View File

@ -19,7 +19,7 @@ use proxmox::sys::linux::procfs::{MountInfo, mountinfo::Device};
use proxmox::{io_bail, io_format_err};
use proxmox::api::api;
use crate::api2::types::{BLOCKDEVICE_NAME_REGEX, StorageStatus};
use pbs_api_types::{BLOCKDEVICE_NAME_REGEX, StorageStatus};
mod zfs;
pub use zfs::*;
@ -574,7 +574,7 @@ pub fn get_lsblk_info() -> Result<Vec<LsblkInfo>, Error> {
let mut command = std::process::Command::new("lsblk");
command.args(&["--json", "-o", "path,parttype,fstype"]);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
let mut output: serde_json::Value = output.parse()?;
@ -886,7 +886,7 @@ pub fn reread_partition_table(disk: &Disk) -> Result<(), Error> {
command.arg("--rereadpt");
command.arg(disk_path);
crate::tools::run_command(command, None)?;
pbs_tools::run_command(command, None)?;
Ok(())
}
@ -905,7 +905,7 @@ pub fn inititialize_gpt_disk(disk: &Disk, uuid: Option<&str>) -> Result<(), Erro
command.arg(disk_path);
command.args(&["-U", uuid]);
crate::tools::run_command(command, None)?;
pbs_tools::run_command(command, None)?;
Ok(())
}
@ -922,7 +922,7 @@ pub fn create_single_linux_partition(disk: &Disk) -> Result<Disk, Error> {
command.args(&["-n1", "-t1:8300"]);
command.arg(disk_path);
crate::tools::run_command(command, None)?;
pbs_tools::run_command(command, None)?;
let mut partitions = disk.partitions()?;
@ -975,7 +975,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
command.args(&["-t", &fs_type]);
command.arg(disk_path);
crate::tools::run_command(command, None)?;
pbs_tools::run_command(command, None)?;
Ok(())
}
@ -1013,7 +1013,7 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
command.args(&["-o", "export"]);
command.arg(disk_path);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
for line in output.lines() {
if let Some(uuid) = line.strip_prefix("UUID=") {

View File

@ -91,7 +91,7 @@ pub fn get_smart_data(
};
command.arg(disk_path);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
let output: serde_json::Value = output.parse()?;

View File

@ -147,7 +147,7 @@ pub fn zpool_list(pool: Option<String>, verbose: bool) -> Result<Vec<ZFSPoolInfo
if let Some(pool) = pool { command.arg(pool); }
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
parse_zpool_list(&output)
}

View File

@ -364,7 +364,7 @@ pub fn zpool_status(pool: &str) -> Result<Vec<(String, String)>, Error> {
let mut command = std::process::Command::new("zpool");
command.args(&["status", "-p", "-P", pool]);
let output = crate::tools::run_command(command, None)?;
let output = pbs_tools::run_command(command, None)?;
parse_zpool_status(&output)
}

View File

@ -17,7 +17,6 @@ use proxmox_http::{
pub use pbs_tools::json;
pub use pbs_tools::nom;
pub use pbs_tools::{run_command, command_output, command_output_as_string};
pub use pbs_tools::process_locker::{
ProcessLocker, ProcessLockExclusiveGuard, ProcessLockSharedGuard
};