From fe8e4b800cd6d25dd37de9581f9f27b57d795e07 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Fri, 5 May 2017 04:33:09 -0400 Subject: [PATCH 1/3] enhance bmcsetup logic for openbmc --- xCAT-genesis-scripts/bin/bmcsetup | 42 +++++++++++++++++----- xCAT-genesis-scripts/bin/getipmi | 9 ++++- xCAT-server/lib/perl/xCAT/PasswordUtils.pm | 8 +++-- xCAT-server/lib/xcat/plugins/bmcconfig.pm | 8 +++-- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 13a6eb47d..9e5a2ce80 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -112,6 +112,13 @@ fi # Add ipmi_devintf module to allow the ipmitool operation in-band modprobe ipmi_devintf +for parm in `cat /proc/cmdline`; do + key=`echo $parm|awk -F= '{print $1}'` + if [ "$key" = "xcatd" ]; then + XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` + fi +done + allowcred.awk & CREDPID=$! sleep 5 @@ -161,6 +168,7 @@ 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 # if [ "$IPMIMFG" == 2 ]; then #IBM if [ "$XPROD" == "220" ]; then @@ -258,13 +266,20 @@ 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 + ISOPENBMC=1 fi +if [ -z "$ISOPENBMC" ]; then + LAN_MED_TYPE="802.3" +else + LAN_MED_TYPE="Other LAN" +fi while [ -z "$LANCHAN" ]; do logger -s -t $log_label -p local4.info "Auto detecting LAN channel..." for TLANCHAN in {1..16}; do # Try to get the channel information; then get the MAC which is used for the channel - if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; then + if ipmitool channel info $TLANCHAN 2> /dev/null | grep "$LAN_MED_TYPE" > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; then LANCHAN=$TLANCHAN break; fi; @@ -279,6 +294,9 @@ logger -s -t $log_label -p local4.info "Detected LAN channel $LANCHAN" let idev=NUMBMCS if [ $IPCFGMETHOD="static" ]; then + if [ ! -z "$ISOPENBMC" ]; then + let idev=0 + fi while [ $idev -gt 0 ]; do let idev=idev-1 TRIES=0 @@ -334,7 +352,11 @@ if [ $IPCFGMETHOD="static" ]; then done fi else - let idev=NUMBMCS + if [ -z "$ISOPENBMC" ];then + let idev=NUMBMCS + else + let idev=0 + fi while [ $idev -gt 0 ]; do let idev=idev-1 TRIES=0 @@ -366,6 +388,16 @@ done # After network commands are issued, pause to allow the BMC to apply (OpenPower) snooze +# update the node status to 'bmcready' for openbmc, no more configuration is needed. +if [ ! -z "$ISOPENBMC" ]; then + # update the node status to 'bmcready' + if [ ! -z "$XCATMASTER" ]; then + updateflag.awk $XCATMASTER 3002 "installstatus bmcready" + fi + rm -f /tmp/ipmicfg.xml + exit 0 +fi + let idev=NUMBMCS-1 for user in $BMCUS; do if [ "$user" = "" ]; then @@ -587,12 +619,6 @@ while [ $idev -gt 0 ]; do cold_reset_bmc # update the node status to 'bmcready' - for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" = "xcatd" ]; then - XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` - fi - done if [ ! -z "$XCATMASTER" ]; then updateflag.awk $XCATMASTER 3002 "installstatus bmcready" fi diff --git a/xCAT-genesis-scripts/bin/getipmi b/xCAT-genesis-scripts/bin/getipmi index ecc046213..cec1af653 100755 --- a/xCAT-genesis-scripts/bin/getipmi +++ b/xCAT-genesis-scripts/bin/getipmi @@ -29,10 +29,17 @@ for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do done BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may opt to use DHCP, if so we need to feed up the mac address #TODO: need a way to get the DUID the service processor may use, perhaps reserve that for 'ibmsetup' since spec doesn't touch ipv6? - +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 +else + ISOPENBMC=0 +fi echo " getbmcconfig 300 +$ISOPENBMC $BMCMAC " > /tmp/bmcreq.xml rm -f /tmp/ipmicfg.xml diff --git a/xCAT-server/lib/perl/xCAT/PasswordUtils.pm b/xCAT-server/lib/perl/xCAT/PasswordUtils.pm index e17ac14a5..b1161bc7e 100644 --- a/xCAT-server/lib/perl/xCAT/PasswordUtils.pm +++ b/xCAT-server/lib/perl/xCAT/PasswordUtils.pm @@ -30,10 +30,14 @@ sub getIPMIAuth { my $noderange = $args{noderange}; my $ipmihash = $args{ipmihash}; my $mphash = $args{mphash}; + my $key = $args{keytype}; + unless($key) { + $key = "ipmi"; + } my $tmp; my %authmap; unless ($ipmihash) { #in the event that calling code does not pass us a prefetched set of values, pull it ourselves - my $ipmitab = xCAT::Table->new('ipmi', -create => 0); + my $ipmitab = xCAT::Table->new("$key", -create => 0); if ($ipmitab) { $ipmihash = $ipmitab->getNodesAttribs($noderange, [ 'username', 'password' ]); } } unless ($mphash) { @@ -42,7 +46,7 @@ sub getIPMIAuth { } my $passtab = xCAT::Table->new('passwd'); if ($passtab) { - ($tmp) = $passtab->getAttribs({ 'key' => 'ipmi' }, 'username', 'password'); + ($tmp) = $passtab->getAttribs({ 'key' => "$key" }, 'username', 'password'); if (defined($tmp)) { $ipmiuser = $tmp->{username}; $ipmipass = $tmp->{password}; diff --git a/xCAT-server/lib/xcat/plugins/bmcconfig.pm b/xCAT-server/lib/xcat/plugins/bmcconfig.pm index d889a8155..60581c77d 100644 --- a/xCAT-server/lib/xcat/plugins/bmcconfig.pm +++ b/xCAT-server/lib/xcat/plugins/bmcconfig.pm @@ -96,20 +96,24 @@ sub process_request { my $request = shift; my $callback = shift; my $node = $request->{'_xcat_clienthost'}->[0]; + my $open_table = "ipmi"; + if ($request->{isopenbmc}->[0]) { + $open_table = "openbmc"; + } unless (ok_with_node($node, 300)) { $callback->({ error => ["Unable to prove root on your IP approves of this request"], errorcode => [1] }); return; } #my $sitetable = xCAT::Table->new('site'); - my $ipmitable = xCAT::Table->new('ipmi'); + my $ipmitable = xCAT::Table->new("$open_table"); my $tmphash; my $username; my $gennedpassword = 0; my $bmc; my $password; $tmphash = $ipmitable->getNodesAttribs([$node], [ 'bmc', 'username', 'bmcport', 'password', 'taggedvlan' ]); - my $authmap = xCAT::PasswordUtils::getIPMIAuth(noderange => [$node], ipmihash => $tmphash); + my $authmap = xCAT::PasswordUtils::getIPMIAuth(noderange => [$node], ipmihash => $tmphash, keytype => $open_table); if ($::XCATSITEVALS{genpasswords} eq "1" or $::XCATSITEVALS{genpasswords} =~ /y(es)?/i) { $password = genpassword(10) . "1cA!"; From 2aa3136094940b174e93a3e3769799dee2d8576a Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 8 May 2017 02:47:33 -0400 Subject: [PATCH 2/3] add set channel access on to apply network setting for OpenBMC --- xCAT-genesis-scripts/bin/bmcsetup | 32 ++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 9e5a2ce80..cbd787605 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -266,7 +266,7 @@ 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 +elif [ "$IPMIMFG" = "42817" -a "$XPROD" = "16975" ]; then ISOPENBMC=1 fi @@ -385,18 +385,40 @@ for b in $BMCVLAN; do let idev=idev+1 done -# After network commands are issued, pause to allow the BMC to apply (OpenPower) -snooze + # update the node status to 'bmcready' for openbmc, no more configuration is needed. if [ ! -z "$ISOPENBMC" ]; then + # To enable network configuration for openbmc + let idev=0 + TRIES=0 + bmc_config_rc=0 + # Set Channel Access to apply network setting + #while ! ipmitool -d $idev lan set $LANCHAN access on; do + while ! ipmitool -d $idev raw 0x06 0x40 $LANCHAN 0x42 0x44 > /dev/null; do + snooze + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then + bmc_config_rc=1 + break; + fi + done + # update the node status to 'bmcready' if [ ! -z "$XCATMASTER" ]; then - updateflag.awk $XCATMASTER 3002 "installstatus bmcready" + if [ "$bmc_config_rc" = "0" ]; then + # Wait for some time for the new network setting is ready + snooze + updateflag.awk $XCATMASTER 3002 "installstatus bmcready" + else + updateflag.awk $XCATMASTER 3002 "installstatus failed" + fi fi rm -f /tmp/ipmicfg.xml - exit 0 + exit $bmc_config_rc fi +# After network commands are issued, pause to allow the BMC to apply (OpenPower) +snooze let idev=NUMBMCS-1 for user in $BMCUS; do From 69f38cbb87cdeb9e6fb985cd9e924dacd093b6eb Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 9 May 2017 04:03:41 -0400 Subject: [PATCH 3/3] Update bmcsetup related code for OpenBMC --- xCAT-genesis-scripts/bin/bmcsetup | 13 ++++++------- xCAT-server/lib/xcat/plugins/bmcconfig.pm | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index cbd787605..b8208abe8 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -266,13 +266,13 @@ 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 +elif [ "$IPMIMFG" = "42817" -a "$XPROD" = "16975" ]; then # IBM OpenPOWER servers with OpenBMC ISOPENBMC=1 fi -if [ -z "$ISOPENBMC" ]; then - LAN_MED_TYPE="802.3" -else +LAN_MED_TYPE="802.3" +if [ ! -z "$ISOPENBMC" ]; then + # Overvide the default value for OpenBMC LAN_MED_TYPE="Other LAN" fi while [ -z "$LANCHAN" ]; do @@ -390,12 +390,11 @@ done # update the node status to 'bmcready' for openbmc, no more configuration is needed. if [ ! -z "$ISOPENBMC" ]; then # To enable network configuration for openbmc - let idev=0 TRIES=0 bmc_config_rc=0 # Set Channel Access to apply network setting - #while ! ipmitool -d $idev lan set $LANCHAN access on; do - while ! ipmitool -d $idev raw 0x06 0x40 $LANCHAN 0x42 0x44 > /dev/null; do + #while ! ipmitool -d 0 lan set $LANCHAN access on; do + while ! ipmitool -d 0 raw 0x06 0x40 $LANCHAN 0x42 0x44 > /dev/null; do snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then diff --git a/xCAT-server/lib/xcat/plugins/bmcconfig.pm b/xCAT-server/lib/xcat/plugins/bmcconfig.pm index 60581c77d..bef071f58 100644 --- a/xCAT-server/lib/xcat/plugins/bmcconfig.pm +++ b/xCAT-server/lib/xcat/plugins/bmcconfig.pm @@ -96,9 +96,9 @@ sub process_request { my $request = shift; my $callback = shift; my $node = $request->{'_xcat_clienthost'}->[0]; - my $open_table = "ipmi"; + my $bmc_mgmt_type = "ipmi"; if ($request->{isopenbmc}->[0]) { - $open_table = "openbmc"; + $bmc_mgmt_type = "openbmc"; } unless (ok_with_node($node, 300)) { $callback->({ error => ["Unable to prove root on your IP approves of this request"], errorcode => [1] }); @@ -106,14 +106,14 @@ sub process_request { } #my $sitetable = xCAT::Table->new('site'); - my $ipmitable = xCAT::Table->new("$open_table"); + my $ipmitable = xCAT::Table->new("$bmc_mgmt_type"); my $tmphash; my $username; my $gennedpassword = 0; my $bmc; my $password; $tmphash = $ipmitable->getNodesAttribs([$node], [ 'bmc', 'username', 'bmcport', 'password', 'taggedvlan' ]); - my $authmap = xCAT::PasswordUtils::getIPMIAuth(noderange => [$node], ipmihash => $tmphash, keytype => $open_table); + my $authmap = xCAT::PasswordUtils::getIPMIAuth(noderange => [$node], ipmihash => $tmphash, keytype => $bmc_mgmt_type); if ($::XCATSITEVALS{genpasswords} eq "1" or $::XCATSITEVALS{genpasswords} =~ /y(es)?/i) { $password = genpassword(10) . "1cA!";