start:mkdef_null
description:mkdef without any flag
label:mn_only,db
cmd:mkdef
check:output=~Usage
end

start:mkdef_node
description:mkdef -t node
label:mn_only,db
cmd:mkdef -t node -o testnode,testnode1 groups=all,aix
check:rc==0
cmd:lsdef -i groups testnode
check:rc==0
check:output=~groups=all,aix
cmd:lsdef -i groups testnode1
check:rc==0
check:output=~groups=all,aix
cmd:rmdef -t node -o testnode,testnode1
end

start:mkdef_f
description:mkdef -f
label:mn_only,db
cmd:mkdef -t node -o testnode groups=all,aix
check:rc==0
cmd:mkdef -f -t node -o testnode nodetype=lpar,osi groups=all
check:rc==0
cmd:lsdef -i groups,nodetype testnode
check:rc==0
check:output=~nodetype=lpar,osi
check:output!=aix
cmd:rmdef -t node -o testnode
end	

start:mkdef_z
description:mkdef -z
label:mn_only,db
cmd:mkdef -t node -o orignode mgt=fsp cons=hmc pprofile=orignode groups=lpar,all
check:rc==0
cmd:lsdef -l orignode -z > /tmp/orignode.stanza
check:rc==0
cmd:perl -pi -e 's/orignode/testnode/g' /tmp/orignode.stanza
cmd:cat /tmp/orignode.stanza | mkdef -z
check:rc==0
cmd:lsdef -l testnode -z > /tmp/testnode.stanza
check:rc==0
cmd:diff /tmp/orignode.stanza /tmp/testnode.stanza
check:rc==0
cmd:rm -f /tmp/orignode.stanza
cmd:rm -f /tmp/testnode.stanza
cmd:rmdef -t node testnode
cmd:rmdef -t node orignode
end

start:mkdef_group
description: mkdef static node group
label:mn_only,db
cmd:mkdef -t node -o testnode1-testnode2 mgt=hmc cons=hmc groups=all,systemp
check:rc==0
cmd:mkdef -t node -o testnode3-testnode4 mgt=ipmi cons=ipmi groups=all,systemx
check:rc==0
cmd:mkdef -t group -o testgrp members=testnode1,testnode3
check:rc==0
cmd:lsdef -s testgrp
check:rc==0
check:output=~testnode1
check:output=~testnode3
check:output!~testnode2
check:output!~testnode4
cmd:lsdef testnode1
check:rc==0
check:output=~=all,systemp,testgrp
cmd:lsdef testnode3
check:rc==0
check:output=~=all,systemx,testgrp
cmd:rmdef -t group testgrp
check:rc==0
cmd:lsdef testgrp
check:output=~Could not find an object named 'testgrp'
cmd:lsdef -t group -o testgrp
check:output=~Could not find an object named 'testgrp'
cmd:lsdef testnode1
check:rc==0
check:output=~=all,systemp
check:output!~=testgrp
cmd:lsdef testnode3
check:rc==0
check:output=~=all,systemx
check:output!~=testgrp
cmd:rmdef -t node -o testnode1-testnode4
check:rc==0
end

start:mkdef_dynamic_group
description:mkdef with dynamic node group
label:mn_only,db
cmd:mkdef -t node -o testnode1-testnode2 mgt=hmc cons=hmc groups=all,systemp
check:rc==0
cmd:mkdef -t node -o testnode3-testnode4 mgt=ipmi cons=ipmi groups=all,systemx
check:rc==0
cmd:mkdef -t group -o dyngrp1 -d -w mgt==hmc
check:rc==0
cmd:lsdef -s dyngrp1
check:rc==0
check:output=~testnode1
check:output=~testnode2
check:output!~testnode3
check:output!~testnode4
cmd:mkdef -t group -o dyngrp2 -d -w mgt==hmc -w cons==hmc
check:rc==0
cmd:lsdef -s dyngrp2
check:rc==0
check:output=~testnode1
check:output=~testnode2
check:output!~testnode3
check:output!~testnode4
cmd:mkdef -t group -o dyngrp3 -d -w mgt==hmc -w cons==ipmi
check:rc==0
cmd:lsdef -s dyngrp3
check:rc!=0
check:output!~testnode1
check:output!~testnode2
check:output!~testnode3
check:output!~testnode4
cmd:rmdef -t group -o dyngrp1,dyngrp2,dyngrp3
check:rc==0
cmd:rmdef -t node -o testnode1-testnode4
check:rc==0
end

start:mkdef_multiple_keys
description:mkdef support for multiple keys in a table, such as ppcdirect
label:mn_only,db
cmd: mkdef -t node -o testfsp mgt=fsp cons=fsp groups=all,fsp nodetype=fsp passwd.HMC=abc123 passwd.general=abc123 passwd.admin=abc123
check:rc==0
cmd:lsdef testfsp
check:rc==0
check:output=~passwd.HMC=abc123
check:output=~passwd.general=abc123
check:output=~passwd.admin=abc123
cmd:rmdef -t node -o testfsp
check:rc==0
end

start:mkdef_t_network
description: mkdef -t network
label:mn_only,db
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0 gateway=1.2.3.1
check:rc==0
cmd:lsdef -t network
check:rc==0
check:output=~testnetwork
cmd:lsdef -t network -o testnetwork -l
check:rc==0
check:output=~net=1.2.3.0
check:output=~mask=255.255.255.0
check:output=~gateway=1.2.3.1
cmd:rmdef -t network testnetwork
end

start:mkdef_t_o_error
description:mkdef -t wrongtype
label:mn_only,db
cmd:mkdef -t wrongtype -o testnode groups=all,aix
check:rc!=0
check:output=~not a valid
end


start:mkdef_template_switch_template_without_attribute
description:create a node with swtich template without any attributes
label:mn_only,db
cmd:result=`lsdef | grep  auto_test_node_1`; if [[ $result =~ "auto_test_node_1" ]]; then echo $result; noderm auto_test_node_1; fi
cmd:mkdef -t node -o auto_test_node_1 --template switch-template
check:rc==0
check:output=~1 object definitions have been created or modified.
cmd:lsdef auto_test_node_1
check:rc==0
check:output=~Object name\: auto_test_node_1
check:output=~groups=switch
check:output=~nodetype=switch
check:output=~postbootscripts\=otherpkgs
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output=~usercomment\=the switch definition template
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output!=ip\=OPTIONAL\:the ip address of the switch
check:output!=mac\=OPTIONAL\:the MAC address of the switch
check:output!=switchtype\=
cmd:noderm auto_test_node_1
check:rc==0
end

start:mkdef_template_cec_template_without_remainder
description:create a node with cec template once
label:mn_only,db
cmd:result=`lsdef | grep  auto_test_cec_node_1`; if [[ $result =~ "auto_test_cec_node_1" ]]; then echo $result; noderm auto_test_cec_node_1; fi
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test mtm=test hcp=test
check:rc==0
check:output=~1 object definitions have been created or modified
cmd:lsdef auto_test_cec_node_1
check:output=~Object name\: auto\_test\_cec\_node\_1
check:output=~groups\=cec\,all
check:output=~hwtype\=cec
check:output=~mgt\=hmc
check:output=~nodetype\=ppc
check:output=~postbootscripts\=otherpkgs
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output=~usercomment\=the cec definition template
check:output=~hcp\=test
check:output=~mtm\=test
check:output=~serial\=test
cmd:noderm auto_test_cec_node_1
check:rc==0
end

start:mkdef_template_invalid_template
description:create a node with invalid template
label:mn_only,db
cmd:result=`lsdef | grep  auto_test_node`; if [[ $result =~ "auto_test_node" ]]; then echo $result; noderm auto_test_node; fi
cmd:result=`lsdef | grep  auto_test_invalid_template`; if [[ $result =~ "auto_test_invalid_template" ]]; then echo $result; noderm auto_test_invalid_template; fi
cmd:lsdef --template auto_test_invalid_template
check:rc==1
check:output=~Error\: (\[.*?\]: )?Could not find auto\_test\_invalid\_template in xCAT templates
cmd:mkdef -t node -o auto_test_node --template auto_test_invalid_template
check:rc==1
check:output=~Error\: (\[.*?\]: )?Could not find the template object named \'auto\_test\_invalid\_template\' of type \'node\'
end

start:mkdef_node_with_a_node_template
description:create a node with a node template, using cec template to create node at beginning
label:mn_only,db
cmd:result=`lsdef | grep  auto_test_cec_node_1`; if [[ $result =~ "auto_test_cec_node_1" ]]; then echo $result; noderm auto_test_cec_node_1; fi
cmd:result=`lsdef | grep  auto_test_cec_node_2`; if [[ $result =~ "auto_test_cec_node_2" ]]; then echo $result; noderm auto_test_cec_node_2; fi
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test mtm=test hcp=test groups=test_template
check:rc==0
check:output=~1 object definitions have been created or modified
check:output=~created
cmd:mkdef -t node -o auto_test_cec_node_2 --template auto_test_cec_node_1 serial=test2 mtm=test2 hcp=test2
check:rc==0
check:output=~1 object definitions have been created or modified
cmd:lsdef auto_test_cec_node_2
check:output=~Object name\: auto\_test\_cec\_node\_2
check:output=~groups\=test\_template
check:output!=groups\=cec\,all
check:output=~hwtype\=cec
check:output=~mgt\=hmc
check:output=~nodetype\=ppc
check:output=~postbootscripts\=otherpkgs
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output=~usercomment\=the cec definition template
check:output=~hcp\=test2
check:output=~mtm\=test2
check:output=~serial\=test2
cmd:noderm auto_test_cec_node_1
check:rc==0
cmd:noderm auto_test_cec_node_2
check:rc==0
end

start:mkdef_template_cec_template_step_by_step
description:create a node with cec template step by step
label:mn_only,db
cmd:result=`lsdef | grep  auto_test_cec_node_1`; if [[ $result =~ "auto_test_cec_node_1" ]]; then echo $result; noderm auto_test_cec_node_1; fi
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template
check:rc==1
check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified!
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test
check:rc==1
check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified!
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test hcp=test
check:rc==1
check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified!
cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test mtm=test hcp=test
check:rc==0
check:output=~1 object definitions have been created or modified
cmd:lsdef auto_test_cec_node_1
check:output=~Object name\: auto\_test\_cec\_node\_1
check:output=~groups\=cec\,all
check:output=~hwtype\=cec
check:output=~mgt\=hmc
check:output=~nodetype\=ppc
check:output=~postbootscripts\=otherpkgs
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output=~usercomment\=the cec definition template
check:output=~hcp\=test
check:output=~mtm\=test
check:output=~serial\=test
cmd:noderm auto_test_cec_node_1
check:rc==0
end

start:check_mkdef_node_with_template_priority
description:create node named cec-template with cec template at beginning, the node is priority high than tempalate to create a new node
label:mn_only,db
cmd:result=`lsdef | grep  cec-template`; if [[ $result =~ "cec-template" ]]; then echo $result; noderm cec-template; fi
cmd:result=`lsdef | grep  auto_test_cec_node`; if [[ $result =~ "auto_test_cec_node" ]]; then echo $result; noderm auto_test_cec_node; fi
cmd:mkdef -t node -o cec-template --template cec-template serial=test mtm=test hcp=test groups=test_template_priority
check:rc==0
check:output=~1 object definitions have been created or modified
cmd:mkdef -t node -o auto_test_cec_node --template cec-template serial=test2 mtm=test2 hcp=test2
check:rc==0
check:output=~1 object definitions have been created or modified
cmd:lsdef auto_test_cec_node
check:output=~Object name\: auto\_test\_cec\_node
check:output!=groups\=test\_template\_priority
check:output=~groups\=cec\,all
check:output=~hwtype\=cec
check:output=~mgt\=hmc
check:output=~nodetype\=ppc
check:output=~postbootscripts\=otherpkgs
check:output=~postscripts\=syslog\,remoteshell\,syncfiles
check:output=~usercomment\=the cec definition template
check:output=~hcp\=test2
check:output=~mtm\=test2
check:output=~serial\=test2
cmd:noderm cec-template
check:rc==0
cmd:noderm auto_test_cec_node
check:rc==0
end

start:mkdef_template_diskless_osimage_rootimgdir
description:check rootimgdir warning message after make new osimage with mkdef --template
label:cn_os_ready,db
cmd:mkdef -t osimage -o test-osimage_with_template --template  __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
output=~1 object definitions have been created or modified
cmd:xcatprobe osimagecheck
check:output=~Identical root image directory
check:output=~test-osimage
check:output=~__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
cmd:rmdef -t osimage -o test-osimage_with_template
check:rc==0
end

start:mkdef_rhels73
description:create rhels7.3 osimage
label:mn_only,db
cmd:mkdef -t osimage -o rhels7.3-test-osimage --template  __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
output=~1 object definitions have been created or modified
cmd:rmdef -t osimage -o rhels7.3-test-osimage
check:rc==0
cmd:lsdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -z > /tmp/osiamge.stanza
check:rc==0
cmd:cat /tmp/osiamge.stanza |sed 's/__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute:/rhels7.3-test:/g' >/tmp/osiamge.stanza1
check:rc==0
cmd:cat /tmp/osiamge.stanza1|mkdef -z
check:rc==0
cmd:rm -rf /tmp/osiamge.stanza;rm -rf /tmp/osiamge.stanza1
check:rc==0
cmd:lsdef -t osimage -o rhels7.3-test |grep "Object name: rhels7.3-test"
check:rc==0
cmd:lsdef -t osimage -o rhels7.3-test |grep pkgdir=
check:rc==0
cmd:rmdef -t osimage -o rhels7.3-test
check:rc==0
end
