From f6690b648eda7391264b37f8db847ffee8baa811 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 15 Nov 2017 16:56:16 -0500 Subject: [PATCH 1/2] [openbmc]Do not send exec command for bmc console if bmc is not reachable --- xCAT-server/lib/perl/xCAT/xcatd.pm | 2 +- xCAT-server/share/xcat/cons/openbmc | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/xcatd.pm b/xCAT-server/lib/perl/xCAT/xcatd.pm index 5e60e5ebb..721d31972 100644 --- a/xCAT-server/lib/perl/xCAT/xcatd.pm +++ b/xCAT-server/lib/perl/xCAT/xcatd.pm @@ -192,7 +192,7 @@ sub validate { $status = "Denied"; $rc = 0; } - if (($request->{command}->[0] ne "getdestiny") && ($request->{command}->[0] ne "getbladecons") && ($request->{command}->[0] ne "getipmicons")) { + if (($request->{command}->[0] ne "getdestiny") && ($request->{command}->[0] ne "getbladecons") && ($request->{command}->[0] ne "getipmicons") && ($request->{command}->[0] ne "getopenbmccons")) { # set username authenticated to run command # if from Trusted host, use input username, else set from creds diff --git a/xCAT-server/share/xcat/cons/openbmc b/xCAT-server/share/xcat/cons/openbmc index cfb26c33e..4429daa4b 100755 --- a/xCAT-server/share/xcat/cons/openbmc +++ b/xCAT-server/share/xcat/cons/openbmc @@ -91,6 +91,19 @@ if ($ENV{SSHCONSOLEPORT}) { $sshport= $ENV{SSHCONSOLEPORT}; } +#check if sshport is up +my $nmap_output = `/usr/bin/nmap $bmcip -p $sshport -Pn`; +while ($nmap_output =~ /0 hosts up/) { + $sleepint = 10 + int(rand(20)); + print "Failure to reach openbmc, 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`; +} + + # To automatically connect to the console without the need to send over the ssh keys, # ensure sshpass is installed on the Management and/or Service Nodes. print "Unable to open console. If BMC pings, ensure sshpass is installed or ssh keys have been configured on the BMC.\n"; From 0b9aae5754a85baf46f995608b4f25b3273ce788 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 16 Nov 2017 14:49:32 -0500 Subject: [PATCH 2/2] change log messages --- xCAT-server/share/xcat/cons/openbmc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/cons/openbmc b/xCAT-server/share/xcat/cons/openbmc index 4429daa4b..f21d899ad 100755 --- a/xCAT-server/share/xcat/cons/openbmc +++ b/xCAT-server/share/xcat/cons/openbmc @@ -95,7 +95,7 @@ if ($ENV{SSHCONSOLEPORT}) { my $nmap_output = `/usr/bin/nmap $bmcip -p $sshport -Pn`; while ($nmap_output =~ /0 hosts up/) { $sleepint = 10 + int(rand(20)); - print "Failure to reach openbmc, retrying in $sleepint seconds (Hit Ctrl-E,c,o to skip)\n"; + 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);