From 90cbe4acd1ccc247bb4afa4938a206b6144bfa28 Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Fri, 11 Apr 2008 09:06:42 +0000
Subject: [PATCH] factorize the code: Get the list of opends instances in the topology with getOpendsInstancesInATopology()

---
 opends/tests/system-tests/phases/configuration/configuration.xml |   33 ++--------------
 opends/tests/system-tests/phases/verdict/verdict_opends.xml      |   11 ++---
 opends/tests/system-tests/phases/parser/object_lib.xml           |   26 ++++++++++++
 3 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/opends/tests/system-tests/phases/configuration/configuration.xml b/opends/tests/system-tests/phases/configuration/configuration.xml
index 64858f5..19aae17 100755
--- a/opends/tests/system-tests/phases/configuration/configuration.xml
+++ b/opends/tests/system-tests/phases/configuration/configuration.xml
@@ -59,36 +59,13 @@
         fileList = STAXGlobal([])
       </script>
       
-      <!-- == Get the list of opends instances in the topology == -->
+      <!--== Get the list of opends instances in the topology == -->
+      <call function="'getOpendsInstancesInATopology'">
+        { 'suffix' : suffix }
+      </call>
       <script>
-        opendsInstances = []
-        msg = ''
-        topoInstances = suffix.getTopology()
-        
-        sys.path.append("%s/phases/parser" % TESTS_DIR )
-        from parser import getRefObjectByName
-        
-        for topoInstance in topoInstances:
-          result = getRefObjectByName(topoInstance.getName(),instances)
-          if result[0] != '':
-            msg = '%s\n%s' % (msg,result[0])
-          currentInstance = result[1]
-          
-          if currentInstance.getProduct() == 'opends':
-            opendsInstances.append(currentInstance)
-          
+        opendsInstances = STAXResult
       </script>
-      <if expr="msg != ''">
-        <sequence>
-          <message>'%s' % msg</message>
-          <call function="'writeMessage'">
-          { 'fileFd'  : LOG_MAIN_FD,
-            'content' : msg
-          }
-          </call>
-          <script>ERR_NUM[0] += 1</script>
-        </sequence>
-      </if>
       
       <!-- == Configure opends == -->
       <call function="'configureOpends'">
diff --git a/opends/tests/system-tests/phases/parser/object_lib.xml b/opends/tests/system-tests/phases/parser/object_lib.xml
index b613efb..fe4f7aa 100644
--- a/opends/tests/system-tests/phases/parser/object_lib.xml
+++ b/opends/tests/system-tests/phases/parser/object_lib.xml
@@ -29,7 +29,31 @@
   <!-- ************************************************************ -->
   <!--                    Libs for instance object                  -->
   <!-- ************************************************************ -->
-  
+  <function name="getOpendsInstancesInATopology" scope="local">
+   <function-prolog>
+      'return the list of opends instances in a topology (using same suffix)'
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="suffix" type="required">
+        <function-arg-description>
+          suffix object
+        </function-arg-description>
+      </function-arg-def>
+    </function-map-args>
+    <sequence>
+      <script>
+        opendsInstances = []
+        topoInstances   = suffix.getTopology()
+        
+        for topoInstance in topoInstances:
+          cInstance = topoInstance.getInstanceRef()
+          if cInstance.getProduct() == 'opends':
+            opendsInstances.append(cInstance)
+      </script>
+      
+      <return>opendsInstances</return>
+    </sequence>
+  </function>
   
   
   
diff --git a/opends/tests/system-tests/phases/verdict/verdict_opends.xml b/opends/tests/system-tests/phases/verdict/verdict_opends.xml
index 6dce9ac..63d4033 100644
--- a/opends/tests/system-tests/phases/verdict/verdict_opends.xml
+++ b/opends/tests/system-tests/phases/verdict/verdict_opends.xml
@@ -57,14 +57,11 @@
     
     <sequence>
       <!--== Get the list of opends instances in the topology == -->
+      <call function="'getOpendsInstancesInATopology'">
+        { 'suffix' : suffix }
+      </call>
       <script>
-        opendsInstances = []
-        topoInstances   = suffix.getTopology()
-        
-        for topoInstance in topoInstances:
-          cInstance = topoInstance.getInstanceRef()
-          if cInstance.getProduct() == 'opends':
-            opendsInstances.append(cInstance)
+        opendsInstances = STAXResult
       </script>
       
       

--
Gitblit v1.10.0