Hi,
I am new to STAFF.
Attached is the code copied from FAQ link
http://staf.sourceforge.net/current/STAFFAQ.htm.
In the xml code, the snapshot(image) is called "SilkTest and STAF", but the
code didn't start the right snapshot. It always start the latest snapshot.
Can you help me to solve this?
Thanks,
Cindy
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "D:\DistributionTesting\STAF\stax.dtd">
<stax>
<defaultcall function="main"/>
<function name="main" scope="local">
<parallel>
<block name="'Boot up VMWare image'">
<call function="'startvmware'">
{ 'image': 'E:/vmw1693-w72/vmw1693-w72.vmx',
'timeout' : '15m', 'imagehostname' : '10.0.7.196',
'imagename' : 'SilkTest and STAF'
}
</call>
</block>
<block name="'Release this block to shutdown the VMWare image'">
<sequence>
<hold/>
<call function="'stopvmware'">
{ 'imagehostname' : '10.0.7.196', 'shutdown' : 'shutdown -s -f -t 0' }
</call>
</sequence>
</block>
</parallel>
</function>
<function name="startvmware" scope="local">
<function-prolog>
Starts a VMWare image, and attempts to do a STAF PING to the VMWare image.
Your VMWare image needs to be configured so that there are no popups
displayed when the VMWare image starts (for example, messages about Disk
Drive warnings, etc), and that the image is set up to automatically log
in. Also, the machine must be configured to start STAF automatically.
Also, you must have the following 2 lines in your VMWare image's .vmx file:
gui.exitOnCLIHLT = "TRUE"
gui.exitAtPowerOff = "TRUE"
Note that you should avoid terminating any blocks that are running a VMWare
image, as that will kill the VMWare image without it being shutdown. Instead,
you should manually shutdown and power off the VMWare image, or call the
"terminatevmware" [not yet implemented] function.
You should use Bridged network connections for VMWare images to work
correctly with this function.
</function-prolog>
<function-map-args>
<function-optional-arg name="machine" default="'local'">
The machine on which the VMWare image is to be started. The default is 'local'.
</function-optional-arg>
<function-optional-arg name="vmwarebin" default="'c:/Program Files (x86)/Vmware/VMware Workstation/vmware.exe'">
The VMWare executable file. If the VMWare executable is not in the
VMWare system's PATH, then the file must be fully qualified.
The default is 'c:/Program Files/Vmware/VMware Workstation/vmware.exe'.
</function-optional-arg>
<function-required-arg name="image">
The fully qualified VMWare .vmx file for the VMWare image. Note that
the VMWare executable does not permit spaces in the file name of the
vmx file.
</function-required-arg>
<function-required-arg name="imagehostname">
The hostname for the VMWare image.
</function-required-arg>
<function-optional-arg name="timeout" default="'10m'">
The timeout value for when the function should stop attempting to
STAF PING the VMWare image. The default is 10 minutes. The STAF PING
to the VMWare image will be attempted every 30 seconds, up to the
timeout value.
</function-optional-arg>
<function-optional-arg name="imagename" default='image'>
The name of the VMWare image. The default is the argument specified
for image.
</function-optional-arg>
</function-map-args>
<parallel>
<process name="'VMWare Image %s ' % imagename">
<location>machine</location>
<command>vmwarebin</command>
<parms>'-x -q %s' % image</parms> <!-- -x powers on automatically, -q exits at power off -->
<stdout>'out.txt'</stdout>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<sequence>
<script>contacted = 0</script>
<timer duration='timeout'>
<loop while="contacted == 0">
<sequence>
<stafcmd name="'Delaying for 30 seconds'">
<location>'local'</location>
<service>'delay'</service>
<request>'delay 30000'</request>
</stafcmd>
<stafcmd name = "'Attempt to ping %s' % imagehostname">
<location>imagehostname</location>
<service>'ping'</service>
<request>'ping'</request>
</stafcmd>
<if expr="RC == 0">
<sequence>
<script>contacted = 1</script>
<message>'Machine %s is up and running with VMWare image %s' % (imagehostname, imagename)</message>
<log>'Machine %s is up and running with VMWare image %s' % (imagehostname, imagename)</log>
</sequence>
</if>
</sequence>
</loop>
</timer>
<if expr="RC != 0">
<sequence>
<message>'Machine %s with VMWare image %s was not successfully started RC: %s' % (imagehostname, imagename, RC)</message>
<log>'Machine %s with VMWare image %s was not successfully started RC: %s' % (imagehostname, imagename, RC)</log>
</sequence>
</if>
</sequence>
</parallel>
</function>
<function name="stopvmware" scope="local">
<function-prolog>
Stops a VMWare image
</function-prolog>
<function-map-args>
<function-required-arg name="imagehostname">
The hostname for the VMWare image.
</function-required-arg>
<function-required-arg name="shutdown">
The command used to shut down the OS.
</function-required-arg>
</function-map-args>
<sequence>
<script>
from com.ibm.staf import STAFUtil
</script>
<stafcmd>
<location>imagehostname</location>
<service>'process'</service>
<request>'start async shell command %s' % STAFUtil.wrapData(shutdown)</request>
</stafcmd>
</sequence>
</function>
</stax>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users