RC=11 is shown during run staf process command service. But the command is not executed correctly. I used staf 3.4.6
here is the explanation of error rc 11:
Description: Process already complete
Details : You are trying to stop a specific process that has either already b
een stopped or has finished execution on its own.
However, my process is not stopped. The two machine where installed staf and stax can ping each other. Thanks in advance!
error screenshot
There are different process stop methods supported by STAF. Not all stop methods can stop a process (it depends on the kind of command that the process is running).
RC 11 (Process already complete) from a PROCESS STOP request indicates that STAF thnks the process has already completed. That is a PROCESS LIST request no longer shows the process as currently running.
What operating system is the process running on?
Which process stop method was used to stop the process? Note that you can specify a USING "<stop method>" option on a PROCESS STOP request to override the default process stop method. Or you can override the stop method when starting a process.
What is the output from the following which shows the default process stop using method?
STAF <processMachine> PROCESS LIST SETTINGS
See section "8.12.3 STOP" in the STAF User's Guide at http://staf.sourceforge.net/current/STAFUG.htm#HDRPSSTOP which describes the various process stop methods.
The process is running on windows xp sp3 platform.
Actually, the automation script was okay in 1 month ago. Because I just move to new office, so I change the ip address for those machines for running staf work. Then I met the rc=11 error.
Now the root cause is list process command not working correctly due to rc=11. I need to use list process to list all running vms then I'll use stop process to stop all running vms. However, the list process is running failed, so no running vms is stopped...
But the list process and stop process are okay if I ran them by manual
Here are my code snippet for those part.
<function name="stopVM" scope="local">
<function-prolog>Stops the vm </function-prolog>
<function-map-args>
<function-required-arg name="machine"> The name of machine where the test process should
run. </function-required-arg>
<function-required-arg name="vmPath"> The full path to the vmware image
</function-required-arg>
</function-map-args>
<sequence>
<log>'%s-stopVM: %s' % (machine, vmPath)</log>
<process name="'stop'">
<location>machine</location>
<command>'C:\\Program Files\\VMware\\VMware VIX\\vmrun.exe'</command>
<parms>'stop "%s" ' % (vmPath)</parms>
</process>
</sequence>
</function>
<function name="stopAllVMs" scope="local">
<function-prolog>Stops all the vms on the machine</function-prolog>
<function-map-args>
<function-required-arg name="machine"> The name of machine where the test process should
run. </function-required-arg>
</function-map-args>
<sequence>
<log>'%s-stopAllVMs:' %(machine)</log>
<process name="'list'">
<location>machine</location>
<command>'C:\\Program Files\\VMware\\VMware VIX\\vmrun.exe'</command>
<parms>'list wait 10s'</parms>
<returnstdout/>
</process>
<if expr="RC != 0">
<sequence>
<log>'%s-Could not list vmwares' % machine</log>
<return/>
</sequence>
</if>
<iterate var="result" in="STAXResult">
<sequence>
<if expr="result[0] == 0">
<sequence>
<script>
import re
array = re.split('\r\n', result[1])
</script>
<iterate var="vmp" in="array">
<if expr="vmp and vmp != array[0]">
<call function="'stopVM'">
{ 'machine' : machine,
'vmPath' : vmp
}
</call>
</if>
</iterate>
</sequence>
</if>
</sequence>
</iterate>
</sequence>
</function>
Here is the output for command "staf machine process list settings"
C:\Documents and Settings\qatest>staf crystal process list settings
Response
--------
Default Stop Using Method : SigKillAll
Default Console Mode : New
Default Focus : Background
Process Auth Mode : Disabled
Default Auth Username : <None>
Default Auth Password : <None>
Default Auth Disabled Action: Ignore
Default Shell : <None>
Default New Console Shell : <None>
Default Same Console Shell : <None>
The STAX code snippets you provided do not submit a STAF PROCESS LIST or PROCESS STOP request so I don't understand why you think these commands are not working correctly. Instead, the STAX code snippets you provided run a command called vmrun.exe passing it stop or list parameters.
Sorry, I mixed up STAF PROCESS LIST/STOP and command in my STAX code snippets.
Moreover, I can run vmrun.exe command by manual, please check my new attachment.
However, I met rc=11 during run my script by staf tool. So what's the root cause ?
vmrun result
I'm sorry but you have not yet shown me your code where you are submitting a PROCESS STOP request that you're saying is returning RC 11 so I can see if you're doing something wrong.
What version of STAX are you using?
STAF local STAX VERSION
The STAX version is 3.5.0
Sorry for my misunderstanding. Please ignore PROCESS STOP etc.
Now, the rc=11 error is shown during run PROCESS action of STAX. The PROCESS action is list process in my STAX code as belows.
The vmrun.exe command is executed right away after running stafcmd "Delaying for 30 seconds". Then the list process is run again.
So the rc=11 error happened but it's very strange. why are vmrun.exe command run twice?
<sequence>
<log>'%s-stopAllVMs:' %(machine)</log>
<stafcmd name="'Delaying for 30 seconds'">
<location>machine</location>
<service>'delay'</service>
<request>'delay 30000'</request>
</stafcmd>
<process name="'list'">
<location>machine</location>
<command>'C:\\Program Files\\VMware\\VMware VIX\\vmrun.exe'</command>
<parms>'list wait 10s</parms>
<returnstdout/>
</process>
<if expr="RC != 0">
<sequence>
<log>'%s-Could not list vmwares' % machine</log>
<return/>
</sequence>
</if>
<iterate var="result" in="STAXResult">
<sequence>
<if expr="result[0] == 0">
<sequence>
<log>'result first element equals 0'</log>
<script>
import re
array = re.split('\r\n', result[1])
</script>
<iterate var="vmp" in="array">
<if expr="vmp and vmp != array[0]">
<call function="'stopVM'">
{ 'machine' : machine,
'vmPath' : vmp
}
</call>
</if>
</iterate>
</sequence>
</if>
</sequence>
</iterate>
</sequence>
So, you're seeing "Error submitting request, RC:11" in a command prompt when the <process> element that runs command 'C:\\Program Files\\VMware\\VMware
VIX\\vmrun.exe list wait 10s' is run? You should add <stderr mode="'stdout'"/> to the <process> element so that any errors logged by vmrun.exe in stderr are also returned. For example:
<process name="'list'">
<location>machine</location>
<command>'C:\\Program Files\\VMware\\VMwareVIX\\vmrun.exe'</command>
<parms>'list wait 10s</parms>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
What is the RC after the <process> is run? If it isn't 0, you should log the RC and the error message by changing:
<if expr="RC != 0">
<sequence>
<log>'%s-Could not list vmwares' % machine</log>
<return/>
</sequence>
</if>
to:
<if expr="RC != 0">
<sequence>
<log>
'%s-Could not list vmwares, RC=%s STAFResult=%s STAXResult=%s' % \
(machine, RC, STAFResult, STAXResult)
</log>
<return/>
</sequence>
</if>
And if RC != 0 provide me with what error message is logged in the STAX Job User Log by this <log> element.
Yes.
I've changed my code as per your suggestion. However, I did not get more information.
I've attached two screenshots. Please check them.
In the "finish_delay_30s.jpg" screenshot, the vmrun.exe is executed right away in a command prompt window after "Delaying for 30 seconds" stafcmd is finished.
In the "finish_list_process.jpg" screenshot, the rc=11 error is shown in a command prompt when the <process> element that runs command 'C:\\Program Files\\VMware\\VMware VIX\\vmrun.exe list wait 10s' is finished.
But It seems the staf tool broke out the stopAllvms function with the RC=11 error after the <process> element that runs command 'C:\\Program Files\\VMware\\VMware VIX\\vmrun.exe list wait 10s' is finished. So I did not get output of STAResult and STAXResult. Also, you should see "<log>'after list process'</log>" after <process> element in my code in red color in the screenshot. It's not printed. So the following judging RC code will not be run.
finish delay 30s
finish list process