start:makehosts_h
description:makehosts -h
cmd:makehosts -h
check:rc==0
check:output=~Usage
end

start:makehosts_help
description:makehosts --help
cmd:makehosts --help
check:rc==0
check:output=~Usage
end

start:makehosts_null
description:makehosts 
cmd:cp -f /etc/hosts /etc/hosts.xcatbak
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:mkdef -t node -o node01,node02 groups="compute"
check:rc==0
cmd:makehosts 
check:rc==0
cmd:cat /etc/hosts
check:output=~1.2.3.2 
check:output=~1.2.3.1 
check:output=~node01
check:output=~node02
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:rmdef node02
cmd:mv -f /etc/hosts.xcatbak /etc/hosts
end

start:makehosts_l
cmd:cp -f /etc/hosts /etc/hosts.xcatbak
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01,node02 groups="compute"
check:rc==0
cmd:makehosts -l
check:rc==0
cmd:cat /etc/hosts|awk '{print $2}'
check:output=~node01.cluster.net
check:output=~node02.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:rmdef node02
cmd:mv -f /etc/hosts.xcatbak /etc/hosts
end

start:makehosts_d
cmd:cp -f /etc/hosts /etc/hosts.xcatbak
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="compute"
check:rc==0
cmd:makehosts node01 
check:rc==0
cmd:cat /etc/hosts > /tmp/1
cmd:makehosts -d node01
check:rc==0
cmd:cat /etc/hosts > /tmp/2
cmd:diff /tmp/1 /tmp/2
check:output=~node01.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:mv -f /etc/hosts.xcatbak /etc/hosts
cmd:rm -f /tmp/1 /tmp/2
end

start:makehosts_n
cmd:cp -f /etc/hosts /etc/hosts.xcatbak
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="compute"
check:rc==0
cmd:makehosts -n
check:rc==0
cmd:cat /etc/hosts |wc -l
check:rc==0
check:output==2
cmd:cat /etc/hosts
check:output=~node01.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:mv -f /etc/hosts.xcatbak /etc/hosts
end

start:makehosts_n_noderange
cmd:cp -f /etc/hosts /etc/hosts.xcatbak
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="compute"
check:rc==0
cmd:makehosts -n node01
check:rc==0
cmd:cat /etc/hosts |wc -l
check:rc==0
check:output==2
cmd:cat /etc/hosts
check:output=~node01.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:mv -f /etc/hosts.xcatbak /etc/hosts
cmd:cat /etc/hosts| grep -v node01 > /tmp/1
cmd:mv -f /tmp/1 /etc/hosts 
end


