storage: add rename_snapshot method
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
bb21ba381d
commit
5f916079ea
@ -26,6 +26,9 @@ Future changes should be documented in here.
|
||||
The parameter *can* be used if some extra actions need to be done at the storage
|
||||
layer when the snapshot has already be done at qemu level when the vm is running.
|
||||
|
||||
* Introduce rename_snapshot() plugin method
|
||||
This method allow to rename a vm disk snapshot name to a different snapshot name.
|
||||
|
||||
## Version 11:
|
||||
|
||||
* Allow declaring storage features via plugin data
|
||||
|
||||
@ -2345,6 +2345,31 @@ sub rename_volume {
|
||||
);
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($cfg, $volid, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "no volid provided\n" if !$volid;
|
||||
die "no source or target snap provided\n" if !$source_snap && !$target_snap;
|
||||
|
||||
my ($storeid, $volname) = parse_volume_id($volid);
|
||||
|
||||
activate_storage($cfg, $storeid);
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
return $plugin->cluster_lock_storage(
|
||||
$storeid,
|
||||
$scfg->{shared},
|
||||
undef,
|
||||
sub {
|
||||
return $plugin->rename_snapshot(
|
||||
$scfg, $storeid, $volname, $source_snap, $target_snap,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
# Various io-heavy operations require io/bandwidth limits which can be
|
||||
# configured on multiple levels: The global defaults in datacenter.cfg, and
|
||||
# per-storage overrides. When we want to do a restore from storage A to storage
|
||||
|
||||
@ -995,6 +995,12 @@ sub rename_volume {
|
||||
return "${storeid}:$target_volname";
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not supported for $class";
|
||||
}
|
||||
|
||||
sub get_import_metadata {
|
||||
return PVE::Storage::DirPlugin::get_import_metadata(@_);
|
||||
}
|
||||
|
||||
@ -497,6 +497,12 @@ sub rename_volume {
|
||||
die "renaming volumes is not supported for $class\n";
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not supported for $class";
|
||||
}
|
||||
|
||||
sub volume_export_formats {
|
||||
my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
|
||||
|
||||
|
||||
@ -866,4 +866,10 @@ sub rename_volume {
|
||||
return "${storeid}:${target_volname}";
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not implemented for $class";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@ -483,4 +483,10 @@ sub volume_import_write {
|
||||
);
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not supported for $class";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@ -2046,6 +2046,22 @@ sub rename_volume {
|
||||
return "${storeid}:${base}${target_vmid}/${target_volname}";
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=head3 rename_snapshot
|
||||
|
||||
$plugin->rename_snapshot($scfg, $storeid, $volname, $source_snap, $target_snap)
|
||||
|
||||
Rename a volume source snapshot C<$source_snap> to a target snapshot C<$target_snap>.
|
||||
|
||||
=cut
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not implemented for $class";
|
||||
}
|
||||
|
||||
my sub blockdev_options_nbd_tcp {
|
||||
my ($host, $port, $export) = @_;
|
||||
|
||||
|
||||
@ -1057,4 +1057,10 @@ sub rename_volume {
|
||||
return "${storeid}:${base_name}${target_volname}";
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not implemented for $class";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@ -895,4 +895,10 @@ sub rename_volume {
|
||||
return "${storeid}:${base_name}${target_volname}";
|
||||
}
|
||||
|
||||
sub rename_snapshot {
|
||||
my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_;
|
||||
|
||||
die "rename_snapshot is not supported for $class";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user