From ac02f48b020a185c59c93283cf7ebab8e664653a Mon Sep 17 00:00:00 2001 From: nott Date: Wed, 15 Feb 2012 15:10:50 +0000 Subject: [PATCH] fix emgr support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.6@11580 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/aixinstall.pm | 380 +++++++++++++-------- 1 file changed, 237 insertions(+), 143 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index 644ac2dc7..2e3a47607 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -125,12 +125,11 @@ sub preprocess_request # need for runcmd output $::CALLBACK = $cb; - #if already preprocessed, go straight to request - if ( (defined($req->{_xcatpreprocessed})) - && ($req->{_xcatpreprocessed}->[0] == 1)) - { - return [$req]; - } + #if already preprocessed, go straight to request + if ( (defined($req->{_xcatpreprocessed})) && ($req->{_xcatpreprocessed}->[0] == 1)) + { + return [$req]; + } my $nodes = $req->{node}; # this may not be the list of nodes we need! my $service = "xcat"; @@ -1126,6 +1125,7 @@ sub nimnodeset $cmdargs{boot_client} = "no"; } + # set accept_licenses if (!defined($cmdargs{accept_licenses})) { @@ -1590,7 +1590,7 @@ sub spot_updates { my $rsp; push @{$rsp->{data}}, - "Could not update software in the NIM SPOT called \'$spot_name\'.\n"; + "One or more errors occurred when attempting to update software in the NIM SPOT called \'$spot_name\'.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } @@ -1906,7 +1906,7 @@ sub chkosimage my %pkgtype; foreach my $pkg (@pkglist) { - if (($pkg =~ /R:/) || ($pkg =~ /I:/) ) + if (($pkg =~ /^R:/) || ($pkg =~ /^I:/) || ($pkg =~ /^E:/) ) { my ($junk, $pname) = split(/:/, $pkg); push(@install_list, $pname); @@ -1914,7 +1914,7 @@ sub chkosimage push(@install_list, $pkg); } - if (($pkg =~ /R:/)) { + if (($pkg =~ /^R:/)) { # get a separate list of just the rpms - they must be preceded # by R: my ($junk, $pname) = split(/:/, $pkg); @@ -1937,6 +1937,7 @@ sub chkosimage my $rpm_srcdir = "$lpp_loc/RPMS/ppc"; my $instp_srcdir = "$lpp_loc/installp/ppc"; + my $emgr_srcdir = "$lpp_loc/emgr/ppc"; # get rpm packages my $rcmd = qq~/usr/bin/ls $rpm_srcdir 2>/dev/null~; @@ -1950,8 +1951,7 @@ sub chkosimage } # get epkg files - # epkg files should go with installp filesets - I think? - my $ecmd = qq~/usr/bin/ls $instp_srcdir 2>/dev/null~; + my $ecmd = qq~/usr/bin/ls $emgr_srcdir 2>/dev/null~; my @elist = xCAT::Utils->runcmd("$ecmd", -1); foreach my $f (@elist) { if (($f =~ /epkg\.Z/)) { @@ -8048,6 +8048,7 @@ sub copyres $bkfile = &bkupNIMresources($callback, $bkdir, $resname); if (!defined($bkfile)) { + my $rsp; push @{$rsp->{data}}, "Could not archive $bkdir.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); @@ -11402,7 +11403,7 @@ sub update_spot_sw xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - + my $error; if (scalar(@bndlnames) > 0) { # do installp/RPM install for each bndls @@ -11422,17 +11423,17 @@ sub update_spot_sw } # construct tmp file to hold the pkg list. - my ($tmp_installp, $tmp_rpm) = parse_installp_bundle($callback, $bndlloc); + my ($tmp_installp, $tmp_rpm, $tmp_emgr) = parse_installp_bundle($callback, $bndlloc); # use xcatchroot to install sw in SPOT on nimprime. - + # install installp with file first. - if (defined($tmp_installp) ) { + if ( -e $tmp_installp ){ my $rc = update_spot_installp($callback, $chroot_lpploc, $tmp_installp, $iflags, $spotname, $nimprime, $subreq); if ($rc) { #failed to update installp - return 1; + $error++; } # remove tmp file @@ -11447,7 +11448,7 @@ sub update_spot_sw push @{$rsp->{data}}, "Could not run command: $cmd.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; + $error++; } # - run updtvpkg to make sure installp software @@ -11464,46 +11465,83 @@ sub update_spot_sw push @{$rsp->{data}}, "Could not run command: $cmd.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; + $error++; } } + # then install epkgs. + if ( -e $tmp_emgr ) { + unless (open(EFILE, "<$tmp_emgr")) + { + my $rsp; + push @{$rsp->{data}}, "Could not open $tmp_emgr for reading.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } else { + + my @elist = ; + close(EFILE); + + my $rc = update_spot_epkg($callback, $chroot_epkgloc, $tmp_emgr, $eflags, $spotname, $nimprime, $subreq); + if ($rc) + { + #failed to update RPM + $error++; + } + + # remove tmp file + my $cmd = qq~/usr/bin/rm -f $tmp_emgr~; + + my $output = + xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); + + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, + "Could not run command: $cmd.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } + } + } + # then to install RPMs. - if (defined($tmp_rpm) ) { + if (-e $tmp_rpm) { unless (open(RFILE, "<$tmp_rpm")) { my $rsp; push @{$rsp->{data}}, "Could not open $tmp_rpm for reading.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + $error++; + } else { - my @rlist = ; - close(RFILE); + my @rlist = ; + close(RFILE); - my $rc = update_spot_rpm($callback, $chroot_rpmloc, \@rlist, - $rflags, $spotname, $nimprime, $subreq); - if ($rc) - { - #failed to update RPM - return 1; - } + my $rc = update_spot_rpm($callback, $chroot_rpmloc, \@rlist,$rflags, $spotname, $nimprime, $subreq); + if ($rc) + { + #failed to update RPM + $error++; + } - # remove tmp file - my $cmd = qq~/usr/bin/rm -f $tmp_rpm~; + # remove tmp file + my $cmd = qq~/usr/bin/rm -f $tmp_rpm~; - my $output = - xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); + my $output = + xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, - "Could not run command: $cmd.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, + "Could not run command: $cmd.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } + } } } } @@ -11526,37 +11564,37 @@ sub update_spot_sw my $rsp; push @{$rsp->{data}}, "Could not open $tmp_installp for writing.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + $error++; + } else { - foreach (@$i_pkgs) - { - print IFILE $_ . "\n"; - } - close(IFILE); + foreach (@$i_pkgs) + { + print IFILE $_ . "\n"; + } + close(IFILE); - my $rc = update_spot_installp($callback, $chroot_lpploc, $tmp_installp, - $iflags, $spotname, $nimprime, $subreq); - if ($rc) - { - #failed to update installp - return 1; - } + my $rc = update_spot_installp($callback, $chroot_lpploc, $tmp_installp, $iflags, $spotname, $nimprime, $subreq); + if ($rc) + { + #failed to update installp + $error++; + } - # remove tmp file - my $cmd = qq~/usr/bin/rm -f $tmp_installp~; + # remove tmp file + my $cmd = qq~/usr/bin/rm -f $tmp_installp~; - my $output = - xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); + my $output = + xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, - "Could not run command: $cmd.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, + "Could not run command: $cmd.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } + } } # 2. update rpm in spot @@ -11567,7 +11605,7 @@ sub update_spot_sw if ($rc) { #failed to update RPM - return 1; + $error++; } } @@ -11582,42 +11620,46 @@ sub update_spot_sw my $rsp; push @{$rsp->{data}}, "Could not open $tmp_epkg for writing.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + $error++; + } else { - foreach (@$epkgs) - { - print FILE $_ . "\n"; - } - close(FILE); + foreach (@$epkgs) + { + print FILE $_ . "\n"; + } + close(FILE); - my $rc = update_spot_epkg($callback, $chroot_epkgloc, $tmp_epkg, - $eflags, $spotname, $nimprime, $subreq); - if ($rc) - { - #failed to update epkgs - return 1; - } + my $rc = update_spot_epkg($callback, $chroot_epkgloc, $tmp_epkg,$eflags, $spotname, $nimprime, $subreq); + if ($rc) + { + #failed to update epkgs + $error++; + } - # remove tmp file - my $cmd = qq~/usr/bin/rm -f $tmp_epkg~; + # remove tmp file + my $cmd = qq~/usr/bin/rm -f $tmp_epkg~; - my $output = - xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); + my $output = + xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $nimprime, $cmd, 0); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, - "Could not run command: $cmd.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, + "Could not run command: $cmd.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } } } } # end otherpkgs - return 0; + if ($error) { + return 1; + } else { + return 0; + } } #------------------------------------------------------------------------------- @@ -11794,24 +11836,22 @@ sub sync_spot_files generate tmp files for installp filesets and RPMs separately based on NIM installp_bundles - /tmp/tmp_installp, /tmp/tmp_rpm + /tmp/tmp_installp, /tmp/tmp_rpm, /tmp/tmp_epkg Arguments: callback, installp_bundle location Returns: - installp list file, rpm list file + installp list file, rpm list file, epkg list file Comments: - my ($tmp_installp, $tmp_rpm) = parse_installp_bundle($callback, $bndlloc); + my ($tmp_installp, $tmp_rpm, $tmp_emgr) = parse_installp_bundle($callback, $bndlloc); =cut #------------------------------------------------------------------------------- - sub parse_installp_bundle { - my $callback = shift; my $bndfile = shift; @@ -11827,30 +11867,51 @@ sub parse_installp_bundle # put installp/rpm into an array my @ilist; my @rlist; + my @elist; + my ($junk, $pname); while (my $line = ) { - chomp $line; - - if ($line =~ /^I:/) - { - my ($junk, $iname) = split(/:/, $line); - push (@ilist, $iname); - } - elsif ($line =~ /^R:/) - { - my ($junk, $rname) = split(/:/, $line); - push (@rlist, $rname); - } - } + # skip blank and comment lines + next if ($line =~ /^\s*$/ || $line =~ /^\s*#/); + chomp $line; + + if (($line =~ /\.rpm/) || ($line =~ /^R:/)) + { + if ($line =~ /:/) { + ($junk, $pname) = split(/:/, $line); + } else { + $pname = $line; + } + push (@rlist, $pname); + } + elsif (($line =~ /epkg\.Z/) || ($line =~ /^E:/)) + { + if ($line =~ /:/) { + ($junk, $pname) = split(/:/, $line); + } else { + $pname = $line; + } + push (@elist, $pname); + } else { + if ($line =~ /:/) { + ($junk, $pname) = split(/:/, $line); + } else { + $pname = $line; + } + push (@ilist, $pname); + } + } close(BNDL); # put installp list into tmp file my $tmp_installp = "/tmp/tmp_installp"; my $tmp_rpm = "/tmp/tmp_rpm"; + my $tmp_emgr = "/tmp/tmp_emgr"; + + if ( scalar(@ilist)) { - if ( scalar @ilist) { unless (open(IFILE, ">$tmp_installp")) { my $rsp; @@ -11865,10 +11926,10 @@ sub parse_installp_bundle } close(IFILE); } else { - $tmp_installp=undef; + $tmp_installp=""; } - if ( scalar @rlist) { + if ( scalar(@rlist)) { # put rpm list into tmp file unless (open(RFILE, ">$tmp_rpm")) { @@ -11884,10 +11945,29 @@ sub parse_installp_bundle } close(RFILE); } else { - $tmp_rpm=undef; + $tmp_rpm=""; } - return ($tmp_installp, $tmp_rpm); + if ( scalar(@elist)) { + # put emgr list into tmp file + unless (open(EFILE, ">$tmp_emgr")) + { + my $rsp; + push @{$rsp->{data}}, "Could not open $tmp_emgr for writing.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + foreach (@elist) + { + print EFILE $_ . "\n"; + } + close(EFILE); + } else { + $tmp_emgr=""; + } + + return ($tmp_installp, $tmp_rpm, $tmp_emgr); } @@ -11910,7 +11990,6 @@ sub parse_installp_bundle =cut #------------------------------------------------------------------------------- - sub parse_otherpkgs { my $callback = shift; @@ -11937,7 +12016,7 @@ sub parse_otherpkgs foreach my $p (@pkglist) { chomp $p; - if (($p =~ /\.rpm/) || ($p =~ /R:/)) + if (($p =~ /\.rpm/) || ($p =~ /^R:/)) { if ($p =~ /:/) { @@ -11951,6 +12030,10 @@ sub parse_otherpkgs } elsif (($p =~ /epkg\.Z/)) { + if ($p =~ /:/) + { + ($junk, $pname) = split(/:/, $p); + } push @epkgs, $p; } else @@ -11965,7 +12048,6 @@ sub parse_otherpkgs } push @installp_pkgs, $pname; } - } return (\@installp_pkgs, \@rpm_pkgs, \@epkgs); @@ -12031,6 +12113,7 @@ sub update_spot_installp my $rsp; push @{$rsp->{data}}, "Could not install installp packages in SPOT $spotname.\n"; + push @{$rsp->{data}}, "\n\'$output\'\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } @@ -12097,15 +12180,16 @@ sub update_spot_rpm my $cdcmd = qq~cd $source_dir;~; my $cmd; - # need to test rpms to make sure all will install - #- add test to rpm cmd if not included in rpm_flags + # - need to test rpms to make sure all will install + # - add test to rpm cmd if not included in rpm_flags # - my @doinstall; - my @dontinstall; + my @doinstall = split /\s+/, $rpmpkgs; + my @dontinstall=(); # see if this is an install or update if ( ($rpm_flags =~ /\-i/ ) || ($rpm_flags =~ /install / ) || ($rpm_flags =~ /U/ ) || ($rpm_flags =~ /update / ) ) { # if so then do test + @doinstall = (); my $rflags; # if the flags don't include test then add it @@ -12118,6 +12202,8 @@ sub update_spot_rpm my @badrpms; foreach my $line (@outpt) { + chomp $line; + $line =~ s/^\s+//; #remove leading spaces my ($first, $second, $rest) = split /\s+/, $line; chomp $first; if ($first eq 'package') { @@ -12126,17 +12212,23 @@ sub update_spot_rpm } my @origrpms = split /\s+/, $rpmpkgs; - foreach my $r ( @origrpms) { - my $sr = $r; + foreach my $sr ( @origrpms) { + my $r = $sr; $r =~ s/\*$//g; - if (grep(/$r/, @badrpms)){ - push @dontinstall, $sr; - } else { - push @doinstall, $sr; - } + my $found=0; + foreach my $b (@badrpms) { + if ($b =~ /$r/) { + push @dontinstall, $sr; + $found++; + last; + } + } + if (!$found ) { + push @doinstall, $sr; + } } - if (scalar @doinstall) { + if (scalar(@doinstall)) { $rpmpkgs= join(' ', @doinstall); } else { @@ -12159,6 +12251,9 @@ sub update_spot_rpm if ($::RUNCMD_RC != 0) { $error++; + my $rsp; + # push @{$rsp->{data}}, "\n\'$output\'\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); } if ($::VERBOSE) @@ -12173,12 +12268,12 @@ sub update_spot_rpm my $rsp; push @{$rsp->{data}}, "The following RPM packages were already installed and were not reinstalled:\n"; xCAT::MsgUtils->message("W", $rsp, $callback); - $rsp ={}; + my $rsp2; foreach my $rpm (@dontinstall) { - push @{$rsp->{data}}, "$rpm"; + push @{$rsp2->{data}}, "$rpm"; } - push @{$rsp->{data}}, "\n"; - xCAT::MsgUtils->message("I", $rsp, $callback); + push @{$rsp2->{data}}, "\n"; + xCAT::MsgUtils->message("I", $rsp2, $callback); } if ($error) @@ -12197,9 +12292,7 @@ sub update_spot_rpm xCAT::MsgUtils->message("I", $rsp, $callback); } - - - return 0; + return 0; } #------------------------------------------------------------------------------- @@ -12221,6 +12314,7 @@ sub update_spot_rpm Comments: This uses "xcatchroot" and "emgr" commands directly. Note: assume the *.epkg.Z is copied to lpp_source dir already! + ( ..../emgr/ppc/*.Z ) =cut @@ -12242,7 +12336,7 @@ sub update_spot_epkg xCAT::MsgUtils->message("I", $rsp, $callback); } - my $cdcmd = qq~cd $source_dir;~; + my $cdcmd = qq~cd $source_dir; export INUCLIENTS=1;~; my $ecmd = qq~/usr/sbin/emgr $eflags -f $listfile~; my $cmd = qq~$::XCATROOT/bin/xcatchroot -i $spotname "$cdcmd $ecmd"~; @@ -12252,8 +12346,8 @@ sub update_spot_epkg if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, - "Could not install the interim fix in SPOT $spotname.\n"; + push @{$rsp->{data}}, "One or more errors occurred while trying to install interim fix packages in $spotname.\n"; + push @{$rsp->{data}}, "\n\'$output\'\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; }