[pve-devel] [PATCH 38/48] sheepdog : add volume_rename

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


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

diff --git a/PVE/Storage/SheepdogPlugin.pm b/PVE/Storage/SheepdogPlugin.pm
index 0e658f4..107bb9d 100644
--- a/PVE/Storage/SheepdogPlugin.pm
+++ b/PVE/Storage/SheepdogPlugin.pm
@@ -366,4 +366,27 @@ sub volume_clone {
 
     return "$volname/$volnamedst";
 }
+
+sub volume_rename {
+    my ($class, $scfg, $storeid, $volname, $vmiddest, $type) = @_;
+
+    my $targetvolname = $class->find_free_volname($storeid, $scfg, $vmiddest, undef, $type);
+
+    my $snapname = 'tempforrename';
+
+    my $cmd = &$collie_cmd($scfg, 'vdi', 'snapshot', '-s', $snapname, $volname);
+    run_command($cmd, errmsg => "sheepdog snapshot $volname' error");
+
+    $cmd = &$collie_cmd($scfg, 'vdi', 'clone', '-s', $snapname, $volname, $targetvolname);
+    run_command($cmd, errmsg => "sheepdog clone $volname' error");
+
+    $cmd = &$collie_cmd($scfg, 'vdi', 'delete', '-s', $snapname, $volname);
+    run_command($cmd, errmsg => "sheepdog delete snapshot $volname' error");
+
+    $cmd = &$collie_cmd($scfg, 'vdi', 'delete' , $volname);
+    run_command($cmd, errmsg => "sheepdog delete $volname' error");
+
+    return $targetvolname;
+}
+
 1;
-- 
1.7.10.4




More information about the pve-devel mailing list