]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/DRBDPlugin.pm
pbs: allow setting up a master key
[pve-storage.git] / PVE / Storage / DRBDPlugin.pm
index 8c19a125254aaeba3084df198f4821aad3494827..6010b47baf1691572c78839e3cb1bc4d74e99bfb 100644 (file)
@@ -1,10 +1,13 @@
 package PVE::Storage::DRBDPlugin;
 
+# FIXME: remove with 7.0
+
 use strict;
 use warnings;
+
 use IO::File;
+# FIXME remove libnet-dbus-perl dependency once this gets removed
 use Net::DBus;
-use Data::Dumper;
 
 use PVE::Tools qw(run_command trim);
 use PVE::INotify;
@@ -45,6 +48,7 @@ sub options {
        content => { optional => 1 },
         nodes => { optional => 1 },
        disable => { optional => 1 },
+       bwlimit => { optional => 1 },
     };
 }
 
@@ -72,10 +76,11 @@ sub check_drbd_res {
     
     die "got undefined drbd result\n" if !$rc;
 
+    # Messages for return codes 1 to 99 are not considered an error.
     foreach my $res (@$rc) {
        my ($code, $format, $details) = @$res;
 
-       next if $code == 0;
+       next if $code < 100;
 
        my $msg;
        if (defined($format)) {
@@ -175,22 +180,11 @@ sub alloc_image {
 
     my $hdl = connect_drbdmanage_service();
     my $volumes = drbd_list_volumes($hdl);
+    my $disk_list = [ keys %$volumes ];
 
     die "volume '$name' already exists\n" if defined($name) && $volumes->{$name};
-    
-    if (!defined($name)) {     
-       for (my $i = 1; $i < 100; $i++) {
-           my $tn = "vm-$vmid-disk-$i";
-           if (!defined ($volumes->{$tn})) {
-               $name = $tn;
-               last;
-           }
-       }
-    }
+    $name //= PVE::Storage::Plugin::get_next_vm_diskname($disk_list, $storeid, $vmid, undef, $scfg);
 
-    die "unable to allocate an image name for VM $vmid in storage '$storeid'\n"
-       if !defined($name);
-    
     my ($rc, $res) = $hdl->create_resource($name, {});
     check_drbd_res($rc);
 
@@ -205,7 +199,7 @@ sub alloc_image {
            'allow-two-primaries' => 'yes',
        });
     check_drbd_res($rc);
+
     my $redundancy = get_redundancy($scfg);;
     
     ($rc, $res) = $hdl->auto_deploy($name, $redundancy, 0, 0);