From e351ac786d33d5be53818447778fbe088afdfa7a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 26 Aug 2021 11:00:37 +0200 Subject: [PATCH] split out proxmox-backup-client binary Signed-off-by: Wolfgang Bumiller --- Cargo.toml | 2 +- Makefile | 4 ++- proxmox-backup-client/Cargo.toml | 34 +++++++++++++++++++ .../src}/benchmark.rs | 0 .../src}/catalog.rs | 0 .../src}/key.rs | 0 .../src/main.rs | 17 +++++++--- .../src}/mount.rs | 0 .../src}/snapshot.rs | 5 ++- .../src}/task.rs | 2 +- src/bin/proxmox_backup_client/mod.rs | 13 ------- 11 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 proxmox-backup-client/Cargo.toml rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/benchmark.rs (100%) rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/catalog.rs (100%) rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/key.rs (100%) rename src/bin/proxmox-backup-client.rs => proxmox-backup-client/src/main.rs (99%) rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/mount.rs (100%) rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/snapshot.rs (98%) rename {src/bin/proxmox_backup_client => proxmox-backup-client/src}/task.rs (97%) delete mode 100644 src/bin/proxmox_backup_client/mod.rs diff --git a/Cargo.toml b/Cargo.toml index fa0fc1173..40b75124a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ members = [ "pbs-tools", "proxmox-backup-banner", + "proxmox-backup-client", "pxar-bin", ] @@ -98,7 +99,6 @@ pbs-api-types = { path = "pbs-api-types" } pbs-buildcfg = { path = "pbs-buildcfg" } pbs-client = { path = "pbs-client" } pbs-datastore = { path = "pbs-datastore" } -pbs-fuse-loop = { path = "pbs-fuse-loop" } pbs-runtime = { path = "pbs-runtime" } pbs-systemd = { path = "pbs-systemd" } pbs-tools = { path = "pbs-tools" } diff --git a/Makefile b/Makefile index d6c1acf5e..b2a8e5b42 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ SUBCRATES := \ pbs-systemd \ pbs-tools \ proxmox-backup-banner \ + proxmox-backup-client \ pxar-bin ifeq ($(BUILD_MODE), release) @@ -167,12 +168,13 @@ $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do- $(CARGO) build $(CARGO_BUILD_ARGS) \ --package proxmox-backup-banner \ --bin proxmox-backup-banner \ + --package proxmox-backup-client \ + --bin proxmox-backup-client \ --package pxar-bin \ --bin pxar \ --package proxmox-backup \ --bin dump-catalog-shell-cli \ --bin pmt --bin pmtx \ - --bin proxmox-backup-client \ --bin proxmox-daily-update \ --bin proxmox-file-restore \ --bin proxmox-restore-daemon \ diff --git a/proxmox-backup-client/Cargo.toml b/proxmox-backup-client/Cargo.toml new file mode 100644 index 000000000..b6e138072 --- /dev/null +++ b/proxmox-backup-client/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "proxmox-backup-client" +version = "0.1.0" +authors = ["Proxmox Support Team "] +edition = "2018" + +[dependencies] +anyhow = "1.0" +futures = "0.3" +hyper = { version = "0.14", features = [ "full" ] } +libc = "0.2" +nix = "0.19.1" +openssl = "0.10" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] } +tokio-stream = "0.1.0" +tokio-util = { version = "0.6", features = [ "codec", "io" ] } +xdg = "2.2" +zstd = { version = "0.6", features = [ "bindgen" ] } + +pathpatterns = "0.1.2" +pxar = { version = "0.10.1", features = [ "tokio-io" ] } + +proxmox = { version = "0.13.0", features = [ "sortable-macro", "api-macro", "cli", "router" ] } + +pbs-api-types = { path = "../pbs-api-types" } +pbs-buildcfg = { path = "../pbs-buildcfg" } +pbs-client = { path = "../pbs-client" } +pbs-datastore = { path = "../pbs-datastore" } +pbs-fuse-loop = { path = "../pbs-fuse-loop" } +pbs-runtime = { path = "../pbs-runtime" } +pbs-systemd = { path = "../pbs-systemd" } +pbs-tools = { path = "../pbs-tools" } diff --git a/src/bin/proxmox_backup_client/benchmark.rs b/proxmox-backup-client/src/benchmark.rs similarity index 100% rename from src/bin/proxmox_backup_client/benchmark.rs rename to proxmox-backup-client/src/benchmark.rs diff --git a/src/bin/proxmox_backup_client/catalog.rs b/proxmox-backup-client/src/catalog.rs similarity index 100% rename from src/bin/proxmox_backup_client/catalog.rs rename to proxmox-backup-client/src/catalog.rs diff --git a/src/bin/proxmox_backup_client/key.rs b/proxmox-backup-client/src/key.rs similarity index 100% rename from src/bin/proxmox_backup_client/key.rs rename to proxmox-backup-client/src/key.rs diff --git a/src/bin/proxmox-backup-client.rs b/proxmox-backup-client/src/main.rs similarity index 99% rename from src/bin/proxmox-backup-client.rs rename to proxmox-backup-client/src/main.rs index faf2c0a3c..d8dd04456 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/proxmox-backup-client/src/main.rs @@ -76,8 +76,17 @@ use pbs_tools::sync::StdChannelWriter; use pbs_tools::tokio::TokioWriterAdapter; use pbs_tools::json; -mod proxmox_backup_client; -use proxmox_backup_client::*; +mod benchmark; +pub use benchmark::*; +mod mount; +pub use mount::*; +mod task; +pub use task::*; +mod catalog; +pub use catalog::*; +mod snapshot; +pub use snapshot::*; +pub mod key; fn record_repository(repo: &BackupRepository) { @@ -295,7 +304,7 @@ async fn list_backup_groups(param: Value) -> Result { let mut data: Value = result["data"].take(); - let return_type = &proxmox_backup::api2::admin::datastore::API_METHOD_LIST_GROUPS.returns; + let return_type = &pbs_api_types::ADMIN_DATASTORE_LIST_GROUPS_RETURN_TYPE; format_and_print_result_full(&mut data, return_type, &output_format, &options); @@ -1310,7 +1319,7 @@ async fn prune( .column(ColumnConfig::new("keep").renderer(render_prune_action).header("action")) ; - let return_type = &proxmox_backup::api2::admin::datastore::API_METHOD_PRUNE.returns; + let return_type = &pbs_api_types::ADMIN_DATASTORE_PRUNE_RETURN_TYPE; let mut data = result["data"].take(); diff --git a/src/bin/proxmox_backup_client/mount.rs b/proxmox-backup-client/src/mount.rs similarity index 100% rename from src/bin/proxmox_backup_client/mount.rs rename to proxmox-backup-client/src/mount.rs diff --git a/src/bin/proxmox_backup_client/snapshot.rs b/proxmox-backup-client/src/snapshot.rs similarity index 98% rename from src/bin/proxmox_backup_client/snapshot.rs rename to proxmox-backup-client/src/snapshot.rs index 631a3a537..b63e84a6c 100644 --- a/src/bin/proxmox_backup_client/snapshot.rs +++ b/proxmox-backup-client/src/snapshot.rs @@ -91,7 +91,7 @@ async fn list_snapshots(param: Value) -> Result { .column(ColumnConfig::new("files").renderer(render_files)) ; - let return_type = &proxmox_backup::api2::admin::datastore::API_METHOD_LIST_SNAPSHOTS.returns; + let return_type = &pbs_api_types::ADMIN_DATASTORE_LIST_SNAPSHOTS_RETURN_TYPE; format_and_print_result_full(&mut data, return_type, &output_format, &options); @@ -138,8 +138,7 @@ async fn list_snapshot_files(param: Value) -> Result { record_repository(&repo); - let return_type = - &proxmox_backup::api2::admin::datastore::API_METHOD_LIST_SNAPSHOT_FILES.returns; + let return_type = &pbs_api_types::ADMIN_DATASTORE_LIST_SNAPSHOT_FILES_RETURN_TYPE; let mut data: Value = result["data"].take(); diff --git a/src/bin/proxmox_backup_client/task.rs b/proxmox-backup-client/src/task.rs similarity index 97% rename from src/bin/proxmox_backup_client/task.rs rename to proxmox-backup-client/src/task.rs index 121f084b4..92d0d69f2 100644 --- a/src/bin/proxmox_backup_client/task.rs +++ b/proxmox-backup-client/src/task.rs @@ -65,7 +65,7 @@ async fn task_list(param: Value) -> Result { let mut result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?; let mut data = result["data"].take(); - let return_type = &proxmox_backup::api2::node::tasks::API_METHOD_LIST_TASKS.returns; + let return_type = &pbs_api_types::NODE_TASKS_LIST_TASKS_RETURN_TYPE; use pbs_tools::format::{render_epoch, render_task_status}; let options = default_table_format_options() diff --git a/src/bin/proxmox_backup_client/mod.rs b/src/bin/proxmox_backup_client/mod.rs deleted file mode 100644 index d272dc8f6..000000000 --- a/src/bin/proxmox_backup_client/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -mod benchmark; -pub use benchmark::*; -mod mount; -pub use mount::*; -mod task; -pub use task::*; -mod catalog; -pub use catalog::*; -mod snapshot; -pub use snapshot::*; - -pub mod key; -