public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create
@ 2021-06-08 14:08 Dominik Csapak
  2021-06-22  7:03 ` Dominik Csapak
  2021-06-28 10:11 ` [pbs-devel] applied: " Dietmart Maurer
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-06-08 14:08 UTC (permalink / raw)
  To: pbs-devel

since the output:
Result: "<UPID>"
is not really interesting, show instead the task log while
the datastore is creating, since it is now run in a worker

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/bin/proxmox_backup_manager/datastore.rs | 82 ++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)

diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
index 7e596a1b..7cbd8805 100644
--- a/src/bin/proxmox_backup_manager/datastore.rs
+++ b/src/bin/proxmox_backup_manager/datastore.rs
@@ -5,6 +5,11 @@ use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
 
 use proxmox_backup::config;
 use proxmox_backup::api2::{self, types::* };
+use proxmox_backup::client::{
+    connect_to_localhost,
+    view_task_result,
+};
+use proxmox_backup::config::datastore::DIR_NAME_SCHEMA;
 
 #[api(
     input: {
@@ -67,6 +72,81 @@ fn show_datastore(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
     Ok(Value::Null)
 }
 
+#[api(
+    protected: true,
+    input: {
+        properties: {
+            name: {
+                schema: DATASTORE_SCHEMA,
+            },
+            path: {
+                schema: DIR_NAME_SCHEMA,
+            },
+            comment: {
+                optional: true,
+                schema: SINGLE_LINE_COMMENT_SCHEMA,
+            },
+            "notify-user": {
+                optional: true,
+                type: Userid,
+            },
+            "notify": {
+                optional: true,
+                schema: DATASTORE_NOTIFY_STRING_SCHEMA,
+            },
+            "gc-schedule": {
+                optional: true,
+                schema: GC_SCHEDULE_SCHEMA,
+            },
+            "prune-schedule": {
+                optional: true,
+                schema: PRUNE_SCHEDULE_SCHEMA,
+            },
+            "keep-last": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_LAST,
+            },
+            "keep-hourly": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_HOURLY,
+            },
+            "keep-daily": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_DAILY,
+            },
+            "keep-weekly": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_WEEKLY,
+            },
+            "keep-monthly": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_MONTHLY,
+            },
+            "keep-yearly": {
+                optional: true,
+                schema: PRUNE_SCHEMA_KEEP_YEARLY,
+            },
+            "output-format": {
+                schema: OUTPUT_FORMAT,
+                optional: true,
+            },
+        },
+    },
+)]
+/// Create new datastore config.
+async fn create_datastore(mut param: Value) -> Result<Value, Error> {
+
+    let output_format = extract_output_format(&mut param);
+
+    let mut client = connect_to_localhost()?;
+
+    let result = client.post(&"api2/json/config/datastore", Some(param)).await?;
+
+    view_task_result(&mut client, result, &output_format).await?;
+
+    Ok(Value::Null)
+}
+
 pub fn datastore_commands() -> CommandLineInterface {
 
     let cmd_def = CliCommandMap::new()
@@ -77,7 +157,7 @@ pub fn datastore_commands() -> CommandLineInterface {
                 .completion_cb("name", config::datastore::complete_datastore_name)
         )
         .insert("create",
-                CliCommand::new(&api2::config::datastore::API_METHOD_CREATE_DATASTORE)
+                CliCommand::new(&API_METHOD_CREATE_DATASTORE)
                 .arg_param(&["name", "path"])
         )
         .insert("update",
-- 
2.20.1





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create
  2021-06-08 14:08 [pbs-devel] [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create Dominik Csapak
@ 2021-06-22  7:03 ` Dominik Csapak
  2021-06-28 10:11 ` [pbs-devel] applied: " Dietmart Maurer
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-06-22  7:03 UTC (permalink / raw)
  To: pbs-devel

as it turns out, this patch not only improves the visible feedback,
but actually fixes a but where one cannot create
the datastore via cli

seemingly, embedding an async api call into the clihandler that
returns a upid and starts a worker, does not start
in proxmox-backup-proxy, but directly in the cli handler?

which gets cancelled as soon as the upid is  printed?

see https://bugzilla.proxmox.com/show_bug.cgi?id=3486

On 6/8/21 16:08, Dominik Csapak wrote:
> since the output:
> Result: "<UPID>"
> is not really interesting, show instead the task log while
> the datastore is creating, since it is now run in a worker
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>   src/bin/proxmox_backup_manager/datastore.rs | 82 ++++++++++++++++++++-
>   1 file changed, 81 insertions(+), 1 deletion(-)
> 
> diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
> index 7e596a1b..7cbd8805 100644
> --- a/src/bin/proxmox_backup_manager/datastore.rs
> +++ b/src/bin/proxmox_backup_manager/datastore.rs
> @@ -5,6 +5,11 @@ use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
>   
>   use proxmox_backup::config;
>   use proxmox_backup::api2::{self, types::* };
> +use proxmox_backup::client::{
> +    connect_to_localhost,
> +    view_task_result,
> +};
> +use proxmox_backup::config::datastore::DIR_NAME_SCHEMA;
>   
>   #[api(
>       input: {
> @@ -67,6 +72,81 @@ fn show_datastore(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
>       Ok(Value::Null)
>   }
>   
> +#[api(
> +    protected: true,
> +    input: {
> +        properties: {
> +            name: {
> +                schema: DATASTORE_SCHEMA,
> +            },
> +            path: {
> +                schema: DIR_NAME_SCHEMA,
> +            },
> +            comment: {
> +                optional: true,
> +                schema: SINGLE_LINE_COMMENT_SCHEMA,
> +            },
> +            "notify-user": {
> +                optional: true,
> +                type: Userid,
> +            },
> +            "notify": {
> +                optional: true,
> +                schema: DATASTORE_NOTIFY_STRING_SCHEMA,
> +            },
> +            "gc-schedule": {
> +                optional: true,
> +                schema: GC_SCHEDULE_SCHEMA,
> +            },
> +            "prune-schedule": {
> +                optional: true,
> +                schema: PRUNE_SCHEDULE_SCHEMA,
> +            },
> +            "keep-last": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_LAST,
> +            },
> +            "keep-hourly": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_HOURLY,
> +            },
> +            "keep-daily": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_DAILY,
> +            },
> +            "keep-weekly": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_WEEKLY,
> +            },
> +            "keep-monthly": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_MONTHLY,
> +            },
> +            "keep-yearly": {
> +                optional: true,
> +                schema: PRUNE_SCHEMA_KEEP_YEARLY,
> +            },
> +            "output-format": {
> +                schema: OUTPUT_FORMAT,
> +                optional: true,
> +            },
> +        },
> +    },
> +)]
> +/// Create new datastore config.
> +async fn create_datastore(mut param: Value) -> Result<Value, Error> {
> +
> +    let output_format = extract_output_format(&mut param);
> +
> +    let mut client = connect_to_localhost()?;
> +
> +    let result = client.post(&"api2/json/config/datastore", Some(param)).await?;
> +
> +    view_task_result(&mut client, result, &output_format).await?;
> +
> +    Ok(Value::Null)
> +}
> +
>   pub fn datastore_commands() -> CommandLineInterface {
>   
>       let cmd_def = CliCommandMap::new()
> @@ -77,7 +157,7 @@ pub fn datastore_commands() -> CommandLineInterface {
>                   .completion_cb("name", config::datastore::complete_datastore_name)
>           )
>           .insert("create",
> -                CliCommand::new(&api2::config::datastore::API_METHOD_CREATE_DATASTORE)
> +                CliCommand::new(&API_METHOD_CREATE_DATASTORE)
>                   .arg_param(&["name", "path"])
>           )
>           .insert("update",
> 





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create
  2021-06-08 14:08 [pbs-devel] [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create Dominik Csapak
  2021-06-22  7:03 ` Dominik Csapak
@ 2021-06-28 10:11 ` Dietmart Maurer
  1 sibling, 0 replies; 3+ messages in thread
From: Dietmart Maurer @ 2021-06-28 10:11 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-28 10:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 14:08 [pbs-devel] [PATCH proxmox-backup] proxmox-backup-manager: show task log on datastore create Dominik Csapak
2021-06-22  7:03 ` Dominik Csapak
2021-06-28 10:11 ` [pbs-devel] applied: " Dietmart Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal