[pve-devel] r6386 - in pve-storage/pve2: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Aug 1 08:26:10 CEST 2011


Author: dietmar
Date: 2011-08-01 08:26:10 +0200 (Mon, 01 Aug 2011)
New Revision: 6386

Modified:
   pve-storage/pve2/ChangeLog
   pve-storage/pve2/PVE/Storage.pm
Log:
	* PVE/Storage.pm (iscsi_login): use Net::Ping to check portal
	availability (avoid long iscsi login timeouts)



Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog	2011-07-29 07:17:18 UTC (rev 6385)
+++ pve-storage/pve2/ChangeLog	2011-08-01 06:26:10 UTC (rev 6386)
@@ -1,3 +1,8 @@
+2011-08-01  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/Storage.pm (iscsi_login): use Net::Ping to check portal
+	availability (avoid long iscsi login timeouts)
+
 2011-07-29  Proxmox Support Team  <support at proxmox.com>
 
 	* changelog.Debian: update version to 2.0-3

Modified: pve-storage/pve2/PVE/Storage.pm
===================================================================
--- pve-storage/pve2/PVE/Storage.pm	2011-07-29 07:17:18 UTC (rev 6385)
+++ pve-storage/pve2/PVE/Storage.pm	2011-08-01 06:26:10 UTC (rev 6386)
@@ -14,6 +14,8 @@
 use Getopt::Long qw(GetOptionsFromArray);
 use Socket;
 use Digest::SHA1;
+use Net::Ping;
+
 use PVE::Tools qw(run_command file_read_firstline trim);
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::Exception qw(raise_param_exc);
@@ -832,10 +834,15 @@
 
     my $success = 0;
     foreach my $portal (@{$res->{$target}}) {
+	my ($server, $port) = split(':', $portal);
 	my $cmd = [$ISCSIADM, '--mode', 'node', '--portal', $portal, 
 		   '--targetname',  $target, '--login'];
-	eval { run_command ($cmd); $success = 1; };
-	warn $@ if $@;
+	my $p = Net::Ping->new("tcp", 2);
+	$p->port_number($port);
+	if ($p->ping($server)) {
+	    eval { run_command ($cmd); $success = 1; };
+	    warn $@ if $@;
+	}
     }
     die "iscsi login failed\n" if !$success;
 }



More information about the pve-devel mailing list