1372N/A<?
xml version="1.0" encoding="UTF-8" standalone="no"?>
1372N/A ! The contents of this file are subject to the terms of the 1372N/A ! Common Development and Distribution License, Version 1.0 only 1372N/A ! (the "License"). You may not use this file except in compliance 1372N/A ! You can obtain a copy of the license at 1372N/A ! See the License for the specific language governing permissions 1372N/A ! and limitations under the License. 1372N/A ! When distributing Covered Code, include this CDDL HEADER in each 1372N/A ! file and include the License file at 1372N/A ! add the following below this CDDL HEADER, with the fields enclosed 1372N/A ! by brackets "[]" replaced with your own identifying information: 1372N/A ! Portions Copyright [yyyy] [name of copyright owner] 3215N/A ! Copyright 2007-2009 Sun Microsystems, Inc. 1372N/A ! Portions Copyright 2011-2012 ForgeRock AS. 1372N/A <
function name="copyFile" scope="local">
1372N/A This function copies a source file to destination file to host
1372N/A <
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
1372N/A </
function-
arg-
description>
1372N/A <
function-
arg-
property name="type" value="hostname"/>
2175N/A <
function-
arg-
def name="remotehost" type="optional" default="STAXServiceMachine">
2175N/A The name of remote host (default localhost)
2175N/A </
function-
arg-
description>
1372N/A <
function-
arg-
property name="type" value="hostname"/>
1372N/A <
function-
arg-
def name="srcfile" type="required">
2175N/A The name of the source file
2175N/A </
function-
arg-
description>
2175N/A <
function-
arg-
property name="type" value="filename"/>
2175N/A <
function-
arg-
def name="destfile" type="required">
1372N/A The name of the destination file
1372N/A </
function-
arg-
description>
1547N/A <
function-
arg-
property name="type" value="filename"/>
2175N/A 'Copy file %s:%s to %s:%s.' \
2175N/A % (myLocation,srcfile,remotehost,destfile)
1372N/A 'Checking for parent folder %s on host %s.' % (destfolder,remotehost)
1372N/A <
call function="'createFolder'">
1372N/A 'foldername' : '%s' % destfolder
4153N/A <
stafcmd name="'STAF Command: Copy File'">
1372N/A <
location>'%s' % myLocation</
location>
1372N/A 'COPY FILE %s TOFILE %s TOMACHINE %s' % (srcfile,destfile,remotehost)
1372N/A <
call function="'checkRC'">
1372N/A <
return>[cmdRC,cmdResult]</
return>
<
function name="CopyFolderByExtension">
Copies files by extension from a source to destination folder on host
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="remotehost" type="optional" default="location">
<
function-
arg-
description>
The name of remote host (default same as location)
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="srcfolder" type="required">
<
function-
arg-
description>
The name of the source folder
</
function-
arg-
description>
<
function-
arg-
property name="type" value="foldername"/>
<
function-
arg-
def name="destfolder" type="required">
<
function-
arg-
description>
The name of the destination file
</
function-
arg-
description>
<
function-
arg-
property name="type" value="foldername"/>
<
function-
arg-
def name="extension" type="optional" default="'txt'">
<
function-
arg-
description>
The name of the file extension (default txt)
</
function-
arg-
description>
<
function-
arg-
property name="type" value="file extension"/>
'Copy all %s Files from %s:%s to %s:%s.' \
% (extension,location,srcfolder,remotehost,destfolder)
<
stafcmd name="'STAF Command: Copy all %s Files.' % (extension)">
<
location>'%s' % location</
location>
'COPY DIRECTORY %s TODIRECTORY %s TOMACHINE %s EXT %s RECURSE' \
% (srcfolder,destfolder,remotehost,extension)
<
call function="'checkRC'">
<
function name="copyFolder">
Copies folder from a source to destination folder on host
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="remotehost" type="optional" default="location">
<
function-
arg-
description>
The name of remote host (default same as location)
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="srcfolder" type="required">
<
function-
arg-
description>
The name of the source folder
</
function-
arg-
description>
<
function-
arg-
property name="type" value="foldername"/>
<
function-
arg-
def name="destfolder" type="required">
<
function-
arg-
description>
The name of the destination file
</
function-
arg-
description>
<
function-
arg-
property name="type" value="foldername"/>
'Copy folder %s:%s to %s:%s.' \
% (location,srcfolder,remotehost,destfolder)
<
stafcmd name="'STAF Command: Copy %s folder to %s.' % (srcfolder,destfolder)">
<
location>'%s' % location</
location>
<
request>'COPY DIRECTORY %s TODIRECTORY %s TOMACHINE %s RECURSE' % (srcfolder,destfolder,remotehost) </
request>
<
call function="'checkRC'">
<
function name="zipUpFile">
This function zips up a folder
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="zipfile" type="required">
<
function-
arg-
description>
Name of the file to place zip file contents
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
function-
arg-
def name="folder" type="required">
<
function-
arg-
description>
Name of destination folder to place zip file contents
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="relativeto" type="required">
<
function-
arg-
description>
Folder that the zip archive is relative to
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
stafcmd name="'STAF Command: Zip Up Folder'">
<
location>'%s' % location</
location>
'ADD ZIPFILE %s DIRECTORY %s RECURSE RELATIVETO %s' % (zipfile,folder,relativeto)
<
call function="'checkRC'">
<
function name="unZipFile">
This function unzips a compressed zip archive
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="zipfile" type="required">
<
function-
arg-
description>
Name of the file to place zip file contents
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
function-
arg-
def name="file" type="optional" default="None">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="directory" type="optional" default="None">
<
function-
arg-
description>
Name of directory to unzip
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="unzipdir" type="required">
<
function-
arg-
description>
Name of destination folder to place zip file contents
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
dir='DIRECTORY %s' % directory
<
stafcmd name="'STAF Command: Unzip File'">
<
location>'%s' % location</
location>
'UNZIP ZIPFILE %s TODIRECTORY %s %s %s RESTOREPERMISSION REPLACE' % (zipfile,unzipdir,file,dir)
<
call function="'checkRC'">
<
function name="deleteFile">
This function deletes a file
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="filename" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
stafcmd name="'STAF Command: Delete Existing File'">
<
location>'%s' % location</
location>
'GET ENTRY %s TYPE' % (filename)
'Success: File does not exist, dont delete it.'
'Success: File does exists, will delete it'
<
stafcmd name="'STAF Command: Delete Existing File'">
<
location>'%s' % location</
location>
'DELETE ENTRY %s CONFIRM' % filename
<
call function="'checkRC'">
<
function name="deleteFolder">
This function recursively deletes a folder
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="foldername" type="required">
<
function-
arg-
description>
Name of folder to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
stafcmd name="'STAF Command: Get Folder Attributes'">
<
location>'%s' % location</
location>
<
request>'GET ENTRY %s TYPE' % foldername</
request>
'Folder %s does not exist, do not delete it.' % foldername
'Folder %s exists, will delete it and all contents.' % foldername
<
stafcmd name="'STAF Command: Recursively Delete Folder'">
<
location>'%s' % location</
location>
'DELETE ENTRY %s RECURSE IGNOREERRORS CONFIRM' % (foldername)
<
call function="'checkRC'">
<
function name="createFolder">
This function creates a folder
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="foldername" type="required">
<
function-
arg-
description>
Name of folder to be created
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
'Creating folder %s on %s' % (foldername,location)
<
stafcmd name="'STAF Command: Create Folder'">
<
location>'%s' % location</
location>
'CREATE DIRECTORY %s FULLPATH' % foldername
<
call function="'checkRC'">
<
function name="createMultiFolders" scope="local">
This function creates multiple folders
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="folderslist" type="required">
<
function-
arg-
description>
Name of folder to be created
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
iterate var="folderToCreate" in="folderslist">
<
message>'Check if folder exists already.'</
message>
<
call function="'GetEntry'">
'entry' : folderToCreate,
'Folder %s does not exists, create folder' % folderToCreate
<
call function="'createFolder'">
'foldername' : folderToCreate
<
function name="queryLogs">
Queries the staf logs from startfrom point
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="logname" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="startfrom" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="timestamp"/>
<
function-
arg-
def name="endat" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="timestamp"/>
<
block name="'Query Logs'">
<
stafcmd name="'STAF Command: Log Query for Test Case Log.'">
<
location>'%s' % location</
location>
<
request>'QUERY ALL MACHINE %s LOGNAME %s FROM %s TO %s' % (location,logname,startfrom,endat)</
request>
Sets a variable in the staf var service
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="type" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
function-
arg-
def name="variable" type="required">
<
function-
arg-
description>
Name of file to be deleted
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
message>'Set %s Variable %s' % (type,variable)</
message>
<
stafcmd name="'STAF Command: Set Var.'">
<
location>'%s' % location</
location>
<
request>'SET %s VAR %s' % (type,variable)</
request>
Gets a variable in the staf var service
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="type" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
function-
arg-
def name="variable" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
message>'Get %s Variable %s' % (type,variable)</
message>
<
stafcmd name="'STAF Command: Get Var.'">
<
location>'%s' % location</
location>
<
request>'GET %s VAR %s' % (type,variable)</
request>
<
function name="ResolveVar">
Resolve a variable in the staf var service
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="type" type="required">
<
function-
arg-
description>
Type of string to be resolved
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
function-
arg-
def name="name" type="required">
<
function-
arg-
description>
Name of string to be resolved
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
message>'Resolve %s Variable %s' % (type, name)</
message>
<
stafcmd name="'STAF Command: Resolve Var.'">
<
location>'%s' % location</
location>
<
request>'RESOLVE %s {%s}' % (type, name)</
request>
<
function name="GetEntry">
Retrieves an attribute of a file system entry
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="entry" type="required">
<
function-
arg-
description>
Name of entry to retrieve attributes
</
function-
arg-
description>
<
function-
arg-
property name="type" value="variable"/>
<
function-
arg-
def name="attribute" type="required">
<
function-
arg-
description>
Type of attributes to be retrieved
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
message>'Retrieve attribute %s for %s.' % (attribute,entry)</
message>
<
stafcmd name="'STAF Command: Get Entries Attributes'">
<
location>'%s' % location</
location>
<
request>'GET ENTRY %s %s' % (entry,attribute)</
request>
<
return>[cmdRC,cmdResult]</
return>
<
function name="listFolder">
This function lists a folder
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="foldername" type="required">
<
function-
arg-
description>
Name of folder to be list
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="filename" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
stafcmd name="'STAF Command: list Folder Attributes'">
<
location>'%s' % location</
location>
<
request>' LIST DIRECTORY %s NAME %s LONG ' % (foldername,filename)</
request>
<
call function="'checkRC'">
<!-- List a folder by extension --> <
function name="listFolderByExtension" scope="local">
This function lists a folder by extension
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="foldername" type="required">
<
function-
arg-
description>
Name of folder to be list
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filepath"/>
<
function-
arg-
def name="extension" type="required">
<
function-
arg-
description>
he name of the file extension (default txt)
</
function-
arg-
description>
<
function-
arg-
property name="type" value="file extension"/>
<
stafcmd name="'STAF Command: list folder by extension'">
<
location>'%s' % location</
location>
<
request>' LIST DIRECTORY %s EXT %s RECURSE' % (foldername,extension)</
request>
cmdResult = 'Folder does not exist.'
<
call function="'checkRC'">
<
return>cmdResult</
return>
<
function name="getFile">
This function get the contents of a file
<
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="filename" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="filename"/>
<
function-
arg-
def name="type" type="optional" default="'text'">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="format" type="optional" default="'native'">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
stafcmd name="'STAF Command: Get File'">
<
location>'%s' % location</
location>
'GET FILE %s %s FORMAT %s' % (filename,type,format)
<
return>[cmdRC,cmdResult]</
return>
<
function name="SendEvent" scope="local">
<
function-
arg-
def name="location" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="name" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
message>'Send Event %s on %s' % (name, location)</
message>
<
stafcmd name="'STAF Command: Send Event.'">
<
location>'%s' % location</
location>
<
request>'PULSE EVENT %s' % name</
request>
<
function name="WaitEvent" scope="local">
<
function-
arg-
def name="location" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="name" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
message>'Wait Event %s on %s' % (name, location)</
message>
<
stafcmd name="'STAF Command: Wait Event.'">
<
location>'%s' % location</
location>
<
request>'WAIT EVENT %s' % name</
request>
<
function name="DeleteEvent" scope="local">
<
function-
arg-
def name="location" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="name" type="required">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
message>'Delete Event %s on %s' % (name, location)</
message>
<
stafcmd name="'STAF Command: Delete Event.'">
<
location>'%s' % location</
location>
<
request>'DELETE EVENT %s' % name</
request>
<!-- Add STAF Java Service --> <
function name="addSTAFJavaService" scope="local">
<
function-
arg-
def name="location" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="serviceName" type="required">
<
function-
arg-
description>
Name of the service to add
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="serviceJar" type="required">
<
function-
arg-
description>
Jar of the service to add
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
<
function-
arg-
def name="JVM" type="optional" default="True">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="enum"/>
<
function-
arg-
def name="J2" type="optional">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
'Check if STAF Java Service %s is already started on %s' \
% (serviceName, location)
<
stafcmd name="'STAF Command: Check STAF Java Service.'">
<
location>'%s' % location</
location>
<
service>'service'</
service>
<
request>'query service %s' % serviceName</
request>
cmdOptions = 'ADD SERVICE %s LIBRARY JSTAF' % serviceName
cmdOptions += ' EXECUTE %s' % serviceJar
cmdOptions += ' OPTION JVMNAME=%sJVM-%s' % (serviceName,location)
if location == STAXServiceMachine:
cmdOptions += ' OPTION JVM=%
s/
bin/
java' % LOCAL_JAVA_HOME
cmdOptions += ' OPTION JVM=%
s/
bin/
java' % JAVA_HOME
cmdOptions += ' OPTION J2="%s"' % J2
'Add STAF Java Service %s on %s' % (serviceName, location)
<
message>'service %s' % cmdOptions</
message>
<
stafcmd name="'STAF Command: Add STAF Java Service.'">
<
location>'%s' % location</
location>
<
service>'service'</
service>
<
request>'%s' % cmdOptions</
request>
'STAF Java Service %s is already started on %s' \
% (serviceName, location)
<!-- Remove STAF Java Service --> <
function name="removeSTAFJavaService" scope="local">
Remove STAF Java Service.
<
function-
arg-
def name="location" default="STAXServiceMachine">
<
function-
arg-
description>
</
function-
arg-
description>
<
function-
arg-
property name="type" value="hostname"/>
<
function-
arg-
def name="serviceName" type="required">
<
function-
arg-
description>
Name of the service to add
</
function-
arg-
description>
<
function-
arg-
property name="type" value="string"/>
cmdOptions = 'REMOVE SERVICE %s ' % serviceName
'Remove STAF Java Service %s on %s' % (serviceName, location)
<
stafcmd name="'STAF Command: Remove STAF Java Service.'">
<
location>'%s' % location</
location>
<
service>'service'</
service>
<
request>'%s' % cmdOptions</
request>