start:xcatd_start
description:stop then start xcatd daemon, and check all the 6 processes are running
label:mn_only,xcatd
cmd:if [ -d "/tmp/xcatd_start" ]; then mv /tmp/xcatd_start /tmp/xcatd_start.org; fi; mkdir -p /tmp/xcatd_start
check:rc==0
cmd:service xcatd status
check:rc==0
check:output=~xcatd service|xcatd.service
check:output=~Active: active \(running\)|xcatd service is running
cmd:ps axjf |grep -v grep |grep "xcatd:" | tee /tmp/xcatd_start/original_xcatd_processes_status
check:rc==0
cmd:cat /tmp/xcatd_start/original_xcatd_processes_status |wc -l
check:output=~6
cmd:service xcatd stop
check:rc==0
cmd:sleep 3
cmd:ps axjf |grep -v grep |grep "xcatd:" | tee /tmp/xcatd_start/after_stop_xcatd_processes_status
check:rc==0
cmd:cat /tmp/xcatd_start/after_stop_xcatd_processes_status|wc -l
check:output=~0
cmd:service xcatd start
check:rc==0
cmd:sleep 3
cmd:service xcatd status
check:rc==0
check:output=~xcatd service|xcatd.service
check:output=~Active: active \(running\)|xcatd service is running
cmd:ps axjf |grep -v grep |grep "xcatd:" | tee /tmp/xcatd_start/after_start_xcatd_processes_status
check:rc==0
cmd:cat  /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~6
cmd:grep "xcatd: SSL listener" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd:grep "xcatd: DB Access" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd:grep "xcatd: UDP listener" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd:grep "xcatd: Discovery worker" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd:grep "xcatd: install monitor" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd:grep "xcatd: Command log writer" /tmp/xcatd_start/after_start_xcatd_processes_status|wc -l
check:output=~1
cmd: rm -rf /tmp/xcatd_start; if [ -d "/tmp/xcatd_start.org" ]; then mv /tmp/xcatd_start.org /tmp/xcatd_start; fi
check:rc==0
end


start:xcatd_stop
description:stop xcatd daemon, then check all the 6 processes are stopped
label:mn_only,xcatd
cmd:service xcatd status
check:rc==0
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
cmd:service xcatd stop
check:rc==0
cmd:sleep 3
cmd:ps axjf |grep -v grep |grep "xcatd:" | wc -l
check:rc==0
check:output=~0
cmd:service xcatd status
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is not running|inactive \(dead\)
cmd:ps -ef | grep xcatd
check:output!~"xcatd: SSL listener"
check:output!~"xcatd: DB Access"
check:output!~"xcatd: UDP listener"
check:output!~"xcatd: install monitor"
check:output!~"xcatd: Discovery worke"
check:output!~"xcatd: Command log writer"
cmd:service xcatd start
check:rc==0
end


start:xcatd_restart
description:restart xcatd daemon
label:mn_only,xcatd
cmd:service xcatd status
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
check:rc==0
cmd:service xcatd restart
check:rc==0
cmd:sleep 10
cmd:service xcatd status
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
check:rc==0
end



start:run_command_with_XCATBYPASS
description:with XCATBYPASS=YES, the command works either xcatd deamon running or not
label:mn_only,xcatd
cmd:service xcatd status
check:rc==0
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
cmd:XCATBYPASS=YES tabdump site
check:rc==0
cmd:service xcatd stop
check:rc==0
cmd:sleep 3
cmd:service xcatd status
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is not running|inactive \(dead\)
cmd:tabdump site
check:rc!=0
cmd:XCATBYPASS=YES tabdump site
check:rc==0
cmd:service xcatd start
check:rc==0
cmd:service xcatd status
check:rc==0
check:output=~xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
end

start:disable_root_permission_in_policy_table
description:disable root permission, only with XCATBYPASS=YES, the command works
label:mn_only,xcatd
cmd:service xcatd status
check:rc==0
check:output=~ xcatd service|xcatd.service
check:output=~xcatd service is running|active \(running\)
cmd:chtab name=root policy.rule=disable
check:rc==0
cmd:lsdef
check:output=~Error: (\[.*?\]: )?Permission denied for request
cmd:XCATBYPASS=YES lsdef
check:rc==0
cmd:XCATBYPASS=YES chtab name=root policy.rule=allow
check:rc==0
cmd:lsdef
check:rc==0
end


start:assign_certain_command_permission
description:assign root permission to certain command, only this command works
label:mn_only,xcatd
cmd:service xcatd status
check:rc==0
check:output=~ xcatd service |xcatd.service
check:output=~xcatd service is running|active \(running\)
cmd:lsdef
check:rc==0
cmd:tabdump policy
check:rc==0
cmd:chtab name=root policy.commands=lsdef policy.rule=allow
check:rc==0
cmd:lsdef
check:rc==0
cmd:tabdump policy
check:output=~Error: (\[.*?\]: )?Permission denied for request
cmd:chtab name=root policy.commands= policy.rule=allow
check:rc==0
end


