]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/GlusterfsPlugin.pm
fix prune-backups validation (again)
[pve-storage.git] / PVE / Storage / GlusterfsPlugin.pm
index b3e5553416474eb812c4299c4b220c7ab43a422e..ea4df82a9682f949c74ac4445632d8256c9d60b1 100644 (file)
@@ -97,7 +97,7 @@ sub type {
 
 sub plugindata {
     return {
-       content => [ { images => 1, vztmpl => 1, iso => 1, backup => 1},
+       content => [ { images => 1, vztmpl => 1, iso => 1, backup => 1, snippets => 1},
                     { images => 1 }],
        format => [ { raw => 1, qcow2 => 1, vmdk => 1 } , 'raw' ],
     };
@@ -129,9 +129,10 @@ sub options {
        server2 => { optional => 1 },
        volume => { fixed => 1 },
        transport => { optional => 1 },
-        nodes => { optional => 1 },
+       nodes => { optional => 1 },
        disable => { optional => 1 },
-        maxfiles => { optional => 1 },
+       maxfiles => { optional => 1 },
+       'prune-backups' => { optional => 1 },
        content => { optional => 1 },
        format => { optional => 1 },
        mkdir => { optional => 1 },
@@ -160,17 +161,6 @@ sub parse_name_dir {
     die "unable to parse volume filename '$name'\n";
 }
 
-my $find_free_diskname = sub {
-    my ($imgdir, $vmid, $fmt, $scfg) = @_;
-
-    my $disk_list = [];
-
-    my $dh = IO::Dir->new ($imgdir);
-    @$disk_list = $dh->read() if defined($dh);
-
-    return PVE::Storage::Plugin::get_next_vm_diskname($disk_list, $imgdir, $vmid, $fmt, $scfg, 1);
-};
-
 sub path {
     my ($class, $scfg, $volname, $storeid, $snapname) = @_;
 
@@ -207,7 +197,7 @@ sub path {
 sub clone_image {
     my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
 
-    die "storage definintion has no path\n" if !$scfg->{path};
+    die "storage definition has no path\n" if !$scfg->{path};
 
     my ($vtype, $basename, $basevmid, undef, undef, $isBase, $format) =
        $class->parse_volname($volname);
@@ -225,7 +215,7 @@ sub clone_image {
 
     mkpath $imagedir;
 
-    my $name = $find_free_diskname->($imagedir, $vmid, "qcow2", $scfg);
+    my $name = $class->find_free_diskname($storeid, $scfg, $vmid, "qcow2", 1);
 
     warn "clone $volname: $vtype, $name, $vmid to $name (base=../$basevmid/$basename)\n";
 
@@ -238,7 +228,7 @@ sub clone_image {
     my $volumepath = "gluster://$server/$glustervolume/images/$vmid/$name";
 
     my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
-              '-f', 'qcow2', $volumepath];
+              '-F', $format, '-f', 'qcow2', $volumepath];
 
     run_command($cmd, errmsg => "unable to create image");
 
@@ -253,7 +243,7 @@ sub alloc_image {
 
     mkpath $imagedir;
 
-    $name = $find_free_diskname->($imagedir, $vmid, $fmt, $scfg) if !$name;
+    $name = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt, 1) if !$name;
 
     my (undef, $tmpfmt) = parse_name_dir($name);