]> git.proxmox.com Git - pve-storage.git/commitdiff
rbd : clone_image
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 5 Feb 2013 11:55:34 +0000 (12:55 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 14 Feb 2013 08:37:16 +0000 (09:37 +0100)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Storage/RBDPlugin.pm

index cccf936e54c91ce5e7f0931d86b434c5a5e4ae47..4936d8f20bd3e61eca49e77ea036c7eab4849517 100644 (file)
@@ -252,7 +252,23 @@ sub create_base {
 sub clone_image {
     my ($class, $scfg, $storeid, $volname, $vmid) = @_;
 
-    die "not implemented";
+    my $snap = '__base__';
+
+    my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
+        $class->parse_volname($volname);
+
+    die "clone_image onyl works on base images\n" if !$isBase;
+
+    my $name = &$find_free_diskname($storeid, $scfg, $vmid);
+
+    warn "clone $volname: $basename to $name\n";
+
+    my $newvol = "$basename/$name";
+
+    my $cmd = &$rbd_cmd($scfg, $storeid, 'clone', $basename, '--snap', $snap, $name);
+    run_command($cmd, errmsg => "rbd clone $basename' error", errfunc => sub {});
+
+    return $newvol;
 }
 
 my $find_free_diskname = sub {