[pve-devel] [PATCH 36/48] plugin : add volume_rename
Alexandre Derumier
aderumier at odiso.com
Tue Jan 29 17:14:18 CET 2013
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage/Plugin.pm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 07c6fc2..c4a5e39 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -622,6 +622,28 @@ sub volume_protect {
return undef;
}
+sub volume_rename {
+ my ($class, $scfg, $storeid, $volname, $vmiddest, $type) = @_;
+
+ my $imagedir = $class->get_subdir($scfg, 'images');
+ my $format = undef;
+
+ if ($volname =~ m!^(\d+)/(\S+)$!) {
+ my ($vmid, $srcname) = ($1, $2);
+ (undef, $format) = parse_name_dir($srcname);
+ }
+
+ my $name = $class->find_free_volname($storeid, $scfg, $vmiddest, $format, $type);
+
+ my $targetvolname = "$vmiddest/$name";
+
+ my $cmd = ['mv', "$imagedir/$volname" , "$imagedir/$targetvolname"];
+
+ run_command($cmd, timeout => 10);
+
+ return $targetvolname;
+}
+
sub list_images {
my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
--
1.7.10.4
More information about the pve-devel
mailing list