From patchwork Thu Jan 12 23:11:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 6171 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E865023F7F for ; Thu, 12 Jan 2012 23:11:15 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id C28ABA185AB for ; Thu, 12 Jan 2012 23:11:15 +0000 (UTC) Received: by bkbzu5 with SMTP id zu5so2278640bkb.11 for ; Thu, 12 Jan 2012 15:11:15 -0800 (PST) Received: by 10.204.38.80 with SMTP id a16mr1943725bke.99.1326409875480; Thu, 12 Jan 2012 15:11:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs16812bkc; Thu, 12 Jan 2012 15:11:15 -0800 (PST) Received: by 10.216.134.149 with SMTP id s21mr2560109wei.41.1326409873977; Thu, 12 Jan 2012 15:11:13 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fx2si4158563wbb.102.2012.01.12.15.11.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jan 2012 15:11:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RlTnd-0000dy-Nu for ; Thu, 12 Jan 2012 23:11:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id A9087E0990 for ; Thu, 12 Jan 2012 23:11:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 189 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 189: support the inclusion of a auth token in the job file and use it when submitting results Message-Id: <20120112231113.21882.15062.launchpad@ackee.canonical.com> Date: Thu, 12 Jan 2012 23:11:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14664"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: ce8fc5d5f293265138c9b95e410fc8d2b61818b9 Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-dispatcher/support-submit_job-token/+merge/87893 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Paul Larson (pwlars) review: Approve - Zygmunt Krynicki (zkrynicki) https://code.launchpad.net/~mwhudson/lava-dispatcher/custom-connection-command/+merge/87890 proposed by: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 189 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Fri 2012-01-13 12:08:03 +1300 message: support the inclusion of a auth token in the job file and use it when submitting results this means that it is now possible to submit a job to a private bundle stream modified: lava_dispatcher/actions/launch_control.py lava_dispatcher/connection.py lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf setup.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 === modified file 'lava_dispatcher/actions/launch_control.py' --- lava_dispatcher/actions/launch_control.py 2011-11-24 03:00:54 +0000 +++ lava_dispatcher/actions/launch_control.py 2012-01-09 23:20:01 +0000 @@ -24,6 +24,9 @@ import shutil import tarfile import logging +import urlparse + +from lava_tool.authtoken import AuthenticatingServerProxy, MemoryAuthBackend from lava_dispatcher.actions import BaseAction from lava_dispatcher.client.base import OperationFailed @@ -44,8 +47,8 @@ test_runs += bundle['test_runs'] return main_bundle - def submit_combine_bundles(self, status='pass', err_msg='', server=None, stream=None): - dashboard = _get_dashboard(server) + def submit_combine_bundles(self, status='pass', err_msg='', server=None, stream=None, token=None): + dashboard = _get_dashboard(server, token) main_bundle = self.combine_bundles() self.context.test_data.add_seriallog( self.context.client.get_seriallog()) @@ -67,7 +70,7 @@ logging.warning("Fault string: %s" % err.faultString) class cmd_submit_results_on_host(SubmitResultAction): - def run(self, server, stream): + def run(self, server, stream, token=None): #Upload bundle files to dashboard logging.info("Executing submit_results_on_host command") bundlename_list = [] @@ -87,7 +90,7 @@ status = 'fail' err_msg = err_msg + " Some test case result appending failed." - self.submit_combine_bundles(status, err_msg, server, stream) + self.submit_combine_bundles(status, err_msg, server, stream, token) for bundle in bundlename_list: os.remove(bundle) @@ -98,7 +101,7 @@ class cmd_submit_results(SubmitResultAction): - def run(self, server, stream, result_disk="testrootfs"): + def run(self, server, stream, result_disk="testrootfs", token=None): """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 @@ -126,12 +129,12 @@ if err_msg is None: err_msg = '' - self.submit_combine_bundles(status, err_msg, server, stream) + self.submit_combine_bundles(status, err_msg, server, stream, token) if status == 'fail': raise OperationFailed(err_msg) #util function, see if it needs to be part of utils.py -def _get_dashboard(server): +def _get_dashboard(server, token): if not server.endswith("/"): server = ''.join([server, "/"]) @@ -141,7 +144,23 @@ server = ''.join([server, "xml-rpc/"]) logging.warn("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) + parsed_server = urlparse.urlparse(server) + auth_backend = MemoryAuthBackend([]) + if parsed_server.username: + if token: + userless_server = '%s://%s%s' % ( + parsed_server.scheme, parsed_server.hostname, parsed_server.path) + auth_backend = MemoryAuthBackend([(parsed_server.username, userless_server, token)]) + else: + logging.warn( + "specifying a user without a token is unlikely to work") + else: + if token: + logging.warn( + "specifying a token without a user is probably useless") + + srv = AuthenticatingServerProxy( + server, allow_none=True, use_datetime=True, auth_backend=auth_backend) if server.endswith("xml-rpc/"): logging.warn("Please use RPC2 endpoint instead, xml-rpc is deprecated!!!") dashboard = srv === modified file 'lava_dispatcher/connection.py' --- lava_dispatcher/connection.py 2012-01-12 20:38:57 +0000 +++ lava_dispatcher/connection.py 2012-01-12 23:08:03 +0000 @@ -102,7 +102,7 @@ class LavaConmuxConnection(LavaConnection): def _make_connection(self, sio): - cmd = "conmux-console %s" % self.device_option("hostname") + cmd = self.device_option("connection_command") proc = pexpect.spawn(cmd, timeout=1200, logfile=sio) #serial can be slow, races do funny things if you don't increase delay proc.delaybeforesend=1 === modified file 'lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf' --- lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf 2011-11-30 01:12:17 +0000 +++ lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf 2012-01-09 03:16:32 +0000 @@ -12,6 +12,8 @@ # 'qemu' is the other possible value at this time. client_type = master +connection_command = conmux-console %(hostname)s + # The bootloader commands to boot the device into the test image (we # assume that the device boots into the master image without bootloader # intervention). === modified file 'setup.py' --- setup.py 2011-11-14 04:24:37 +0000 +++ setup.py 2012-01-09 03:08:37 +0000 @@ -22,6 +22,7 @@ }, install_requires=[ "pexpect >= 2.3", + "lava-tool", "json-schema-validator", ], setup_requires=[