]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/DRBDPlugin.pm
rbd: allow to use client custom ceph conf for each storeid
[pve-storage.git] / PVE / Storage / DRBDPlugin.pm
index d722c5d6df4cd5b1b83e64bee6a4d84cdbc6b464..7536b4298223082ee0ea76a318101bc10c91cce5 100644 (file)
@@ -72,10 +72,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)) {
@@ -190,7 +191,7 @@ sub alloc_image {
 
     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 +206,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);
@@ -268,9 +269,9 @@ sub status {
        my ($rc, $free_space, $total_space) = $hdl->cluster_free_query($redundancy);
        check_drbd_res($rc);
 
-       $avail = $free_space;
-       $total = $total_space;
-       $used = $total_space - $free_space;
+       $avail = $free_space*1024;
+       $total = $total_space*1024;
+       $used = $total - $avail;
 
     };
     if (my $err = $@) {
@@ -304,21 +305,17 @@ sub activate_volume {
     
     my $hdl = connect_drbdmanage_service();
     my $nodename = PVE::INotify::nodename();
-    my ($rc, $res) = $hdl->list_assignments([$nodename], [], 0, {}, []);
+    my ($rc, $res) = $hdl->list_assignments([$nodename], [$volname], 0, {}, []);
     check_drbd_res($rc);
 
-    foreach my $entry (@$res) {
-       my ($node, $res_name, $props, $voldata) = @$entry;
-       if (($node eq $nodename) && ($res_name eq $volname)) {
-           return undef; # assignment already exists
-       }
-    }
+# assignment already exists?
+    return undef if @$res;
 
     # create diskless assignment
     ($rc, $res) = $hdl->assign($nodename, $volname, { diskless => 'true' });
     check_drbd_res($rc);
 
-    # wait until device is acessitble
+    # wait until device is accessible
     my $print_warning = 1;
     my $max_wait_time = 20;
     for (my $i = 0;; $i++) {