[pbs-devel] [PATCH proxmox-backup 2/2] fix #2847: proxmox-backup-client: add change-owner cmd
Dietmar Maurer
dietmar at proxmox.com
Wed Oct 14 08:56:48 CEST 2020
applied, adopted to previous api changes
> On 10/13/2020 10:58 AM Dylan Whyte <d.whyte at proxmox.com> wrote:
>
>
> This adds a change-owner command to proxmox-backup-client,
> that allows a caller with datastore modify privileges
> to change the owner of a backup-group.
>
> Signed-off-by: Dylan Whyte <d.whyte at proxmox.com>
> ---
> src/bin/proxmox-backup-client.rs | 43 +++++++++++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
> index 97398f49..90cb8378 100644
> --- a/src/bin/proxmox-backup-client.rs
> +++ b/src/bin/proxmox-backup-client.rs
> @@ -412,6 +412,41 @@ async fn list_backup_groups(param: Value) -> Result<Value, Error> {
> Ok(Value::Null)
> }
>
> +#[api(
> + input: {
> + properties: {
> + repository: {
> + schema: REPO_URL_SCHEMA,
> + optional: true,
> + },
> + group: {
> + type: String,
> + description: "Backup group.",
> + },
> + "new-owner": {
> + type: String,
type: Userid
> + description: "Userid to transfer ownership to",
> + },
> + }
> + }
> +)]
> +/// Change owner of a backup group
> +async fn change_backup_owner(mut param: Value) -> Result<(), Error> {
> +
> + let repo = extract_repository_from_value(¶m)?;
> +
> + let mut client = connect(repo.host(), repo.port(), repo.user())?;
> +
> + param.as_object_mut().unwrap().remove("repository");
> +
> + let path = format!("api2/json/admin/datastore/{}/change-owner", repo.store());
> + client.post(&path, Some(param)).await?;
> +
> + record_repository(&repo);
> +
> + Ok(())
> +}
> +
> #[api(
> input: {
> properties: {
> @@ -1967,6 +2002,11 @@ fn main() {
> let version_cmd_def = CliCommand::new(&API_METHOD_API_VERSION)
> .completion_cb("repository", complete_repository);
>
> + let change_owner_cmd_def = CliCommand::new(&API_METHOD_CHANGE_BACKUP_OWNER)
> + .arg_param(&["group", "new-owner"])
> + .completion_cb("group", complete_backup_group)
added: .completion_cb("new-owner", complete_user_name)
> + .completion_cb("repository", complete_repository);
> +
> let cmd_def = CliCommandMap::new()
> .insert("backup", backup_cmd_def)
> .insert("upload-log", upload_log_cmd_def)
> @@ -1987,7 +2027,8 @@ fn main() {
> .insert("catalog", catalog_mgmt_cli())
> .insert("task", task_mgmt_cli())
> .insert("version", version_cmd_def)
> - .insert("benchmark", benchmark_cmd_def);
> + .insert("benchmark", benchmark_cmd_def)
> + .insert("change-owner", change_owner_cmd_def);
>
> let rpcenv = CliEnvironment::new();
> run_cli_command(cmd_def, rpcenv, Some(|future| {
> --
> 2.20.1
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
More information about the pbs-devel
mailing list