From b36c0ee19ed6b3d865f00bf9f054eade10961683 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 10 Oct 2017 02:35:18 -0400 Subject: [PATCH 1/2] Fix issue 4062, modify method of node type check in bmcdiscover --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 27 +++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 27defb307..d8caa28ce 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -47,7 +47,6 @@ my $bmc_user; my $bmc_pass; my $openbmc_user; my $openbmc_pass; -my $openbmc_port = 2200; #------------------------------------------------------- @@ -668,14 +667,26 @@ sub scan_process { # Set child process default, if not the function runcmd may return error $SIG{CHLD} = 'DEFAULT'; - my $nmap_cmd = "nmap ${$live_ip}[$i] -p $openbmc_port -Pn"; - my $nmap_output = xCAT::Utils->runcmd($nmap_cmd, -1); - if ($nmap_output !~ /$openbmc_port(.+)closed/) { - # If the openbmc_port is anything execpt 'closed' assume it's OpenBMC server - bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command); - } else { - bmcdiscovery_ipmi(${$live_ip}[$i], $opz, $opw, $request_command); + my @mc_cmds = ("/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -P $openbmc_pass mc info", + "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -U $bmc_user -P $bmc_pass mc info"); + my $mc_info; + my $flag; + foreach my $mc_cmd (@mc_cmds) { + $mc_info = xCAT::Utils->runcmd($mc_cmd, -1); + if ($mc_info =~ /Manufacturer ID\s*:\s*(\d+)\s*Manufacturer Name.+\s*Product ID\s*:\s*(\d+)/) { + if ($1 eq "42817" and $2 eq "16975") { + bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command); + $flag = 1; + last; + } else { + bmcdiscovery_ipmi(${$live_ip}[$i], $opz, $opw, $request_command); + $flag = 1; + last; + } + } } + bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command) unless ($flag); + close($parent_fd); exit 0; } else { From 8db826016cf6422b67c0719c305d7db1093400fa Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 10 Oct 2017 22:49:25 -0400 Subject: [PATCH 2/2] mofidied depending on comments --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index d8caa28ce..9c07b5427 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -47,6 +47,8 @@ my $bmc_user; my $bmc_pass; my $openbmc_user; my $openbmc_pass; +$::P9_WITHERSPOON_MFG_ID = "42817"; +$::P9_WITHERSPOON_PRODUCT_ID = "16975"; #------------------------------------------------------- @@ -667,14 +669,19 @@ sub scan_process { # Set child process default, if not the function runcmd may return error $SIG{CHLD} = 'DEFAULT'; - my @mc_cmds = ("/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -P $openbmc_pass mc info", - "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -U $bmc_user -P $bmc_pass mc info"); + my $bmcusername; + my $bmcpassword; + $bmcusername = "-U $bmc_user" if ($bmc_user); + $bmcpassword = "-P $bmc_pass" if ($bmc_pass); + + my @mc_cmds = ("/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -P $openbmc_pass mc info -N 1 -R 1", + "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] $bmcusername $bmcpassword mc info -N 1 -R 1"); my $mc_info; my $flag; foreach my $mc_cmd (@mc_cmds) { $mc_info = xCAT::Utils->runcmd($mc_cmd, -1); if ($mc_info =~ /Manufacturer ID\s*:\s*(\d+)\s*Manufacturer Name.+\s*Product ID\s*:\s*(\d+)/) { - if ($1 eq "42817" and $2 eq "16975") { + if ($1 eq $::P9_WITHERSPOON_MFG_ID and $2 eq $::P9_WITHERSPOON_PRODUCT_ID) { bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command); $flag = 1; last;