start:export_import_credential
description:This case is used to test xcat-inventory support credential export and import.
label:others,xcat_inventory
cmd:dir="/tmp/credential";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi; mkdir -p $dir
cmd:dir="/tmp/backup";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi; mkdir -p $dir
cmd:cp -rf /etc/xcat/ca/ca-cert.pem /etc/xcat/ca/private/ca-key.pem /etc/xcat/cert/server-cred.pem /root/.xcat/client-key.pem /tmp/backup
check:rc==0
cmd:xcat-inventory export -t credential -d /tmp/credential
check:rc==0
check:output=~The credential objects has been exported to directory /tmp/credential
cmd:diff -y /etc/xcat/ca/ca-cert.pem /tmp/credential/credential/etc/xcat/ca/ca-cert.pem
check:rc==0
cmd:diff -y /etc/xcat/ca/private/ca-key.pem  /tmp/credential/credential/etc/xcat/ca/private/ca-key.pem
check:rc==0
cmd:diff -y  /etc/xcat/cert/server-cred.pem  /tmp/credential/credential/etc/xcat/cert/server-cred.pem
check:rc==0
cmd:diff -y /root/.xcat/client-key.pem  /tmp/credential/credential/root/.xcat/client-key.pem
check:rc==0
cmd:sed -i '$a\test' /etc/xcat/ca/ca-cert.pem
check:rc==0
cmd:sed -i '$a\test' /etc/xcat/ca/private/ca-key.pem
check:rc==0
cmd:sed -i '$a\test' /etc/xcat/cert/server-cred.pem
check:rc==0
cmd:sed -i '$a\test' /root/.xcat/client-key.pem
check:rc==0
cmd:xcat-inventory import -t credential -d /tmp/credential
check:rc==0
check:output=~Inventory import successfully!
check:output=~Warning: the /etc/xcat/ca/ca-cert.pem already exists, will be overwritten
check:output=~Warning: the /etc/xcat/ca/private/ca-key.pem already exists, will be overwritten
check:output=~Warning: the /root/.xcat/client-key.pem already exists, will be overwritten
check:output=~Warning: the /etc/xcat/cert/server-cred.pem already exists, will be overwritten
check:output=~The object credential has been imported
cmd:diff -y /etc/xcat/ca/ca-cert.pem /tmp/backup/ca-cert.pem
check:rc==0
cmd:diff -y /etc/xcat/ca/private/ca-key.pem  /tmp/backup/ca-key.pem
check:rc==0
cmd:diff -y  /etc/xcat/cert/server-cred.pem  /tmp/backup/server-cred.pem
check:rc==0
cmd:diff -y /root/.xcat/client-key.pem  /tmp/backup/client-key.pem
check:rc==0
cmd:rm -rf /tmp/credential
cmd:cp -rf /tmp/backup/ca-cert.pem /etc/xcat/ca/ca-cert.pem
cmd:cp -rf /tmp/backup/ca-key.pem /etc/xcat/ca/private/ca-key.pem
cmd:cp -rf /tmp/backup/server-cred.pem /etc/xcat/cert/server-cred.pem
cmd:cp -rf /tmp/backup/client-key.pem /root/.xcat/client-key.pem
cmd:rm -rf /tmp/backup
cmd:dir="/tmp/credential";if [ -e "${dir}" ];then mv ${dir}".bak" ${dir}; fi;
cmd:dir="/tmp/backup";if [ -e "${dir}" ];then mv ${dir}".bak" ${dir}; fi;
end
