From patchwork Sun Dec 2 04:46:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 13316 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 CD0E42425B for ; Sun, 2 Dec 2012 04:46:16 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5D8C0A1806E for ; Sun, 2 Dec 2012 04:46:16 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so2509565ieb.11 for ; Sat, 01 Dec 2012 20:46:15 -0800 (PST) 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=uZxsDm4cG+IjACJt9/vx9ygEFAIGxrdQy3EintAPUHo=; b=ltkdIgDz/9fZj+FNa4hq770lBYFh8NwodVavGYlvEMBnwgD8QrMeAmfbtD7QlUDJe1 QuNhXUnm/f14cwpA8FZYFNdw996OlJ/wMPCzRyjyi2J4P4rZWiZzytHondp6SZHPrqZK YkJ2uYtK3XYSCd4DSsJa6zSWmgECL2VXYWxLabTgIg1nSo7z44PC9qLlnE2eJMnE1cDA RUi16q9dXRBhanzEi9nxA8GMErcuZgyFaErgYHx91U9Gvd1MwxlCF/1fjeQG8ZKvc953 dnP1OnGryKx90SrzIPW6ZlFcvxcHpDmAKj/pJJ7SKkM+jI/vfcezIMuSsr9DX5fTFG/E g7Ag== Received: by 10.50.186.199 with SMTP id fm7mr2871319igc.62.1354423575798; Sat, 01 Dec 2012 20:46: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.50.67.148 with SMTP id n20csp1240187igt; Sat, 1 Dec 2012 20:46:13 -0800 (PST) Received: by 10.216.220.35 with SMTP id n35mr833140wep.128.1354423572690; Sat, 01 Dec 2012 20:46:12 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id z50si6095509wej.105.2012.12.01.20.46.11 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 01 Dec 2012 20:46:12 -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 1Tf1RT-0001D1-Mp for ; Sun, 02 Dec 2012 04:46:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id A4F74E03DD for ; Sun, 2 Dec 2012 04:46:11 +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: 475 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 475: add a new "devices" api to the dispatcher Message-Id: <20121202044611.21737.77940.launchpad@ackee.canonical.com> Date: Sun, 02 Dec 2012 04:46:11 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16319"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: b2d7135812a370f3f12278006ccc6b8843cbe71b X-Gm-Message-State: ALoCoQnwdESMY8dZ5qVVB5KevD2f8olssSeqwEYmbnaf3bZLFFesFi9p8iKfWqH0CFizbRBOjmmm ------------------------------------------------------------ revno: 475 committer: Andy Doan branch nick: device-list timestamp: Fri 2012-11-30 13:14:23 -0600 message: add a new "devices" api to the dispatcher This allows us to know every device configured locally for a given LAVA instance. modified: lava/dispatcher/commands.py lava_dispatcher/config.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-09-26 02:55:25 +0000 +++ lava/dispatcher/commands.py 2012-11-30 19:14:23 +0000 @@ -1,4 +1,3 @@ -import argparse import logging import os import sys @@ -7,7 +6,7 @@ from lava.tool.command import Command from lava.tool.errors import CommandError -from lava_dispatcher.config import get_config, get_device_config +from lava_dispatcher.config import get_config, get_device_config, get_devices from lava_dispatcher.job import LavaTestJob, validate_job_data @@ -30,6 +29,15 @@ help="Configuration directory override (currently %(default)s") +class devices(DispatcherCommand): + """ + Lists all the configured devices in this LAVA instance. + """ + def invoke(self): + for d in get_devices(self.args.config_dir): + print d.hostname + + class dispatch(DispatcherCommand): """ Run test scenarios on virtual and physical hardware @@ -68,8 +76,8 @@ del logging.root.handlers[:] del logging.root.filters[:] FORMAT = '%(asctime)s %(levelname)s: %(message)s' - DATEFMT= '%Y-%m-%d %I:%M:%S %p' - logging.basicConfig(format=FORMAT,datefmt=DATEFMT) + DATEFMT = '%Y-%m-%d %I:%M:%S %p' + logging.basicConfig(format=FORMAT, datefmt=DATEFMT) config = get_config(self.args.config_dir) logging.root.setLevel(config.logging_level) @@ -100,7 +108,6 @@ job.run() - class DeviceCommand(DispatcherCommand): @classmethod @@ -115,12 +122,14 @@ 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.connection_command) + class power_cycle(DeviceCommand): def invoke(self): === modified file 'lava_dispatcher/config.py' --- lava_dispatcher/config.py 2012-11-30 19:13:30 +0000 +++ lava_dispatcher/config.py 2012-11-30 19:14:23 +0000 @@ -191,3 +191,12 @@ logging.warning("Device config for %s is not valid:\n %s", name, '\n '.join(report)) return DeviceConfig(real_device_config) + + +def get_devices(config_dir): + devices = [] + devices_dir = os.path.join(config_dir, 'devices') + for d in os.listdir(devices_dir): + d = os.path.splitext(d)[0] + devices.append(get_device_config(d, config_dir)) + return devices === modified file 'setup.py' --- setup.py 2012-11-21 00:57:15 +0000 +++ setup.py 2012-11-30 19:14:23 +0000 @@ -15,6 +15,7 @@ [lava.commands] dispatch = lava.dispatcher.commands:dispatch connect = lava.dispatcher.commands:connect + devices = lava.dispatcher.commands:devices power-cycle = lava.dispatcher.commands:power_cycle [lava.signal_handlers] add-duration = lava_dispatcher.signals.duration:AddDuration