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

index a39faf4794e1db0074ff5961ea302f627c38fd19..93cfc8b398033600cd4371f5e863d4c3e77c20b2 100644 (file)
@@ -241,7 +241,32 @@ my $find_free_diskname = sub {
 sub create_base {
     my ($class, $storeid, $scfg, $volname) = @_;
 
-    die "not implemented";
+    my $snap = '__base__';
+
+    my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
+        $class->parse_volname($volname);
+
+    die "create_base not possible with base image\n" if $isBase;
+
+#    die "volname '$volname' contains wrong information about parent $parent $basename\n"
+#        if $basename && (!$parent || $parent ne $basename."@".$snap);
+
+    my $newname = $name;
+    $newname =~ s/^vm-/base-/;
+
+    my $newvolname = $basename ? "$basename/$newname" : "$newname";
+
+    #we can't rename a nexenta volume, so clone it to a new volname
+    nexenta_request($scfg, 'create_snapshot', 'zvol', "$scfg->{pool}/$name", $snap, '');
+    nexenta_request($scfg, 'clone', 'zvol', "$scfg->{pool}/$name\@$snap", "$scfg->{pool}/$newname");
+    nexenta_create_lu($scfg, $newname);
+    nexenta_add_lun_mapping_entry($scfg, $newname);
+
+    my $running  = undef; #fixme : is create_base always offline ?
+
+    $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
+
+    return $newvolname;
 }
 
 sub clone_image {