[pve-devel] applied: [PATCH storage 1/3] import: add -delete-snapshot parameter

Dietmar Maurer dietmar at proxmox.com
Tue May 23 13:30:09 CEST 2017


applied, but set max length to 80 (replication snapshot names are longer than 40
...)

@@ -261,8 +261,8 @@ __PACKAGE__->register_method ({
            'delete-snapshot' => {
                description => "A snapshot to delete on success",
                type => 'string',
-               pattern => qr/[a-z0-9_\-]{1,40}/,
-               maxLength => 40,
+               pattern => qr/[a-z0-9_\-]{1,80}/,
+               maxLength => 80,
                optional => 1,
            },
        },



> On May 23, 2017 at 12:30 PM Wolfgang Bumiller <w.bumiller at proxmox.com> wrote:
> 
> 
> This deletes a snapshot on *success*, done directly in the
> CLI handler, as the rollback/delete on failure is already
> happening inside the plugin's import method.
> ---
>  PVE/CLI/pvesm.pm | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
> index ba2c91b..7f5748f 100755
> --- a/PVE/CLI/pvesm.pm
> +++ b/PVE/CLI/pvesm.pm
> @@ -258,6 +258,13 @@ __PACKAGE__->register_method ({
>  		optional => 1,
>  		default => 0,
>  	    },
> +	    'delete-snapshot' => {
> +		description => "A snapshot to delete on success",
> +		type => 'string',
> +		pattern => qr/[a-z0-9_\-]{1,40}/,
> +		maxLength => 40,
> +		optional => 1,
> +	    },
>  	},
>      },
>      returns => { type => 'null' },
> @@ -275,8 +282,12 @@ __PACKAGE__->register_method ({
>  	}
>  
>  	my $cfg = PVE::Storage::config();
> -	PVE::Storage::volume_import($cfg, $infh, $param->{volume}, $param->{format},
> +	my $volume = $param->{volume};
> +	my $delete = $param->{'delete-snapshot'};
> +	PVE::Storage::volume_import($cfg, $infh, $volume, $param->{format},
>  	    $param->{base}, $param->{'with-snapshots'});
> +	PVE::Storage::volume_snapshot_delete($cfg, $volume, $delete)
> +	    if defined($delete);
>  	return;
>      }
>  });
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list