[pve-devel] [PATCH 5/6] ISCSIDirect : fixes and cleanup

Alexandre Derumier aderumier at odiso.com
Sun Aug 5 09:24:12 CEST 2012


-use "lunX" for volume name.
previously it was only the lun number, and it conflict with current syntax to disk alloc disk size.

-scsi-ls return size in Gb, so we need to convert to bytes

-small cleanups

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage/ISCSIDirectPlugin.pm |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/PVE/Storage/ISCSIDirectPlugin.pm b/PVE/Storage/ISCSIDirectPlugin.pm
index 6279aae..6233fa1 100644
--- a/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/PVE/Storage/ISCSIDirectPlugin.pm
@@ -17,29 +17,20 @@ sub iscsi_ls {
     my $portal = $scfg->{portal};
     my $cmd = ['/usr/bin/iscsi-ls', '-s', 'iscsi://'.$portal ];
     my $list = {};
-    my $test  = "";
-
-     my $errfunc = sub {
-         my $line = shift;
-         $line = trim($line);
-
-         die $line if $line;
-    };
 
     eval {
 
-	    run_command($cmd, errmsg => "iscsi error", errfunc => $errfunc, outfunc => sub {
+	    run_command($cmd, errmsg => "iscsi error", errfunc => sub {}, outfunc => sub {
 	        my $line = shift;
+		print $line."\n";
 	        $line = trim($line);
 	        if( $line =~ /Lun:(\d+)\s+([A-Za-z0-9\-\_\.\:]*)\s+\(Size:(\d+)G\)/ ) {
-		$test = $1;
-
-	            my $image = $1;
+	            my $image = "lun".$1;
 	            my $size = $3;
 
 	            $list->{$storeid}->{$image} = {
 	                name => $image,
-	                size => $size,
+	                size => $size*1024*1024*1024,
 	            };
 	        }
 	    });
@@ -47,7 +38,9 @@ sub iscsi_ls {
 
     my $err = $@;
     die $err if $err && $err !~ m/TESTUNITREADY failed with SENSE KEY/ ;
+
     return $list;
+
 }
 
 # Configuration
@@ -78,7 +71,7 @@ sub parse_volname {
     my ($class, $volname) = @_;
 
 
-    if ($volname =~ m/^(\d+)$/) {
+    if ($volname =~ m/^lun(\d+)$/) {
 	return ('images', $1, undef);
     }
 
-- 
1.7.2.5




More information about the pve-devel mailing list