[pve-devel] [PATCH 35/48] storage : add volume_rename

Alexandre Derumier aderumier at odiso.com
Tue Jan 29 17:14:17 CET 2013


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage.pm |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 491bca9..919c79b 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -229,6 +229,22 @@ sub volume_protect {
     }
 }
 
+sub volume_rename {
+    my ($cfg, $volid, $vmiddest, $type) = @_;
+
+    my ($storeid, $volname) = parse_volume_id($volid, 1);
+    if ($storeid) {
+        my $scfg = storage_config($cfg, $storeid);
+        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+        my $newvolname = $plugin->volume_rename($scfg, $storeid, $volname, $vmiddest, $type);
+	return "$storeid:$newvolname";
+    } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+        die "rename device is not possible";
+    } else {
+        die "can't rename";
+    }
+}
+
 sub get_image_dir {
     my ($cfg, $storeid, $vmid) = @_;
 
-- 
1.7.10.4




More information about the pve-devel mailing list