From 413810fcb74f76ba5993e6f555503c4715cc829f Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 7 Aug 2014 20:35:15 -0700 Subject: [PATCH 1/6] correct a typo --- xCAT/postscripts/xcatlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index d1a4d08a9..fe6febc63 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -493,7 +493,7 @@ function disableservice { if [ -n "$svcunit" ];then cmd="systemctl disable $svcunit" - elif [ -n "svcjob" ];then + elif [ -n "$svcjob" ];then cmd="update-rc.d -f $svcd remove" elif [ -n "$svcd" ];then command -v chkconfig >/dev/null 2>&1 From 73758058015201d4c57a80783e415f8c0238d990 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 8 Aug 2014 08:51:30 -0700 Subject: [PATCH 2/6] fix defect #4238 [FVT]: xcat installation on sles gives out /sbin/SuSEfirewall2: line 507: /proc/net/ip_tables_names: No such file or directory --- perl-xCAT/xCAT/Utils.pm | 152 +++++++++++++++++++++++++++++++++++- xCAT/postscripts/xcatlib.sh | 94 +++++++++++++++++++++- 2 files changed, 244 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 976b79078..63aabf6dc 100755 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3542,6 +3542,98 @@ sub gettimezone } +#-------------------------------------------------------------------------------- + +=head3 specialservicemgr + some special services cannot be processed in sysVinit, upstart and systemd framework, should be process here... + Arguments: + service name: + action: start/stop/restart/status/enable/disable + outputoption: + 1: return a hashref with the keys:"retcode","retmsg" + otherwise: return retcode only + Returns: + + a hashref if $outputoption is 1,the hash structure is: + {"retcode"=>(status code, 0 for running/active,1 for stopped/inactive,2 for failed) + "retmsg" =>(status string, running/active/stopped/inactive/failed) + } + the status code otherwise + + retcode: 127 if the service specified is not processed + the exit code of the service operation if the service specified is processed + + Globals: + none + Error: + none + Example: + my $ret=xCAT::Utils->specialservicemgr("firewall","start"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub specialservicemgr{ + my $svcname=shift; + my $action=shift; + my $outputoption=shift; + my %ret; + + $ret{retcode}=127; + if($svcname eq "firewall") + { + + my $cmd="type -P SuSEfirewall2 >/dev/null 2>&1"; + xCAT::Utils->runcmd($cmd,-1); + if($::RUNCMD_RC) + { + $ret{retcode}=127; + if(defined $outputoption and $outputoption == 1){ + return \%ret; + }else{ + return $ret{retcode}; + } + }else{ + if(($action eq "start") || ($action eq "stop")) + { + $cmd="SuSEfirewall2 $action"; + }elsif($action eq "restart"){ + $cmd="SuSEfirewall2 stop;SuSEfirewall2 start"; + }elsif($action eq "disable"){ + $cmd="SuSEfirewall2 off"; + }elsif($action eq "enable"){ + $cmd="SuSEfirewall2 on"; + }elsif($action eq "status"){ + $cmd="service SuSEfirewall2_setup status"; + }else{ + + $ret{retcode}=127; + if(defined $outputoption and $outputoption == 1){ + return \%ret; + }else{ + return $ret{retcode}; + } + } + + $ret{retmsg}=xCAT::Utils->runcmd($cmd,-1); + $ret{retcode}= $::RUNCMD_RC; + if(defined $outputoption and $outputoption == 1){ + return \%ret; + }else{ + return $ret{retcode}; + } + } + + } + + if(defined $outputoption and $outputoption == 1){ + return \%ret; + }else{ + return $ret{retcode}; + } +} + #-------------------------------------------------------------------------------- @@ -3594,7 +3686,7 @@ sub servicemap{ "nfs" => ["nfsserver","nfs-server","nfs","nfs-kernel-server"], "named" => ["named","bind9"], "syslog" => ["syslog","syslogd","rsyslog"], - "firewall" => ["iptables","firewalld","SuSEfirewall2_setup","ufw"], + "firewall" => ["iptables","firewalld","ufw"], "http" => ["apache2","httpd"], "ntpserver" =>["ntpd","ntp"], "mysql" => ["mysqld","mysql"], @@ -3661,6 +3753,13 @@ sub startservice{ $svcname=shift; } + my $retval=0; + $retval=specialservicemgr($svcname,"start"); + if($retval != 127) + { + return $retval; + } + my $cmd=""; #for Systemd my $svcunit=undef; @@ -3725,6 +3824,16 @@ sub stopservice{ $svcname=shift; } + + my $retval=0; + $retval=specialservicemgr($svcname,"stop"); + if($retval != 127) + { + return $retval; + } + + + my $cmd=""; my $svcunit=undef; my $svcd=undef; @@ -3787,6 +3896,14 @@ sub restartservice{ $svcname=shift; } + + my $retval=0; + $retval=specialservicemgr($svcname,"restart"); + if($retval != 127) + { + return $retval; + } + my $cmd=""; my $svcunit=undef; my $svcd=undef; @@ -3857,6 +3974,18 @@ sub checkservicestatus{ my $outputoption=shift; + my $retval; + $retval=specialservicemgr($svcname,"status",1); + if($retval->{retcode} != 127) + { + if(defined $outputoption and $outputoption == 1 ){ + return $retval; + }elsif(exists $retval->{retcode}){ + return $retval->{retcode}; + } + } + + my $cmd=""; my $svcunit=undef; my $svcd=undef; @@ -3950,6 +4079,16 @@ sub enableservice{ $svcname=shift; } + + my $retval=0; + $retval=specialservicemgr($svcname,"enable"); + if($retval != 127) + { + return $retval; + } + + + my $cmd=""; my $svcunit=undef; my $svcd=undef; @@ -4016,6 +4155,17 @@ sub disableservice{ $svcname=shift; } + + + + my $retval=0; + $retval=specialservicemgr($svcname,"disable"); + if($retval != 127) + { + return $retval; + } + + my $cmd=""; my $svcunit=undef; my $svcjob=undef; diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index fe6febc63..8962ad554 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -286,7 +286,7 @@ function servicemap { INIT_syslog="syslog syslogd rsyslog"; - INIT_firewall="iptables firewalld SuSEfirewall2_setup ufw"; + INIT_firewall="iptables firewalld ufw"; INIT_http="apache2 httpd"; @@ -328,8 +328,58 @@ function servicemap { } +#some special services cannot be processed in sysVinit, upstart and systemd framework, should be process here... +#Notice: +# return value: +# 127 : if the service $svcname cannot be processed in this function +# otherwise: the return value of the service action + +function specialservicemgr { + local svcname=$1 + local action=$2 + + if [ "$svcname" = "firewall" ];then + type -P SuSEfirewall2 >/dev/null 2>&1 + if [ "$?" = "0" ] ;then + case "$action" in + "start"|"stop") + SuSEfirewall2 $action + ;; + "restart") + SuSEfirewall2 stop + SuSEfirewall2 start + ;; + "disable") + SuSEfirewall2 off + ;; + "enable") + SuSEfirewall2 on + ;; + "status") + service SuSEfirewall2_setup status + ;; + *) + return 127 + ;; + esac + return $? + fi + fi + + return 127 +} + function startservice { local svcname=$1 + + local retval + specialservicemgr "$svcname" start + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + + local cmd= local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` @@ -354,6 +404,14 @@ function startservice { function stopservice { local svcname=$1 + + local retval + specialservicemgr "$svcname" stop + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + local cmd= local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` @@ -384,6 +442,15 @@ function stopservice { function restartservice { local svcname=$1 + + local retval + specialservicemgr "$svcname" restart + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + + local cmd= local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` @@ -413,6 +480,14 @@ function restartservice { function checkservicestatus { local svcname=$1 + local retval + specialservicemgr "$svcname" status + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + + local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` local svcd=`servicemap $svcname 0` @@ -455,6 +530,15 @@ function checkservicestatus { function enableservice { local svcname=$1 + + local retval + specialservicemgr "$svcname" enable + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + + local cmd= local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` @@ -486,6 +570,14 @@ function enableservice { function disableservice { local svcname=$1 + + local retval + specialservicemgr "$svcname" disable + retval=$? + if [ "$retval" != "127" ]; then + return $retval + fi + local cmd= local svcunit=`servicemap $svcname 1` local svcjob=`servicemap $svcname 2` From 8ee690c6a17cf82918a6ead72805a9d76e975bb7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 9 Aug 2014 02:20:50 -0700 Subject: [PATCH 3/6] #4242 In physical rhel7 env,set installnic=ethx can not provision compute node. --- xCAT/postscripts/disableconsistentNICrename | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 xCAT/postscripts/disableconsistentNICrename diff --git a/xCAT/postscripts/disableconsistentNICrename b/xCAT/postscripts/disableconsistentNICrename new file mode 100755 index 000000000..3c5e221b0 --- /dev/null +++ b/xCAT/postscripts/disableconsistentNICrename @@ -0,0 +1,5 @@ +#/bin/sh +#modify the grub.cfg to prevent nic consistent network renameing +grep -E -q "net.ifnames=0" /etc/sysconfig/grub || sed -i '/^GRUB_CMDLINE_LINUX=.*/{s/"$/ net.ifnames=0"/}' /etc/sysconfig/grub +grep -E -q "net.ifnames=0" /etc/default/grub || sed -i '/^GRUB_CMDLINE_LINUX=.*/{s/"$/ net.ifnames=0"/}' /etc/default/grub +grub2-mkconfig -o /boot/grub2/grub.cfg From 9069f4dffd358a3338fbda5d6f9b7509a60d4475 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 9 Aug 2014 04:24:42 -0700 Subject: [PATCH 4/6] fix defect #4238 [FVT]: xcat installation on sles gives out /sbin/SuSEfirewall2: line 507: /proc/net/ip_tables_names: No such file or directory --- xCAT/postscripts/configfirewall | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xCAT/postscripts/configfirewall b/xCAT/postscripts/configfirewall index 22a5bf5e6..24fe8bf88 100755 --- a/xCAT/postscripts/configfirewall +++ b/xCAT/postscripts/configfirewall @@ -141,16 +141,14 @@ elsif (-f "/etc/SuSE-release") # restart firewall #my $cmd = "service SuSEfirewall2_setup restart"; #system($cmd); - xCAT::Utils->restartservice("SuSEfirewall2_setup"); + xCAT::Utils->restartservice("firewall"); # SuSEfirewall2_setup should be stared on reboot #$cmd = "chkconfig SuSEfirewall2_init on"; #system($cmd); #$cmd = "chkconfig SuSEfirewall2_setup on"; #system($cmd); - xCAT::Utils->enableservice("SuSEfirewall2_init"); - xCAT::Utils->enableservice("SuSEfirewall2_setup"); - + xCAT::Utils->enableservice("firewall"); } else { From 1d18788c73f45c0d10a1050c15bc6922e61394e5 Mon Sep 17 00:00:00 2001 From: chudegao Date: Sun, 10 Aug 2014 22:01:27 +0800 Subject: [PATCH 5/6] merge getmacs function from 2.8.2-pcm and fix a bug --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 86 ++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 109ba66d5..523b726af 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -491,6 +491,16 @@ Usage: return; } + # Get no mac address nodes when user only defined CEC in NIF for 7R2 support. + my @nomacnodes = (); + foreach my $nomacnode(@nodelist){ + if(defined($hostinfo_dict{$nomacnode}{'cec'}) && + not (defined($hostinfo_dict{$nomacnode}{'mac'})) && + not (defined($hostinfo_dict{$nomacnode}{'switch'}))){ + push @nomacnodes, $nomacnode; + } + } + # Create the full hostinfo dict. xCAT::MsgUtils->message('S', "Generating new hostinfo string."); my ($retcode_gen, $retstr_gen) = gen_new_hostinfo_dict(\%hostinfo_dict); @@ -535,6 +545,75 @@ Usage: } } + # Use xcat command: getmacs -D to automatically get node mac address + # If some of nodes can not get mac address, then finally remove them with warning msg. + if(@nomacnodes){ + # Sleep 10 seconds to ensure the basic node attributes are effected + sleep 10; + $retref = xCAT::Utils->runxcmd({command=>["getmacs"], node=>\@nomacnodes, arg=>['-D']}, $request_command, 0, 2); + $retstrref = parse_runxcmd_ret($retref); + if($::RUNCMD_RC != 0){ + $warnstr .= "Warning: Can not discover MAC address by getmacs command for some node(s)."; + } + + # Parse the output of "getmacs -D" to filter success and failed nodes. + my @successnodes = (); + my @failednodes = (); + my $nodelistref = $retref->{'node'}; + my $index = 0; + my $name = ''; + my $contents = ''; + if($nodelistref){ + foreach(@$nodelistref){ + # Get node name. + if($nodelistref->[$index]->{'name'}){ + $name = $nodelistref->[$index]->{'name'}->[0]; + } + # Get node data contents. + if($nodelistref->[$index]->{'data'}->[0]->{'contents'}){ + $contents = $nodelistref->[$index]->{'data'}->[0]->{'contents'}->[0]; + } + # Get success and failed nodes list. + if(defined($name) and $contents =~ /[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}/){ + push @successnodes, $name; + }else{ + push @failednodes, $name; + } + $index++; + } + } + + # Reconfigure the nodes that MAC address discovered by getmacs command + if(@successnodes){ + $mac_addr_mode = 1; + my $retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@successnodes, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2); + my $retstrref = parse_runxcmd_ret($retref); + if ($::RUNCMD_RC != 0){ + $warnstr .= "Warning: failed to run command kitnodeadd."; + if ($retstrref->[1]) { + $warnstr .= "Details: $retstrref->[1]"; + } + } + } + + # Remove these nodes that can not get mac address by xcat command: getmacs -D. + if(@failednodes){ + my $nodermretref = xCAT::Utils->runxcmd({command=>["noderm"], node=>\@failednodes}, $request_command, 0, 2); + my $nodermretstrref = parse_runxcmd_ret($nodermretref); + if($::RUNCMD_RC != 0){ + $warnstr .= "Warning: Cannot remove some of nodes that not MAC address discovered by getmacs command."; + if($nodermretstrref->[1]){ + $warnstr .= "Details: $nodermretstrref->[1]"; + } + } + } + + # Push the success nodes to nodelist and remove the failed nodes from nodelist. + @nodelist = xCAT::CFMUtils->arrayops("U", \@nodelist, \@successnodes); + @failednodes = xCAT::CFMUtils->arrayops("I", \@nodelist, \@failednodes); + @nodelist = xCAT::CFMUtils->arrayops("D", \@nodelist, \@failednodes); + } + setrsp_progress("Imported nodes."); #TODO: get the real nodelist here. setrsp_success(\@nodelist, $warnstr); @@ -2166,11 +2245,12 @@ sub validate_node_entry{ if (exists $allhostnames{$node_name}) { $errmsg .= "Node name $node_name already exists. You must use a new node name.\n"; } - # Must specify either MAC or switch + port. + # Must specify either MAC, CEC or switch + port. if (exists $node_entry{"mac"} || - exists $node_entry{"switches"} ){ + exists $node_entry{"switch"} && exists $node_entry{"switchport"} || + exists $node_entry{"cec"}){ } else{ - $errmsg .= "MAC address or switches is not specified. You must specify the MAC address or switches.\n"; + $errmsg .= "MAC address, cec, switch and port is not specified. You must specify the MAC address, CEC name or switch and port.\n"; } if (! xCAT::NetworkUtils->isValidHostname($node_name)){ From 844fb5faa670a196d1f7ceacc89b25a72417df9a Mon Sep 17 00:00:00 2001 From: huweihua Date: Tue, 12 Aug 2014 05:00:42 -0400 Subject: [PATCH 6/6] add --no-bootloader option for si_updateclient command --- xCAT/postscripts/syscloneimgupdate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/syscloneimgupdate b/xCAT/postscripts/syscloneimgupdate index d47332f73..64e46dc87 100755 --- a/xCAT/postscripts/syscloneimgupdate +++ b/xCAT/postscripts/syscloneimgupdate @@ -42,7 +42,7 @@ fi str_server_ip=`echo $str_server_ip | sed "s/'//g"` #call system imager command to update the image echo "si_updateclient --server $str_server_ip --yes" -export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --yes +export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --yes --no-bootloader if [[ -f /sbin/dracut ]]; then #redhat or centos