From 35376641b41282d2c407021a307ee2761ffb2c37 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 13 Jan 2014 07:54:05 -0500 Subject: [PATCH] To make bmcsetup cmd to update node status to be [bmcready] in genesis; And make chain mechanism to support [shutdown] key word which is used to poweroff the node --- perl-xCAT/xCAT/GlobalDef.pm | 2 ++ xCAT-genesis-scripts/bin/bmcsetup | 10 ++++++++ xCAT-genesis-scripts/bin/doxcat | 2 ++ xCAT-genesis-scripts/bin/updateflag.awk | 32 +++++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/destiny.pm | 2 +- 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 xCAT-genesis-scripts/bin/updateflag.awk diff --git a/perl-xCAT/xCAT/GlobalDef.pm b/perl-xCAT/xCAT/GlobalDef.pm index 14dc0fb58..872433cb8 100644 --- a/perl-xCAT/xCAT/GlobalDef.pm +++ b/perl-xCAT/xCAT/GlobalDef.pm @@ -56,6 +56,7 @@ $::STATUS_SHELL="shell"; $::STATUS_DEFINED="defined"; $::STATUS_UNKNOWN="unknown"; $::STATUS_FAILED="failed"; +$::STATUS_BMCREADY="bmcready"; %::VALID_STATUS_VALUES = ( $::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1, @@ -72,6 +73,7 @@ $::STATUS_FAILED="failed"; $::STATUS_DEFINED=>1, $::STATUS_UNKNOWN=>1, $::STATUS_FAILED=>1, + $::STATUS_BMCREADY=>1, $::STATUS_SYNCING=>1, $::STATUS_OUT_OF_SYNC=>1, diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index a3336706a..d140f2dc2 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -381,6 +381,16 @@ if [ ! "$IPMIVER" == "1.5" ]; then if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi fi +# update the node status to 'bmcready' +for parm in `cat /proc/cmdline`; do + key=`echo $parm|awk -F= '{print $1}'` + if [ "$key" = "xcatd" ]; then + XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` + fi +done +if [ ! -z "$XCATMASTER" ]; then + updateflag.awk $XCATMASTER 3002 "installstatus bmcready" +fi #frume.awk echo "Lighting Identify Light" diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index eb412ae57..af49141e3 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -189,6 +189,8 @@ while :; do sleep 1 done echo "Retrying "; + elif [ "$dest" = shutdown ]; then + poweroff -f else echo "Unrecognized directive $dest" destiny='' diff --git a/xCAT-genesis-scripts/bin/updateflag.awk b/xCAT-genesis-scripts/bin/updateflag.awk new file mode 100755 index 000000000..66fbc9ebf --- /dev/null +++ b/xCAT-genesis-scripts/bin/updateflag.awk @@ -0,0 +1,32 @@ +#!/usr/bin/awk -f +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { + xcatdhost = ARGV[1] + xcatdport = ARGV[2] + flag = ARGV[3] + + if (!flag) flag = "next" + + ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport + + while(1) { + if((ns |& getline) > 0) + print $0 | "logger -t xcat -p local4.info" + else { + print "Retrying flag update" | "logger -t xcat -p local4.info" + close(ns) + system("sleep 10") + } + + if($0 == "ready") + print flag |& ns + if($0 == "done") + break + } + + close(ns) + + exit 0 +} + diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 9c81f1290..89203982b 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -453,7 +453,7 @@ sub setdestiny { return; } } - } elsif ($state eq "offline") { + } elsif ($state eq "offline" || $state eq "shutdown") { 1; } elsif (!($state eq "boot")) { $callback->({error=>["Unknown state $state requested"],errorcode=>[1]});