diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 113: Merge fix for bug 827727, support both xml-rpc and RPC2 endpoints now.

Message ID 20110916025613.15617.41192.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Spring Zhang Sept. 16, 2011, 2:56 a.m. UTC
Merge authors:
  Spring Zhang (qzhang)
Related merge proposals:
  https://code.launchpad.net/~qzhang/lava-dispatcher/fix-827727/+merge/74351
  proposed by: Spring Zhang (qzhang)
  review: Approve - Spring Zhang (qzhang)
  review: Approve - Michael Hudson-Doyle (mwhudson)
  review: Needs Fixing - Paul Larson (pwlars)
------------------------------------------------------------
revno: 113 [merge]
committer: Spring Zhang <spring.zhang@linaro.org>
branch nick: fix-827727
timestamp: Fri 2011-09-16 10:51:47 +0800
message:
  Merge fix for bug 827727, support both xml-rpc and RPC2 endpoints now.
  Bug #827727: dispatcher only works with dashboard endpoint
modified:
  doc/android-0xbench-job.json
  doc/android-basic-job.json
  doc/android-monkey-job.json
  doc/lava-ltp-job.json
  doc/lava-new-kernel.json
  doc/lava-out-of-tree-test-1.json
  doc/lava-out-of-tree-test-2.json
  lava_dispatcher/actions/launch_control.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'doc/android-0xbench-job.json'
--- doc/android-0xbench-job.json	2011-06-02 20:00:26 +0000
+++ doc/android-0xbench-job.json	2011-09-13 09:15:07 +0000
@@ -28,7 +28,7 @@ 
       "command": "submit_results",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/android-panda01-0xbench/",
           "result_disk": "sdcard"
         }

=== modified file 'doc/android-basic-job.json'
--- doc/android-basic-job.json	2011-06-02 20:00:26 +0000
+++ doc/android-basic-job.json	2011-09-13 09:15:07 +0000
@@ -28,7 +28,7 @@ 
       "command": "submit_results_on_host",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/android-panda01-basic/"
         }
     }

=== modified file 'doc/android-monkey-job.json'
--- doc/android-monkey-job.json	2011-06-02 20:00:26 +0000
+++ doc/android-monkey-job.json	2011-09-13 09:15:07 +0000
@@ -28,7 +28,7 @@ 
       "command": "submit_results_on_host",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/android-panda01-monkey/"
         }
     }

=== modified file 'doc/lava-ltp-job.json'
--- doc/lava-ltp-job.json	2011-09-14 04:18:40 +0000
+++ doc/lava-ltp-job.json	2011-09-16 02:51:47 +0000
@@ -32,7 +32,7 @@ 
       "command": "submit_results",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/panda01-ltp/"
         }
     }

=== modified file 'doc/lava-new-kernel.json'
--- doc/lava-new-kernel.json	2011-08-18 10:40:22 +0000
+++ doc/lava-new-kernel.json	2011-09-16 02:51:47 +0000
@@ -22,7 +22,7 @@ 
       "command": "submit_results",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/testresult/"
         }
     }

=== modified file 'doc/lava-out-of-tree-test-1.json'
--- doc/lava-out-of-tree-test-1.json	2011-08-19 01:32:22 +0000
+++ doc/lava-out-of-tree-test-1.json	2011-09-13 09:15:07 +0000
@@ -40,7 +40,7 @@ 
       "command": "submit_results",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/RPC2/",
           "stream": "/anonymous/panda01-tesing/"
         }
     }

=== modified file 'doc/lava-out-of-tree-test-2.json'
--- doc/lava-out-of-tree-test-2.json	2011-08-18 20:38:38 +0000
+++ doc/lava-out-of-tree-test-2.json	2011-09-13 09:15:07 +0000
@@ -33,7 +33,7 @@ 
       "command": "submit_results",
       "parameters":
         {
-          "server": "http://validation.linaro.org/launch-control",
+          "server": "http://validation.linaro.org/lava-server/dashboard/xml-rpc/",
           "stream": "/anonymous/panda01-testing/"
         }
     }

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-09-10 03:02:04 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-09-16 02:47:34 +0000
@@ -17,8 +17,7 @@ 
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along
-# with this program; if not, see <http://www.gnu.org/licenses>.
+# along with this program; if not, see <http://www.gnu.org/licenses>.
 
 import json
 import os
@@ -34,10 +33,8 @@ 
 
 class cmd_submit_results_on_host(BaseAction):
     def run(self, server, stream):
-        xmlrpc_url = "%s/xml-rpc/" % server
-        srv = xmlrpclib.ServerProxy(xmlrpc_url,
-                allow_none=True, use_datetime=True)
-
+        dashboard = _get_dashboard(server)
+ 
         #Upload bundle files to dashboard
         bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)
         for bundle_name in bundle_list:
@@ -47,7 +44,7 @@ 
             f.close()
             try:
                 print >> self.context.oob_file, 'dashboard-put-result:', \
-                      srv.put_ex(content, bundle, stream)
+                      dashboard.put_ex(content, bundle, stream)
             except xmlrpclib.Fault, err:
                 print "xmlrpclib.Fault occurred"
                 print "Fault code: %d" % err.faultCode
@@ -61,14 +58,12 @@ 
     all_bundles = []
 
     def run(self, server, stream, result_disk="testrootfs"):
-        """Submit test results to a launch-control server
-        :param server: URL of the launch-control server
-        :param stream: Stream on the launch-control server to save the result to
+        """Submit test results to a lava-dashboard server
+        :param server: URL of the lava-dashboard server RPC endpoint
+        :param stream: Stream on the lava-dashboard server to save the result to
         """
-        #Create l-c server connection
-        xmlrpc_url = "%s/xml-rpc/" % server
-        srv = xmlrpclib.ServerProxy(xmlrpc_url,
-                allow_none=True, use_datetime=True)
+        #Create l-d server connection
+        dashboard = _get_dashboard(server)
 
         client = self.client
         try:
@@ -156,7 +151,7 @@ 
             test_run['attributes'] = attributes
         json_bundle = json.dumps(main_bundle)
         print >> self.context.oob_file, 'dashboard-put-result:', \
-              srv.put_ex(json_bundle, 'lava-dispatcher.bundle', stream)
+              dashboard.put_ex(json_bundle, 'lava-dispatcher.bundle', stream)
 
         if status == 'fail':
             raise OperationFailed(err_msg)
@@ -173,3 +168,26 @@ 
             test_runs += bundle['test_runs']
         return main_bundle
 
+#util function, see if it needs to be part of utils.py
+def _get_dashboard(server):
+    if not server.endswith("/"):
+        server = ''.join([server, "/"])
+    #add backward compatible for 'dashboard/'-end URL
+    #Fix it: it's going to be deleted after transition
+    if server.endswith("dashboard/"):
+        server = ''.join([server, "xml-rpc/"])
+        print "WARNING: Please use whole endpoint URL not just end with 'dashboard/', 'xml-rpc/' is added automatically now!!!"
+
+    srv = xmlrpclib.ServerProxy(server, allow_none=True, use_datetime=True)
+    if server.endswith("xml-rpc/"):
+        print "WARNING: Please use RPC2 endpoint instead, xml-rpc is deprecated!!!"
+        dashboard = srv
+    elif server.endswith("RPC2/"):
+        #include lava-server/RPC2/
+        dashboard = srv.dashboard
+    else:
+        print "WARNING: The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!"
+        dashboard = srv.dashboard
+    print "  server RPC endpoint URL: %s" %server
+    return dashboard
+