From 1fcadbd9f4d2a3e954aa831dc8827e4a5f1b11df Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Wed, 11 Jun 2014 23:16:11 -0700 Subject: [PATCH 1/4] fix bug 4069 'rspconfig hmc sshcfg=enable' failed in rhel7.0 environment --- perl-xCAT/xCAT/PPCcfg.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/PPCcfg.pm b/perl-xCAT/xCAT/PPCcfg.pm index ee4130dfe..0c4e79a27 100644 --- a/perl-xCAT/xCAT/PPCcfg.pm +++ b/perl-xCAT/xCAT/PPCcfg.pm @@ -436,9 +436,9 @@ sub sshcfg { ##################################### # userid@host not found in key file ##################################### - if ( $sshkey !~ /\s+(\S+\@\S+$)/ ) { - return( [[$server,"Cannot find userid\@host in '$fname'",RC_ERROR]] ); - } + #if ( $sshkey !~ /\s+(\S+\@\S+$)/ ) { + # return( [[$server,"Cannot find userid\@host in '$fname'",RC_ERROR]] ); + #} my $logon = $1; ##################################### From 73c420eefc3b2360fcd0f3374eb888a6e221a23d Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 12 Jun 2014 09:04:39 -0400 Subject: [PATCH 2/4] make subvars could handle the var in #INCLUDE --- xCAT-server/lib/perl/xCAT/Template.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index b5822e0c3..fc1eb4097 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -154,6 +154,25 @@ sub subvars { #do *all* includes, recursive and all my $doneincludes=0; while (not $doneincludes) { + $doneincludes=1; + $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; # handle the variable in #INCLUDE + if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; + } + if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg; + } + if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg; + } + if ($inc =~ /#INCLUDE:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; + } + #support multiple paths of osimage in rh/sles diskfull installation my @pkgdirs; if ( defined($media_dir) ) { @@ -239,7 +258,7 @@ sub subvars { $partcontent .= $_; } close ($inh); - + #the content of the specified file is a script which can write partition definition into /tmp/partitionfile if ($scriptflag){ #for redhat/sl/centos/kvm/fedora @@ -278,7 +297,7 @@ sub subvars { } } - $doneincludes=1; + $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; # handle the variable in #INCLUDE if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { $doneincludes=0; $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; From 293fe015ce5d525ca76bf8b026059385da2a5859 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 13 Jun 2014 06:23:36 -0400 Subject: [PATCH 3/4] use the base64 coding to pass the partition file into kickstart/autoyast pre script --- xCAT-server/lib/perl/xCAT/Template.pm | 137 +++++++++++++------------- 1 file changed, 67 insertions(+), 70 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index fc1eb4097..ccb34232c 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -151,7 +151,29 @@ sub subvars { } } - #do *all* includes, recursive and all + #if user specify the partion file, replace the default partition strategy + my $partcontent; + my $scriptflag = 0; + if ($partitionfile){ + if ($partitionfile =~ /^s:(.*)/){ + $scriptflag = 1; + $partitionfile = $1; + } + + if (-r $partitionfile){ + open ($inh, "<", $partitionfile); + while (<$inh>){ + $partcontent .= $_; + } + close ($inh); + } + } + + # append the partition file into the $inc to do the replacement + $inc .= "\nFFFFFFFFFFFFPARTITIONFILESTART\n".$partcontent; + + + #do *all* includes, recursive for all my $doneincludes=0; while (not $doneincludes) { $doneincludes=1; @@ -240,79 +262,54 @@ sub subvars { my $sles_sdk_media = "http://" . $tftpserver->{tftpserver} . $media_dir . "/sdk1"; $inc =~ s/#SLES_SDK_MEDIA#/$sles_sdk_media/eg; - - #if user specify the partion file, replace the default partition strategy - if ($partitionfile){ - #if the content of the partition file is definition replace the default is ok - my $partcontent = ''; - my $scriptflag = 0; - - if ($partitionfile =~ /^s:(.*)/){ - $scriptflag = 1; - $partitionfile = $1; - } - - if (-r $partitionfile){ - open ($inh, "<", $partitionfile); - while (<$inh>){ - $partcontent .= $_; - } - close ($inh); - #the content of the specified file is a script which can write partition definition into /tmp/partitionfile - if ($scriptflag){ - #for redhat/sl/centos/kvm/fedora - if ($inc =~ /#XCAT_PARTITION_START#/) { - my $tempstr = "%include /tmp/partitionfile\n"; - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; - #modify the content in the file, and write into %pre part - #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; - $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; - - $partcontent .= "chmod 755 /tmp/partscript\n"; - $partcontent .= "/tmp/partscript\n"; - #replace the #XCA_PARTITION_SCRIPT# - $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; - } - #for sles/suse - elsif ($inc =~ //){ - my $tempstr = "XCATPARTITIONTEMP"; - $inc =~ s/[\s\S]*/$tempstr/; - #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; - $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; - $partcontent .= "chmod 755 /tmp/partscript\n"; - $partcontent .= "/tmp/partscript\n"; - $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; - } + if ($partitionfile && $doneincludes) { + #the content of the specified file is a script which can write partition definition into /tmp/partitionfile + # split the partition file out from the $inc + ($inc, $partcontent) = split(/FFFFFFFFFFFFPARTITIONFILESTART/, $inc); + if ($scriptflag){ + # since the whole partition file needs be packaged in %pre first and generate an executable file at running time, + # all the special chars like ',",%,\ need be kept, we have to use the base64 coding to code it and put it in + # %pre and decode it out during the running time. + use MIME::Base64; + $partcontent = encode_base64($partcontent); + $partcontent =~ s/\n//g; + + #for redhat/sl/centos/kvm/fedora + if ($inc =~ /#XCAT_PARTITION_START#/) { + my $tempstr = "%include /tmp/partitionfile\n"; + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; + # Put the base64 coded partitionfile into %pre part + $partcontent = "cat > /tmp/partscript.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + # Put the code to decode the partitionfile + $partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partscript\n"; + $partcontent .= "chmod 755 /tmp/partscript\n"; + $partcontent .= "/tmp/partscript\n"; + #replace the #XCA_PARTITION_SCRIPT# + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; } - else{ - $partcontent =~ s/\s$//; - if ($inc =~ /#XCAT_PARTITION_START#/){ - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; - } - elsif ($inc =~ //){ - $inc =~ s/[\s\S]*/$partcontent/; - } + #for sles/suse + elsif ($inc =~ //){ + my $tempstr = "XCATPARTITIONTEMP"; + $inc =~ s/[\s\S]*/$tempstr/; + # Put the base64 coded partitionfile into %pre part + $partcontent = "cat > /tmp/partscript.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + # Put the code to decode the partitionfile + $partcontent .= "perl -ne 'use MIME::Base64; print decode_base64(\$_)' /tmp/partscript\n"; + $partcontent .= "chmod 755 /tmp/partscript\n"; + $partcontent .= "/tmp/partscript\n"; + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; + } + } + else{ + $partcontent =~ s/\s$//; + if ($inc =~ /#XCAT_PARTITION_START#/){ + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; + } + elsif ($inc =~ //){ + $inc =~ s/[\s\S]*/$partcontent/; } } - } - - $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; # handle the variable in #INCLUDE - if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; - } - if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg; - } - if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg; - } - if ($inc =~ /#INCLUDE:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; } } From 53d70830f53e14154e7335f8c50f9bf409cf2c07 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 13 Jun 2014 06:55:37 -0400 Subject: [PATCH 4/4] minor change for partition file handling --- xCAT-server/lib/perl/xCAT/Template.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index ccb34232c..f77c5f06d 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -167,10 +167,10 @@ sub subvars { } close ($inh); } - } - # append the partition file into the $inc to do the replacement - $inc .= "\nFFFFFFFFFFFFPARTITIONFILESTART\n".$partcontent; + # append the partition file into the $inc to do the replacement + $inc .= "\nFFFFFFFFFFFFPARTITIONFILESTART\n".$partcontent; + } #do *all* includes, recursive for all