]> git.proxmox.com Git - pve-storage.git/commitdiff
nexenta : clone_image
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 5 Feb 2013 11:56:03 +0000 (12:56 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 14 Feb 2013 09:31:39 +0000 (10:31 +0100)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Storage/NexentaPlugin.pm

index 93cfc8b398033600cd4371f5e863d4c3e77c20b2..ad8ac7df6e79bf6451073f909a7d242e0d3c60c1 100644 (file)
@@ -272,7 +272,25 @@ 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 only 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";
+
+    nexenta_request($scfg, 'clone', 'zvol', "$scfg->{pool}/$basename\@$snap", "$scfg->{pool}/$name");
+
+    nexenta_create_lu($scfg, $name);
+    nexenta_add_lun_mapping_entry($scfg, $name);
+
+    return $newvol;
 }
 
 sub alloc_image {