From patchwork Fri Jun 1 02:00:17 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: 9064 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 1BA5E23F0A for ; Fri, 1 Jun 2012 02:00:22 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id C2B45A18AC6 for ; Fri, 1 Jun 2012 02:00:21 +0000 (UTC) Received: by ggnf1 with SMTP id f1so1610147ggn.11 for ; Thu, 31 May 2012 19:00:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=Hqk/fdqpXbwgNImO36eGkZJtHtHycH9qQzC5PFtCAGc=; b=FNQpnp62NrbFbtuaxkrlfqFh0GZU/CWLOwKLsJaRSu1wbl8pAnRVSqL4wVhfJCGz9Q VJxEJz43T0HG8w1O3hZ6bGMMm+IUcnjACICHx0Im/e5GFtYTz4EgCuCj1zGuf4wMuvI+ 4Gs+iOAw80AZufwTLIMfXh0js/67SnyVSQ2txrkTjV/ylQ4FGEuJC3yPla6KKpue+c23 M+O+Qydq9G2eoSXtCVwjeuQHdQ5gxQiuHOtZr2x6K+12hPW7fmYInnagbgsDejiRqFS+ 8nbOYPPnos6pahybvzvnG0MMTvlM19TJWQ9UNSt2qA1JvFG6eGunCdAU4NM9lAAodBtX K0qw== Received: by 10.42.89.72 with SMTP id f8mr421450icm.33.1338516021146; Thu, 31 May 2012 19:00:21 -0700 (PDT) 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.231.24.148 with SMTP id v20csp290397ibb; Thu, 31 May 2012 19:00:18 -0700 (PDT) Received: by 10.216.225.196 with SMTP id z46mr776424wep.17.1338516017957; Thu, 31 May 2012 19:00:17 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id n13si543229wee.27.2012.05.31.19.00.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 May 2012 19:00:17 -0700 (PDT) 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 1SaHA1-00077a-CQ for ; Fri, 01 Jun 2012 02:00:17 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 51578E041A for ; Fri, 1 Jun 2012 02:00:17 +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: 309 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 309: add "lava connect" and "lava power-cycle" commands Message-Id: <20120601020017.23363.74358.launchpad@ackee.canonical.com> Date: Fri, 01 Jun 2012 02:00:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15342"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 2405434e4c2141cc8dfcd6a4b235df2c0280226f X-Gm-Message-State: ALoCoQn7XkPdYD7+V5sRFHttmWhY5+itAdL45hZEeLbcLdmrFDRjf6Y7mKA3UO1JaEMwTIMzUTi2 Merge authors: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 309 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Fri 2012-06-01 13:56:05 +1200 message: add "lava connect" and "lava power-cycle" commands modified: lava/dispatcher/commands.py 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/commands.py' --- lava/dispatcher/commands.py 2012-03-19 13:29:52 +0000 +++ lava/dispatcher/commands.py 2012-06-01 01:49:28 +0000 @@ -1,21 +1,20 @@ +import argparse import logging import os import sys from json_schema_validator.errors import ValidationError from lava.tool.command import Command +from lava.tool.errors import CommandError -from lava_dispatcher.config import get_config +from lava_dispatcher.config import get_config, get_device_config from lava_dispatcher.job import LavaTestJob, validate_job_data -class dispatch(Command): - """ - Run test scenarios on virtual and physical hardware - """ - +class DispatcherCommand(Command): @classmethod - def register_arguments(self, parser): + def register_arguments(cls, parser): + super(DispatcherCommand, cls).register_arguments(parser) # When we're working inside a virtual environment use venv-relative # configuration directory. This works well with lava-deployment-tool # and the directory layout it currently provides but will need to be @@ -25,17 +24,26 @@ os.environ["VIRTUAL_ENV"], "etc", "lava-dispatcher") else: default_config_dir = None - + parser.add_argument( + "--config-dir", + default=default_config_dir, + help="Configuration directory override (currently %(default)s") + + +class dispatch(DispatcherCommand): + """ + Run test scenarios on virtual and physical hardware + """ + + @classmethod + def register_arguments(cls, parser): + super(dispatch, cls).register_arguments(parser) parser.add_argument( "--oob-fd", default=None, type=int, help="Used internally by LAVA scheduler.") parser.add_argument( - "--config-dir", - default=default_config_dir, - help="Configuration directory override (currently %(default)s") - parser.add_argument( "--validate", action='store_true', help="Just validate the job file, do not execute any steps.") parser.add_argument( @@ -43,7 +51,7 @@ help=("Set the scheduler job identifier. " "This alters process name for easier debugging")) parser.add_argument( - "job-file", + "job_file", metavar="JOB", help="Test scenario file") @@ -75,7 +83,7 @@ getproctitle(), self.args.job_id)) # Load the scenario file - with open(args[0]) as stream: + with open(self.args.job_file) as stream: jobdata = stream.read() job = LavaTestJob(jobdata, oob_file, config) @@ -87,3 +95,35 @@ print e else: job.run() + + + +class DeviceCommand(DispatcherCommand): + + @classmethod + def register_arguments(cls, parser): + super(DeviceCommand, cls).register_arguments(parser) + parser.add_argument('device') + + @property + def device_config(self): + try: + return get_device_config(self.args.device, self.args.config_dir) + except Exception: + raise CommandError("no such device: %s" % self.args.device) + +class connect(DeviceCommand): + + def invoke(self): + os.execlp( + 'sh', 'sh', '-c', self.device_config.get('connection_command')) + +class power_cycle(DeviceCommand): + + def invoke(self): + command = self.device_config.get('hard_reset_command', '') + if not command: + raise CommandError( + "%s does not have a power cycle command configured" % + self.args.device) + os.system(command) === modified file 'setup.py' --- setup.py 2012-05-08 22:06:32 +0000 +++ setup.py 2012-06-01 01:49:28 +0000 @@ -14,6 +14,8 @@ entry_points=""" [lava.commands] dispatch = lava.dispatcher.commands:dispatch + connect = lava.dispatcher.commands:connect + power-cycle = lava.dispatcher.commands:power_cycle """, packages=find_packages(), package_data= {