From b47d73efec1e5e27e78537f3b28f9a201de00016 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 21 Jul 2014 12:39:55 -0400 Subject: [PATCH 1/9] defect 4231 --- xCAT-server/sbin/xcatconfig | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 34d55d1f4..fde67b8db 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -916,10 +916,12 @@ sub settunables If node private node hostkeys do not exist in either directory or force option or generate host key option, we need to generate them These keys are installed on the nodes in /etc/ssh directory and allow the - node to ssh without password node to node. + node to ssh to the other nodes and the MN or SN to be able to ssh to the node + Without known_hosts warning messages. They are store in /etc/xcat/hostkeys on the MN. - This also includes some migration to /install/postscripts/hostkeys + The public key is also installed in /install/postscripts/hostkeys for the install process + The private key is downloaded by remoteshell postscript using the credentials.pm interface =cut @@ -956,7 +958,7 @@ sub genSSHNodeHostKey } } - # remove the old keys + # remove the old keys from the /intall/postscripts/hostkeys directroy if (-r $hostkey) { my $cmd = "/bin/rm $::INSTALLDIR/postscripts/hostkeys/ssh_host*"; @@ -970,7 +972,7 @@ sub genSSHNodeHostKey } } - # remove the old keys + # remove the old keys from the /etc/xcat/hostkeys directory if (-r $hostkey2) { my $cmd = "/bin/rm /etc/xcat/hostkeys/ssh_host*"; @@ -1014,6 +1016,18 @@ sub genSSHNodeHostKey { xCAT::MsgUtils->message('E', "Could not generate SSH2 DSA key."); } + # see if this system supports the ecdsa + if (-e "/etc/ssh/ssh_host_ecdsa_key") { + xCAT::MsgUtils->message('I', "Generating SSH2 ECDSA Key..."); + $cmd = + "/usr/bin/ssh-keygen -t ecdsa -f /etc/xcat/hostkeys/ssh_host_ecdsa_key -C '' -N ''"; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not generate SSH2 ECDSA key."); + } + } + # copy the public keys to install directory $cmd = From 616b6fbc6de175c80f6be8d95ea5f57bc4a8050b Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 21 Jul 2014 12:42:10 -0400 Subject: [PATCH 2/9] defect 4231 --- xCAT/postscripts/remoteshell | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index e411245a7..93dad4e1b 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -4,7 +4,7 @@ # This script adds xCAT specific setup to the /etc/ssh/sshd_config and ssh_config file # It calls getcredentials.awk to get from the xcatmaster ssh host keys from the # /etc/xcat/hostkeys directory and puts in /etc/ssh on the node the following keys -# ssh_host_dsa_key,ssh_host_rsa_key +# ssh_host_dsa_key,ssh_host_rsa_key, ssh_host_ecdsa_key (if supported) # It calls getcredentials.awk to get from the xcatmaster root ssh keys from the # ~/.ssh directory on the xcatmaster and put in ~/.ssh on the node the following keys: # If site.enablesshbetweennodes is yes @@ -87,6 +87,7 @@ allowcred.awk & CREDPID=$! sleep 1 +#download the ssh host dsa private keys if [ $useflowcontrol = "1" ]; then #first contact daemon xcatflowrequest 3001 logger -t xCAT -p local4.info "remoteshell: sending xcatflowrequest $master 3001" @@ -153,6 +154,7 @@ else fi rm /tmp/ssh_dsa_hostkey +# download the host rsa key if [ $useflowcontrol = "1" ]; then #first contact daemon xcatflowrequest 3001 logger -t xCAT -p local4.info "remoteshell: sending xcatflowrequest $master 3001" @@ -164,6 +166,7 @@ if [ $useflowcontrol = "1" ]; then useflowcontrol=0 fi fi + getcredentials.awk ssh_rsa_hostkey | grep -E -v '|' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /tmp/ssh_rsa_hostkey #check whether the message is an error or not @@ -217,6 +220,75 @@ else fi rm /tmp/ssh_rsa_hostkey +# if there is a ecdsa host key on the node then download the replacement from the MN/SN +if [ -f ssh_host_ecdsa_key ]; then + # download the host ecdsa key + if [ $useflowcontrol = "1" ]; then + #first contact daemon xcatflowrequest 3001 + logger -t xCAT -p local4.info "remoteshell: sending xcatflowrequest $master 3001" + /$xcatpost/xcatflowrequest $master 3001 + rc=$? + logger -t xCAT -p local4.info "remoteshell:xcatflowrequest return=$rc" + if [ $rc -ne 0 ]; then + logger -t xCAT -p local4.info "remoteshell: error from xcatflowrequest, will not use flow control" + useflowcontrol=0 + fi + fi + + getcredentials.awk ssh_ecdsa_hostkey | grep -E -v '|' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /tmp/ssh_ecdsa_hostkey + + #check whether the message is an error or not + grep -E '' /tmp/ssh_ecdsa_hostkey + if [ $? -ne 0 ]; then + #the message received is the data we request + cat /tmp/ssh_ecdsa_hostkey | grep -E -v '|/{0,1}data>||' >/etc/ssh/ssh_host_ecdsa_key + logger -t xCAT -p local4.info ssh_ecdsa_hostkey + MYCONT=`cat /etc/ssh/ssh_host_ecdsa_key` + MAX_RETRIES=10 + RETRY=0 + while [ -z "$MYCONT" ]; do + # not using flow control , need to sleep + if [ $useflowcontrol = "0" ]; then + let SLI=$RANDOM%10 + let SLI=SLI+10 + sleep $SLI + fi + RETRY=$(($RETRY+1)) + if [ $RETRY -eq $MAX_RETRIES ] + then + break + fi + if [ $useflowcontrol = "1" ]; then + #first contact daemon xcatflowrequest 3001 + logger -t xCAT -p local4.info "remoteshell: sending xcatflowrequest $master 3001" + /$xcatpost/xcatflowrequest $master 3001 + rc=$? + logger -t xCAT -p local4.info "remoteshell:xcatflowrequest return=$rc" + if [ $rc -ne 0 ]; then + logger -t xCAT -p local4.info "remoteshell: error from xcatflowrequest, will not use flow control" + useflowcontrol=0 + fi + fi + + getcredentials.awk ssh_ecdsa_hostkey | grep -v '<'|sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /etc/ssh/ssh_host_ecdsa_key + MYCONT=`cat /etc/ssh/ssh_host_ecdsa_key` + done + chmod 600 /etc/ssh/ssh_host_ecdsa_key + if ! grep "PRIVATE KEY" /etc/ssh/ssh_host_ecdsa_key > /dev/null 2>&1 ; then + rm /etc/ssh/ssh_host_ecdsa_key + else + ssh-keygen -y -f /etc/ssh/ssh_host_ecdsa_key > /etc/ssh/ssh_host_ecdsa_key.pub + chmod 644 /etc/ssh/ssh_host_ecdsa_key.pub + chown root /etc/ssh/ssh_host_ecdsa_key.pub + fi + else + #This is an error message + ERR_MSG=`sed -n 's%.*\(.*\).*%\1%p' /tmp/ssh_ecdsa_hostkey` + logger -t xCAT -p local4.err Error: $ERR_MSG + fi + rm /tmp/ssh_ecdsa_hostkey +fi + if [[ $NTYPE = service ]]; then mkdir -p /etc/xcat/hostkeys cp /etc/ssh/ssh* /etc/xcat/hostkeys/. From b42741e5a15e3f1aa89455c20e7d17323e750eda Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 21 Jul 2014 12:43:33 -0400 Subject: [PATCH 3/9] defect 4231 --- xCAT-server/lib/xcat/plugins/credentials.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/credentials.pm b/xCAT-server/lib/xcat/plugins/credentials.pm index fcf3ebef8..e9d1789a6 100644 --- a/xCAT-server/lib/xcat/plugins/credentials.pm +++ b/xCAT-server/lib/xcat/plugins/credentials.pm @@ -198,6 +198,17 @@ sub process_request `logger -t xCAT -p local4.info "credentials: Unable to read private RSA key"` ; next; } + } elsif ($parm =~ /ssh_ecdsa_hostkey/) { + `logger -t xCAT -p local4.info "credentials: sending $parm"` ; + if (-r "/etc/xcat/hostkeys/$client/ssh_host_ecdsa_key") { + $tfilename="/etc/xcat/hostkeys/$client/ssh_host_ecdsa_key"; + } elsif (-r "/etc/xcat/hostkeys/ssh_host_ecdsa_key") { + $tfilename="/etc/xcat/hostkeys/ssh_host_ecdsa_key"; + } else { + push @{$rsp->{'error'}},"Unable to read private ECDSA key from /etc/xcat/hostkeys"; + `logger -t xCAT -p local4.info "credentials: Unable to read private ECDSA key"` ; + next; + } } elsif ($parm =~ /xcat_cfgloc/) { `logger -t xCAT -p local4.info "credentials: sending $parm"` ; unless (-r "/etc/xcat/cfgloc") { From 5ad5eb1b1eca2787f3f7a1dc66d8f781d9ef6a15 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 22 Jul 2014 07:21:51 -0400 Subject: [PATCH 4/9] defect 4231 --- xCAT/postscripts/aixremoteshell | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/aixremoteshell b/xCAT/postscripts/aixremoteshell index f81d46cbe..7db4cb038 100755 --- a/xCAT/postscripts/aixremoteshell +++ b/xCAT/postscripts/aixremoteshell @@ -201,11 +201,31 @@ sub setupSSH $msg = "aixremoteshell: Could not get ssh_host_rsa_key file.\n"; `logger -t xcat -p local4.err $msg`; } - if ( $nodetype eq "service") { + # is there is a ecdsa host key on the node, then get the one from the MN/SN + my $filename = "/etc/ssh/ssh_host_ecdsa_key"; + if (-e $filename) { + my $response=&getresponse("ssh_ecdsa_hostkey"); + if (defined ($response) ) { + my $fd; + &runcmd("mkdir -p /etc/ssh"); + open($fd, '>',$filename); + print $fd $response; + close($fd); + + # set the permissions + my $cmd = "chmod 600 $filename > /dev/null 2>&1"; + &runcmd($cmd); + } + else { + $msg = "aixremoteshell: Could not get ssh_host_ecdsa_key file.\n"; + `logger -t xcat -p local4.err $msg`; + } + } + if ( $nodetype eq "service") { &runcmd("mkdir -p /etc/xcat/hostkeys; cp /etc/ssh/ssh* /etc/xcat/hostkeys/. > /dev/null 2>&1"); } - # Decide whether to enable ssh between the nodes - if ($enablesshbetweennodes eq "YES") { + # Decide whether to enable passwordless ssh between the nodes + if ($enablesshbetweennodes eq "YES") { my $response=&getresponse("ssh_root_key"); if (defined ($response) ) { my $fd; @@ -216,7 +236,6 @@ sub setupSSH close($fd); # set the permissions -#TODO - what perms are needed??? my $cmd = "chmod 600 $filename > /dev/null 2>&1"; &runcmd($cmd); @@ -227,8 +246,8 @@ sub setupSSH else { $msg = "aixremoteshell: Could not get id_rsa file.\n"; `logger -t xcat -p local4.err $msg`; - } - } + } + } return 0; } From 44bae8d8ea6a0527e51035457bfd02e5569c7a5a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 22 Jul 2014 10:29:42 -0400 Subject: [PATCH 5/9] fix for ecdsa support --- xCAT/postscripts/remoteshell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 93dad4e1b..5ce0aec1d 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -221,7 +221,7 @@ fi rm /tmp/ssh_rsa_hostkey # if there is a ecdsa host key on the node then download the replacement from the MN/SN -if [ -f ssh_host_ecdsa_key ]; then +if [ -f /etc/ssh/ssh_host_ecdsa_key ]; then # download the host ecdsa key if [ $useflowcontrol = "1" ]; then #first contact daemon xcatflowrequest 3001 From 9e71b35a4308558b1b871d8083780b8f0d3a7687 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 22 Jul 2014 20:34:23 -0700 Subject: [PATCH 6/9] fix defect #4229 xcatd will restart when add a kit or remove a kit that has a plugin --- xCAT-server/lib/xcat/plugins/kit.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index aec853777..85ea8122b 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1411,7 +1411,8 @@ sub addkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd restart"); + #system("/etc/init.d/xcatd restart"); + system("XCATRELOAD=yes xcatd -p /var/run/xcatd.pid"); } } } @@ -1731,7 +1732,8 @@ sub rmkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd restart"); + #system("/etc/init.d/xcatd restart"); + system("XCATRELOAD=yes xcatd -p /var/run/xcatd.pid"); } } From 67ee622cdd5a12e324ef9905740543b0bba4ce0d Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 22 Jul 2014 23:16:48 -0700 Subject: [PATCH 7/9] fix defect #4233 syslog changes give syntax error on AIX --- xCAT/postscripts/config_chef_server | 7 ++++--- xCAT/postscripts/configbond | 8 +++++--- xCAT/postscripts/configeth | 7 +++++-- xCAT/postscripts/configib | 8 ++++---- xCAT/postscripts/confignics | 7 +++++-- xCAT/postscripts/enablekdump | 6 ++++-- xCAT/postscripts/install_puppet_server | 7 ++++--- xCAT/postscripts/remoteshell | 7 ++++--- xCAT/postscripts/routeop | 7 +++++-- xCAT/postscripts/setupesx | 6 ++++-- xCAT/postscripts/setupntp | 6 ++++-- xCAT/postscripts/sudoer | 7 ++++--- xCAT/postscripts/syslog | 8 ++++---- 13 files changed, 56 insertions(+), 35 deletions(-) diff --git a/xCAT/postscripts/config_chef_server b/xCAT/postscripts/config_chef_server index b1bb266ca..538c737f4 100755 --- a/xCAT/postscripts/config_chef_server +++ b/xCAT/postscripts/config_chef_server @@ -3,9 +3,10 @@ -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi #------------------------------------------------------------------------------- diff --git a/xCAT/postscripts/configbond b/xCAT/postscripts/configbond index 9d55e5318..b709b1268 100755 --- a/xCAT/postscripts/configbond +++ b/xCAT/postscripts/configbond @@ -34,9 +34,11 @@ # NETWORKS_LINE2=netname=10_0_2_0-255_255_255_0||net=10.0.2.0||mask=255.255.255.0||mgtifname=eth0||gateway=10.0.2.2||dhcpserver=||tftpserver=10.0.2.15||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments= -# locd library for network caculation -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh +# load library for network caculation +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi # Subroutine to display message and pass it to syslog # Usage: showmsg "message to putput" ["error"] diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 195fab5a6..d76cd8d35 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -1,7 +1,10 @@ #!/bin/bash -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh + +f [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi function configipv4(){ str_if_name=$1 diff --git a/xCAT/postscripts/configib b/xCAT/postscripts/configib index 905cbe351..d0c36b544 100755 --- a/xCAT/postscripts/configib +++ b/xCAT/postscripts/configib @@ -17,10 +17,10 @@ # NETWORKS_LINE2='netname=ib1||net=15.0.1.0||mask=255.255.255.0||mgtifname=||gateway=15.0.1.254||dhcpserver=||tftpserver=||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments=' # NETWORKS_LINE3='netname=ib3||net=15.0.3.0||mask=255.255.255.0||mgtifname=||gateway=||dhcpserver=||tftpserver=||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments=' - -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi #This is the number of ports for each ib adpator. portnum=1 diff --git a/xCAT/postscripts/confignics b/xCAT/postscripts/confignics index 61c6bac15..d743489f0 100755 --- a/xCAT/postscripts/confignics +++ b/xCAT/postscripts/confignics @@ -1,7 +1,10 @@ #!/bin/bash -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh + +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi #the nics' information contain: #1. ip address diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump index 40ceca219..52b8d7c89 100755 --- a/xCAT/postscripts/enablekdump +++ b/xCAT/postscripts/enablekdump @@ -4,9 +4,11 @@ # -str_dir_name=`dirname $0` +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi -. $str_dir_name/xcatlib.sh # create /etc/sysconfig/network-scripts/ pmatch () diff --git a/xCAT/postscripts/install_puppet_server b/xCAT/postscripts/install_puppet_server index ac7cf9201..8c399ebb4 100755 --- a/xCAT/postscripts/install_puppet_server +++ b/xCAT/postscripts/install_puppet_server @@ -2,9 +2,10 @@ # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi #------------------------------------------------------------------------------- #=head1 install_puppet_server diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 5ce0aec1d..1580c519b 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -13,9 +13,10 @@ # if on the Management Node, exit -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi if [ -e /etc/xCATMN ]; then logger -t xcat -p local4.info "remoteshell:Running on the Management Node , exiting " diff --git a/xCAT/postscripts/routeop b/xCAT/postscripts/routeop index 14d66d419..091446d56 100755 --- a/xCAT/postscripts/routeop +++ b/xCAT/postscripts/routeop @@ -23,8 +23,11 @@ #=cut #------------------------------------------------------------------------------- -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh + +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi op=$1 diff --git a/xCAT/postscripts/setupesx b/xCAT/postscripts/setupesx index d21c290ed..40fe21f54 100644 --- a/xCAT/postscripts/setupesx +++ b/xCAT/postscripts/setupesx @@ -2,9 +2,11 @@ # example on how to set up ESX. We setup ssh and also add a basic # VLAN configuration -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi logger -t xcat -p local4.info setupesx # Enable SSH access to root and exchange keys diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index db75578b4..ec2149bc4 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -7,9 +7,11 @@ #--------------------------------------------------------------------------- -str_dir_name=`dirname $0` -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi # if on the Management Node, exit if [ -e /etc/xCATMN ]; then diff --git a/xCAT/postscripts/sudoer b/xCAT/postscripts/sudoer index c15166c2d..4306413f2 100755 --- a/xCAT/postscripts/sudoer +++ b/xCAT/postscripts/sudoer @@ -8,10 +8,11 @@ #------------------------------------------------------------------------------ -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi # Configuration for the sudoer SUDOER="xcat" diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 41ddbe389..13e917fbb 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -14,10 +14,10 @@ #=cut #------------------------------------------------------------------------------- - -str_dir_name=`dirname $0` - -. $str_dir_name/xcatlib.sh +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi master=$MASTER conf_file="/etc/syslog.conf" From 82adc2746bd5e52ee912c36876b12499e364c0cf Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 23 Jul 2014 10:18:11 -0400 Subject: [PATCH 8/9] code change to support lsslp and rscan for IVM. fix the issue that IVM lpar boots to openfirmware after os deployment by adding a command [chsyscfg boot_mode=norm] after rnetboot to make the bootmode to normal instead of of --- perl-xCAT/xCAT/PPCboot.pm | 21 +++++++++++++++++++++ perl-xCAT/xCAT/SLP.pm | 9 +++++---- xCAT-server/lib/xcat/plugins/lsslp.pm | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/PPCboot.pm b/perl-xCAT/xCAT/PPCboot.pm index 19b53e3ef..f2991798d 100644 --- a/perl-xCAT/xCAT/PPCboot.pm +++ b/perl-xCAT/xCAT/PPCboot.pm @@ -350,6 +350,27 @@ sub do_rnetboot { last; } } + + # Set the boot mode to norm from 'of' (open firmware) + # NOW, only necessary for IVM + my $hwtype = @$exp[2]; + if ($hwtype eq "ivm") { + my $server = @$exp[3]; + + # creat connection first + my @newexp = xCAT::PPCcli::connect( $request, $hwtype, $server ); + if (ref($newexp[0]) eq "Expect" ) { + my $cfg = "lpar_id=@$d[0],boot_mode=norm"; + # change the boot mode to 'norm' + xCAT::PPCcli::chsyscfg(\@newexp, "prof", $d, $cfg); + xCAT::PPCcli::disconnect(\@newexp); + } else { + my $rsp; + $rsp->{data} = ["Failed to set the boot mode to normal. For rnetboot command, you have to rpower off and then on the node after finishing the OS deployment."]; + xCAT::MsgUtils->message("E", $rsp, $request->{callback}); + } + } + return $result; } diff --git a/perl-xCAT/xCAT/SLP.pm b/perl-xCAT/xCAT/SLP.pm index 0dfa25f69..3e8c5f438 100755 --- a/perl-xCAT/xCAT/SLP.pm +++ b/perl-xCAT/xCAT/SLP.pm @@ -287,7 +287,7 @@ sub dodiscover { if ($rethash{$peername}) { next; #got a dupe, discard } - my $result = process_slp_packet(packet=>$slpkg,sockaddr=>$pkg,'socket'=>$args{'socket'}); + my $result = process_slp_packet(packet=>$slpkg,sockaddr=>$pkg,'socket'=>$args{'socket'}, peername=>$peername, callback=>$args{reqcallback}); if ($result) { if ($peername =~ /\./) { #ipv4 $peername =~ s/::ffff://; @@ -371,9 +371,10 @@ sub process_slp_packet { if ($parsedpacket->{FunctionId} == 2) {#Service Reply parse_service_reply($parsedpacket->{payload},$parsedpacket); unless (ref $parsedpacket->{service_urls} and scalar @{$parsedpacket->{service_urls}}) { return undef; } - if ($parsedpacket->{attributes}) { #service reply had ext - - return $parsedpacket; #don't bother sending attrrequest, already got it in first packet + if ($parsedpacket->{attributes} && get_mac_for_addr($args{peername})) { + #service reply had ext. Stop here if has gotten attributes and got mac. + #continue the unicast request for service attributes if cannot find mac for peernode + return $parsedpacket; #don't bother sending attrrequest, already got it in first packet } my $srvtype = $xid_to_srvtype_map{$parsedpacket->{Xid}}; my $packet = generate_attribute_request(%args,SrvType=>$srvtype); diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index 5953cb3e7..5c508ea27 100755 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -1090,6 +1090,29 @@ sub parse_responses { trace( $request, "Discover node $atthash{hostname}: type is $atthash{type},\ mtm is $atthash{mtm},sn is $atthash{serial}, ip is $atthash{ip},\ mac is $atthash{mac}, otherinterfaces is $atthash{otherinterfaces}" ); + } elsif ($type eq SERVICE_IVM) { + $atthash{type} = $service_slp{$type}; + $atthash{mtm} = ${$attributes->{'machinetype-model'}}[0]; + $atthash{serial} = ${$attributes->{'serial-number'}}[0]; + $atthash{id} = ${$attributes->{'lparid'}}[0]; + $atthash{ip} = ${$attributes->{'ip-address'}}[0]; + $atthash{hostname} = get_host_from_url($request, $attributes); + my @ips = @{$attributes->{'ip-address'}}; + foreach my $tmpip (@ips) { + if (exists($::OLD_DATA_CACHE{"ivm*".$atthash{mtm}."*".$atthash{serial}})){ + $atthash{hostname} = $::OLD_DATA_CACHE{"ivm*".$atthash{mtm}."*".$atthash{serial}}; + push @matchnode, 'Server-'.$atthash{mtm}.'-SN'.$atthash{serial}; + $atthash{ip} = $tmpip; + } + } + $atthash{mac} = $rsp; + $atthash{url} = ${$searchmacs{$rsp}}{payload}; + $atthash{otherinterfaces} = ${$attributes->{'ip-address'}}[0]; + $outhash{'Server-'.$atthash{mtm}.'-SN'.$atthash{serial}} = \%atthash; + $$length = length( $atthash{ip}) if ( length( $atthash{ip} ) > $$length ); + trace( $request, "Discover node $atthash{hostname}: type is $atthash{type},\ + mtm is $atthash{mtm},sn is $atthash{serial}, ip is $atthash{ip},\ + mac is $atthash{mac}, otherinterfaces is $atthash{otherinterfaces}" ); }elsif (($type eq SERVICE_FSP) && (${$attributes->{'machinetype-model'}}[0] =~ /^7895|1457|7954/ )) { # Skip this entry if "-s CEC" was specified - we do not list FSP entries for Flex when only CECs were requested next unless ($option_s ne "CEC"); From 08d923735c2c134b7bcd2a2b976706c10bc2f1cc Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 24 Jul 2014 09:32:43 -0400 Subject: [PATCH 9/9] Discover ip attributes for lsslp -s IVM; change the default discovred ivm named with ivm-mtm-sn instead of Server-mtm-sn --- xCAT-server/lib/xcat/plugins/lsslp.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index 5c508ea27..ac2dd69ca 100755 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -1097,6 +1097,7 @@ sub parse_responses { $atthash{id} = ${$attributes->{'lparid'}}[0]; $atthash{ip} = ${$attributes->{'ip-address'}}[0]; $atthash{hostname} = get_host_from_url($request, $attributes); + $atthash{hostname} =~ s/^Server/ivm/; my @ips = @{$attributes->{'ip-address'}}; foreach my $tmpip (@ips) { if (exists($::OLD_DATA_CACHE{"ivm*".$atthash{mtm}."*".$atthash{serial}})){ @@ -1569,6 +1570,9 @@ sub format_stanza { if ($type =~ /^fsp|bpa|cmm$/){ $result .= "\totherinterfaces=${$outhash->{$name}}{otherinterfaces}\n"; } + if ($type eq "ivm") { + $result .= "\tip=${$outhash->{$name}}{ip}\n"; + } $result .= "\thwtype=$globalhwtype{$type}\n"; } return( $result );