2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 17:46:38 +00:00

Merge pull request #4330 from mattaezell/openbmccons_fix

Use IO::Socket to check BMC console port
This commit is contained in:
cxhong 2017-11-20 14:03:11 -05:00 committed by GitHub
commit 49252061f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
use Fcntl qw(:DEFAULT :flock);
use Time::HiRes qw(sleep);
use File::Path;
use IO::Socket;
BEGIN {
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
@ -92,15 +93,25 @@ if ($ENV{SSHCONSOLEPORT}) {
}
#check if sshport is up
my $nmap_output = `/usr/bin/nmap $bmcip -p $sshport -Pn`;
while ($nmap_output =~ /0 hosts up/) {
my $sock = IO::Socket::INET->new(
PeerAddr => $bmcip,
PeerPort => $sshport,
Proto => "tcp",
Timeout => 10
);
while (!defined($sock)) {
$sleepint = 10 + int(rand(20));
print "No BMC active at IP $bmcip, retrying in $sleepint seconds (Hit Ctrl-E,c,o to skip)\n";
sleep ($sleepint);
acquire_lock();
sleep(0.1);
release_lock();
$nmap_output = `/usr/bin/nmap $bmcip -p $sshport -Pn`;
$sock = IO::Socket::INET->new(
PeerAddr => $bmcip,
PeerPort => $sshport,
Proto => "tcp",
Timeout => 10
);
}