2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

Mihawk support for bmcdiscover and bmcsetup

This commit is contained in:
Mark Gurevich 2020-02-19 14:23:43 -05:00
parent 650aaadec8
commit 88ee3f1d67
3 changed files with 39 additions and 14 deletions

View File

@ -167,7 +167,8 @@ logger -s -t $log_label -p local4.info "IPMIVER=$IPMIVER, IPMIMFG=$IPMIMFG, XPRO
#
# IPMIMFG=2 = IBM
# IPMIMFG=0 = OpenPOWER
# IPMIMFG=42817 and XPROD=16975 = OpenBMC
# IPMIMFG=42817 and XPROD=16975 = OpenBMC (Witherspoon)
# IPMIMFG=42817 and XPROD=1 = OpenBMC (Mihawk)
#
if [ "$IPMIMFG" == 2 ]; then #IBM
if [ "$XPROD" == "220" ]; then
@ -265,7 +266,9 @@ elif [ "$IPMIMFG" == "674" ]; then # DELL
ipmitool delloem lan set shared with lom$BMCPORT &>/dev/null
ipmitool delloem lan set shared with failover all loms &>/dev/null
fi
elif [ "$IPMIMFG" = "42817" -a "$XPROD" = "16975" ]; then # IBM OpenPOWER servers with OpenBMC
elif [ "$IPMIMFG" == "42817" -a "$XPROD" == "16975" ]; then # IBM OpenPOWER servers with OpenBMC (Witherspoon)
ISOPENBMC=1
elif [ "$IPMIMFG" == "42817" -a "$XPROD" == "1" ]; then # IBM OpenPOWER servers with OpenBMC (Mihawk)
ISOPENBMC=1
fi

View File

@ -32,7 +32,9 @@ BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may o
IPMIMFG=`ipmitool mc info |grep "^Manufacturer ID"|awk '{print $4}'`
XPROD=`ipmitool mc info | grep "^Product ID"|awk '{print $4}'`
if [ "$IPMIMFG" == "42817" -a "$XPROD" == "16975" ]; then
ISOPENBMC=1
ISOPENBMC=1 # Witherspoon
elif [ "$IPMIMFG" == "42817" -a "$XPROD" == "1" ]; then
ISOPENBMC=1 # Mihawk
else
ISOPENBMC=0
fi

View File

@ -51,10 +51,13 @@ my $openbmc_pass;
my $done_num = 0;
$::P9_WITHERSPOON_MFG_ID = "42817";
$::P9_WITHERSPOON_PRODUCT_ID = "16975";
$::P9_MIHAWK_MFG_ID = "42817";
$::P9_MIHAWK_PRODUCT_ID = "1";
$::CHANGE_PW_REQUIRED="The password provided for this account must be changed before access is granted";
$::NO_SESSION="Unable to establish IPMI v2 / RMCP";
$::CHANGE_PW_INSTRUCTIONS_1="Run script '/opt/xcat/share/xcat/scripts/BMC_change_password.sh' to change default password";
$::CHANGE_PW_INSTRUCTIONS_2="Rerun 'bmcdiscover' command with '-p new_bmc_password' flag";
$::NO_MFG_OR_PRODUCT_ID="Zeros returned for Manufacturer id and Product id";
%::VPDHASH = ();
my %node_in_list = ();
@ -654,11 +657,11 @@ sub scan_process {
$bcmd = join(" ", $nmap_path, " -sn -n $range");
}
xCAT::MsgUtils->trace(0, "I", "$log_label Try to scan live IPs by command $bcmd ...");
xCAT::MsgUtils->trace(0, "I", "$log_label Try to scan live IPs with command $bcmd ...");
$ip_info_list = xCAT::Utils->runcmd("$bcmd", -1);
if ($::RUNCMD_RC != 0) {
my $rsp = {};
push @{ $rsp->{data} }, "Nmap scan is failed.\n";
push @{ $rsp->{data} }, "Nmap scan has failed.\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
return 2;
}
@ -678,7 +681,7 @@ sub scan_process {
my %pipe_map;
if (scalar(@{$live_ip}) > 0) {
xCAT::MsgUtils->trace(0, "I", "$log_label Scaned live IPs " . scalar(@{$live_ip}) . " with mac " . scalar(@{$live_mac}));
xCAT::MsgUtils->trace(0, "I", "$log_label Scanned " . scalar(@{$live_ip}) . " live IPs with " . scalar(@{$live_mac}) . " MACs");
foreach (@{$live_ip}) {
my $new_mac = lc(shift @{$live_mac});
$new_mac =~ s/\://g;
@ -764,14 +767,23 @@ sub scan_process {
}
if ($mc_info =~ /Manufacturer ID\s*:\s*(\d+)\s*Manufacturer Name.+\s*Product ID\s*:\s*(\d+)/) {
xCAT::MsgUtils->trace(0, "D", "$log_label Found ${$live_ip}[$i] Manufacturer ID: $1 Product ID: $2");
if ($1 eq $::P9_WITHERSPOON_MFG_ID and $2 eq $::P9_WITHERSPOON_PRODUCT_ID) {
bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command,$parent_fd);
if (($1 eq $::P9_WITHERSPOON_MFG_ID and $2 eq $::P9_WITHERSPOON_PRODUCT_ID) or
($1 eq $::P9_MIHAWK_MFG_ID and $2 eq $::P9_MIHAWK_PRODUCT_ID)) {
bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command,$parent_fd,$2);
$is_openbmc = 1;
$is_ipmi = 0;
last;
}
elsif ($1 eq "0" and $2 eq "0") {
# Got zeros for MFG and PRODUCT ID, not sure if openbmc or ipmi. Print message and move on.
xCAT::MsgUtils->message("W", { data => ["${$live_ip}[$i]: $::NO_MFG_OR_PRODUCT_ID"] }, $::CALLBACK);
last;
}
else {
# System replied to mc info but not with $::P9_WITHERSPOON_MFG_ID and $::P9_WITHERSPOON_PRODUCT_ID, assume IPMI
# System replied to mc info but not with either
# $::P9_WITHERSPOON_MFG_ID and $::P9_WITHERSPOON_PRODUCT_ID, or
# $::P9_MIHAWK_MFG_ID and $::P9_MIHAWK_PRODUCT_ID,
# assume IPMI
$is_openbmc = 0;
$is_ipmi = 1;
last;
@ -1214,7 +1226,7 @@ sub bmcdiscovery_ipmi {
my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip;
if (exists($::VPDHASH{$mtmsip})) {
my $pre_node = $::VPDHASH{$mtmsip};
xCAT::MsgUtils->message("I", { data => ["Found match node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK);
xCAT::MsgUtils->message("I", { data => ["Found matching node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK);
if ($opz) {
$node_data .= ",";
display_output($opz,undef,$pre_node,$mac_node,$node_data,"ipmi",$request_command);
@ -1237,7 +1249,7 @@ sub bmcdiscovery_ipmi {
xCAT::MsgUtils->message("W", { data => ["BMC password is incorrect for $ip"] }, $::CALLBACK);
return;
} else {
xCAT::MsgUtils->message("W", { data => ["Unknown error get from $ip"] }, $::CALLBACK);
xCAT::MsgUtils->message("W", { data => ["Unknown error from $ip"] }, $::CALLBACK);
return;
}
@ -1263,6 +1275,7 @@ sub bmcdiscovery_openbmc{
my $opw = shift;
my $request_command = shift;
my $fd = shift;
my $model_id = shift;
my $mtms_node = "";
my $mac_node = "";
@ -1276,6 +1289,7 @@ sub bmcdiscovery_openbmc{
my $login_endpoint = "login";
my $system_endpoint = "inventory/system";
my $motherboard_boxelder_endpoint = "$system_endpoint/chassis/motherboard/boxelder/bmc";
my $motherboard_tpm_endpoint = "$system_endpoint/chassis/motherboard/tpm";
my $node_data = $ip;
my $brower = LWP::UserAgent->new( ssl_opts => { SSL_verify_mode => 0x00, verify_hostname => 0 }, );
@ -1294,8 +1308,14 @@ sub bmcdiscovery_openbmc{
my $req = HTTP::Request->new('GET', $url, $header);
my $req_output = $brower->request($req);
if ($req_output->is_error) {
# If the host system has not yet been powered on, check the boxelder bmc info for model/serial
$url = "$http_protocol://$ip/$openbmc_project_url/$motherboard_boxelder_endpoint";
# If the host system has not yet been powered on, system_endpoint call will return error
# Instead, check the boxelder (for Witherspoon) or tpm (for Mihawk) info for model/serial
if ($model_id eq $::P9_MIHAWK_PRODUCT_ID) {
$url = "$http_protocol://$ip/$openbmc_project_url/$motherboard_tpm_endpoint";
}
else {
$url = "$http_protocol://$ip/$openbmc_project_url/$motherboard_boxelder_endpoint";
}
$req = HTTP::Request->new('GET', $url, $header);
$req_output = $brower->request($req);
if ($req_output->is_error) {
@ -1349,7 +1369,7 @@ sub bmcdiscovery_openbmc{
my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip;
if (exists($::VPDHASH{$mtmsip})) {
my $pre_node = $::VPDHASH{$mtmsip};
xCAT::MsgUtils->message("I", { data => ["Found match node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK);
xCAT::MsgUtils->message("I", { data => ["Found matching node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK);
if ($opz) {
$node_data .= ",";
display_output($opz,undef,$pre_node,$mac_node,$node_data,"openbmc",$request_command);