]> git.proxmox.com Git - pve-storage.git/commitdiff
since wheezy, iscsiadm -m session throw an error code if no session exist.
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 13 May 2013 06:00:16 +0000 (08:00 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 13 May 2013 06:00:16 +0000 (08:00 +0200)
So we can't bring up the iscsi storage

This patch is based on the patch submitted by Alexandre, but we only
suppress error messages when there are no active sessions. Other errors still
trigges an exceptions.

PVE/Storage/ISCSIPlugin.pm

index 8da7ec58fcb61f65c6d4d766cc6ab8d7a926d001..a445f857dbbd89735baff429c7c9f5447174aa19 100644 (file)
@@ -41,16 +41,20 @@ sub iscsi_session_list {
 
     my $res = {};
 
-    run_command($cmd, outfunc => sub {
-       my $line = shift;
-
-       if ($line =~ m/^tcp:\s+\[(\S+)\]\s+\S+\s+(\S+)\s*$/) {
-           my ($session, $target) = ($1, $2);
-           # there can be several sessions per target (multipath)
-           push @{$res->{$target}}, $session;
-
-       }
-    });
+    eval {
+       run_command($cmd, errmsg => 'iscsi session scan failed', outfunc => sub {
+           my $line = shift;
+           
+           if ($line =~ m/^tcp:\s+\[(\S+)\]\s+\S+\s+(\S+)\s*$/) {
+               my ($session, $target) = ($1, $2);
+               # there can be several sessions per target (multipath)
+               push @{$res->{$target}}, $session;   
+           }
+       });
+    };
+    if (my $err = $@) {
+       die $err if $err !~ m/: No active sessions.$/i;
+    }
 
     return $res;
 }