From 48395aca17f327f4e61ede6ac999c46d0a3528bc Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Tue, 13 Nov 2007 17:01:13 +0000
Subject: [PATCH] add wrapper for STAF commands

---
 opends/tests/shared/functions/utils.xml |   63 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/opends/tests/shared/functions/utils.xml b/opends/tests/shared/functions/utils.xml
index e778fe8..fce3da0 100755
--- a/opends/tests/shared/functions/utils.xml
+++ b/opends/tests/shared/functions/utils.xml
@@ -1538,5 +1538,68 @@
     </sequence>
   </function>
 
+  <function name="runSTAFCommand" >
+    <function-description>
+      A general wrapper to run a STAF command without having to write a 
+      dedicated function for it
+    </function-description>
+    <function-map-args>
+      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+        <function-arg-description>
+          Which machine should the command be executed on
+        </function-arg-description>
+      </function-arg-def>
+      <function-arg-def name="name" type="required">
+        <function-arg-description>
+          The name to give the process
+        </function-arg-description>
+      </function-arg-def>
+      <function-arg-def name="service" type="required">
+        <function-arg-description>
+          the command to run
+        </function-arg-description>
+      </function-arg-def>
+      <function-arg-def name="request" type="required">
+        <function-arg-description>
+          the command to run
+        </function-arg-description>
+      </function-arg-def>
+      <function-arg-def name="arguments" type="optional" default="''">
+        <function-arg-description>
+          the arguments for the service request
+        </function-arg-description>
+      </function-arg-def>      
+    </function-map-args>
+    <sequence>
+      <script>
+        import random
+        import java.util.Date
+        random.seed(java.util.Date().getTime())
+        _id = '%s#%d' % (strftime('%Y-%m-%d %H:%M:%S',localtime()),random.randint(0,99999))
+        
+      </script>
+      <message>
+        '%s: Running STAF command:\n %s %s %s\nlocation: %s\n' % (_id,service,request,arguments,location)
+      </message>
+
+      <block name="'%s:Wrapper for %s' % (_id,name)">
+        <stafcmd name="'STAF Command: %s' % name">
+          <location>'%s' % location</location>
+          <service>service</service>
+          <request>
+            '%s %s' % (request,arguments)
+          </request>
+        </stafcmd>
+      </block>
+      
+      <message level="'info'">
+        '%s: STAF Command returned:\n%s' % (_id,STAFResult)
+      </message>
+
+      <return>
+        STAFResult
+      </return>
+    </sequence>
+  </function>
                         
 </stax>

--
Gitblit v1.10.0