From 8f61ee5aceacd0ee4278cf7b3d4f905a25c23828 Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 29 Mar 2018 05:50:04 -0400 Subject: [PATCH] Add ondiscover support for chain table (#4903) * Add ondiscover support for chain table * For ondiscover, run nextdestiny after the current operation is done * Don't set OpenPower server boot from network if boot --- xCAT-genesis-scripts/usr/bin/doxcat | 20 ++++++++++++++------ xCAT-server/lib/xcat/plugins/destiny.pm | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/xCAT-genesis-scripts/usr/bin/doxcat b/xCAT-genesis-scripts/usr/bin/doxcat index e5bbe71b0..1e909551d 100755 --- a/xCAT-genesis-scripts/usr/bin/doxcat +++ b/xCAT-genesis-scripts/usr/bin/doxcat @@ -359,17 +359,17 @@ while :; do logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` logger -s -t $log_label -p local4.info "nextdestiny - Complete." + elif [ "$dest" = ondiscover ]; then + logger -s -t $log_label -p local4.info "Running nextdestiny (ondiscover) $XCATMASTER:$XCATPORT..." + destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` + logger -s -t $log_label -p local4.info "nextdestiny (ondiscover) - Complete." elif [ "$dest" = runcmd ]; then + $destparameter logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` dest=`echo $destiny|awk -F= '{print $1}'` - $destparameter logger -s -t $log_label -p local4.info "nextdestiny - Complete." elif [ "$dest" = runimage ]; then - logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." - destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` - dest=`echo $destiny|awk -F= '{print $1}'` - logger -s -t $log_label -p local4.info "nextdestiny - Complete." mkdir /tmp/`basename $destparameter` cd /tmp/`basename $destparameter` eval destparameter=$destparameter @@ -389,12 +389,20 @@ while :; do tar xvf `basename $destparameter` ./runme.sh cd - + logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." + destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` + dest=`echo $destiny|awk -F= '{print $1}'` + logger -s -t $log_label -p local4.info "nextdestiny - Complete." + elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." /bin/nextdestiny $XCATMASTER:$XCATPORT logger -s -t $log_label -p local4.info "nextdestiny - Complete." if [ $IPMI_SUPPORT -ne 0 ]; then - ipmitool chassis bootdev pxe + # Set boot from network will cause OpenPOWER server wait at petitboot menu, so do nothing here + if uname -m | grep x86_64; then + ipmitool chassis bootdev pxe + fi fi reboot -f elif [ "$dest" = "install" -o "$dest" = "netboot" ]; then diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 48b8411a2..38f16ed1b 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -226,6 +226,25 @@ sub setdestiny { if ($ient->{initrd}) { $bphash->{initrd} = $ient->{initrd} } if ($ient->{kcmdline}) { $bphash->{kcmdline} = $ient->{kcmdline} } } + } elsif ($state =~ /ondiscover/) { + my $target; + if ($state =~ /=/) { + ($state, $target) = split '=', $state, 2; + } + if(!$target){ + $callback->({ error => "invalid argument: \"$state\"", errorcode => [1] }); + return; + } + my @cmds = split '\|', $target; + foreach my $tmpnode (@{ $req->{node} }) { + foreach my $cmd (@cmds) { + my $action; + ($cmd, $action) = split ':', $cmd; + my $runcmd = "$cmd $tmpnode $action"; + xCAT::Utils->runcmd($runcmd, 0); + xCAT::MsgUtils->trace($verbose, "d", "run ondiscover command: $runcmd"); + } + } } elsif ($state =~ /^install[=\$]/ or $state eq 'install' or $state =~ /^netboot[=\$]/ or $state eq 'netboot' or $state eq "image" or $state eq "winshell" or $state =~ /^osimage/ or $state =~ /^statelite/) { my $target; my $action;