start:redhat_migration1
os:Linux
description:update xCAT from $$MIGRATION1_VERSION to latest version, these two global parameter defined in config file

cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;echo "poweroffsn">/tmp/poweroffsn;fi
check:rc==0
cmd:if [[ "__GETNODEATTR($$SN,groups)__" =~ "service" ]];then chdef $$SN -m groups=service;echo "servicelabel" >/tmp/servicelabel;fi
check:rc==0
cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN  xcatmaster=$$MN
check:rc==0
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
cmd:makeconservercf $$CN
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:sleep 60
cmd:if [ "__GETNODEATTR($$CN,arch)__" = "ppc64" -a  "__GETNODEATTR($$CN,mgt)__" != "ipmi" ]; then getmacs -D $$CN; fi
check:rc==0
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi
check:output=~$$CN
cmd:copycds $$ISO
check:rc==0
cmd:rinstall $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
check:rc==0
check:output=~Provision node\(s\)\: $$CN
cmd:sleep 600
cmd:lsdef -l $$CN | grep status
cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done
cmd:ping $$CN -c 3
check:output=~64 bytes from $$CN
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:xdsh $$CN "rm -rf /oldxcat"
cmd:xdsh $$CN "mkdir -p /oldxcat"
check:rc==0
cmd:xdsh $$CN "yum -y install bzip2"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat;wget $$MIGRATION1_DEP"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat;wget $$MIGRATION1_CORE"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /oldxcat/xcat-dep* -C /oldxcat"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /oldxcat/xcat-core* -C /oldxcat"
check:rc==0
cmd:xdsh $$CN "/oldxcat/xcat-core/mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat/xcat-dep/rh`echo __GETNODEATTR($$CN,os)__ | cut -c6`/__GETNODEATTR($$CN,arch)__/;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "yum clean all;yum -y install xCAT"
check:rc==0
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh"
check:rc==0
cmd:xdsh $$CN "lsxcatd -v"
check:rc==0
check:output=~$$MIGRATION1_VERSION
cmd:xdsh $$CN "service xcatd status"
check:rc==0
check:output=~running
cmd:xdsh $$CN "chdef -t node -o node0001  nodetype=osi groups=linux"
check:rc==0
cmd:xdsh $$CN "lsdef"
check:output=~node0001
cmd:check==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/core-rpms-snap.tar.bz2 /"
check:rc==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/xcat-dep*.tar.bz2 /"
check:rc==0
cmd:xdsh $$CN "tar -jxf /core-rpms-snap.tar.bz2"
check:rc==0
cmd:xdsh $$CN "cd /root/xcat-core;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /xcat-dep*.tar.bz2"
check:rc==0
cmd:xdsh $$CN "cd /root/xcat-dep/rh`echo __GETNODEATTR($$CN,os)__ | cut -c6`/__GETNODEATTR($$CN,arch)__/;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "yum clean metadata;yum -y update '*xCAT*'"
check:rc==0
cmd:xdsh $$CN "service xcatd status"
check:rc==0
check:output=~running
cmd:xdsh $$CN "lsdef"
check:output=~node0001
cmd:xdsh $$CN "noderm node0001"
check:rc==0
cmd:latest_version_info=`lsxcatd -v`;xdsh $$CN "lsxcatd -v" | grep "$latest_version_info"
check:rc==0
cmd:if [[ -f /tmp/servicelabel ]];then chdef $$SN -p groups=service;rm -rf /tmp/servicelabel;fi
check:rc==0
cmd:if [[ -f /tmp/poweroffsn ]];then rpower $$SN on > /dev/null;rm -rf /tmp/poweroffsn;fi
check:rc==0
end

start:redhat_migration2
os:Linux
description:update xCAT from $$MIGRATION2_VERSION to latest version, these two global parameter defined in config file
#stop:yes
cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;echo "poweroffsn">/tmp/poweroffsn;fi
check:rc==0
cmd:if [[ "__GETNODEATTR($$SN,groups)__" =~ "service" ]];then chdef $$SN -m groups=service;echo "servicelabel" >/tmp/servicelabel;fi
check:rc==0
cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN  xcatmaster=$$MN
check:rc==0
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
cmd:makeconservercf $$CN
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:sleep 60
cmd:if [ "__GETNODEATTR($$CN,arch)__" = "ppc64" -a  "__GETNODEATTR($$CN,mgt)__" != "ipmi" ]; then getmacs -D $$CN; fi
check:rc==0
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi
check:output=~$$CN
cmd:copycds $$ISO
check:rc==0
cmd:rinstall $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
check:rc==0
check:output=~Provision node\(s\)\: $$CN
cmd:sleep 600
cmd:lsdef -l $$CN | grep status
cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done
cmd:ping $$CN -c 3
check:output=~64 bytes from $$CN
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:xdsh $$CN "rm -rf /oldxcat"
cmd:xdsh $$CN "mkdir -p /oldxcat"
check:rc==0
cmd:xdsh $$CN "yum -y install bzip2"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat;wget $$MIGRATION2_DEP"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat;wget $$MIGRATION2_CORE"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /oldxcat/xcat-dep* -C /oldxcat"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /oldxcat/xcat-core* -C /oldxcat"
check:rc==0
cmd:xdsh $$CN "/oldxcat/xcat-core/mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "cd /oldxcat/xcat-dep/rh`echo __GETNODEATTR($$CN,os)__ | cut -c6`/__GETNODEATTR($$CN,arch)__/;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "yum clean all;yum -y install xCAT"
check:rc==0
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh"
check:rc==0
cmd:xdsh $$CN "lsxcatd -v"
check:rc==0
check:output=~$$MIGRATION2_VERSION
cmd:xdsh $$CN "service xcatd status"
check:rc==0
check:output=~running
cmd:xdsh $$CN "chdef -t node -o node0001  nodetype=osi groups=linux"
check:rc==0
cmd:xdsh $$CN "lsdef"
check:output=~node0001
cmd:check==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/core-rpms-snap.tar.bz2 /"
check:rc==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/xcat-dep*.tar.bz2 /"
check:rc==0
cmd:xdsh $$CN "tar -jxf /core-rpms-snap.tar.bz2"
check:rc==0
cmd:xdsh $$CN "cd /root/xcat-core;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "tar -jxvf /xcat-dep*.tar.bz2"
check:rc==0
cmd:xdsh $$CN "cd /root/xcat-dep/rh`echo __GETNODEATTR($$CN,os)__ | cut -c6`/__GETNODEATTR($$CN,arch)__/;./mklocalrepo.sh"
check:rc==0
cmd:xdsh $$CN "yum clean metadata;yum -y update '*xCAT*'"
check:rc==0
cmd:xdsh $$CN "service xcatd status"
check:rc==0
check:output=~running
cmd:xdsh $$CN "lsdef"
check:output=~node0001
cmd:xdsh $$CN "noderm node0001"
check:rc==0
cmd:latest_version_info=`lsxcatd -v`;xdsh $$CN "lsxcatd -v" | grep "$latest_version_info"
check:rc==0
cmd:if [[ -f /tmp/servicelabel ]];then chdef $$SN -p groups=service;rm -rf /tmp/servicelabel;fi
check:rc==0
cmd:if [[ -f /tmp/poweroffsn ]];then rpower $$SN on > /dev/null;rm -rf /tmp/poweroffsn;fi
check:rc==0
end

