From patchwork Sun Jun 17 23:57:09 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: 9373 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 CB67D23E4F for ; Sun, 17 Jun 2012 23:57:13 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6F1C4A1816C for ; Sun, 17 Jun 2012 23:57:13 +0000 (UTC) Received: by obbun3 with SMTP id un3so8588791obb.11 for ; Sun, 17 Jun 2012 16:57:12 -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=rSm2zEKm6qBOvkaAsB749LB5RrRSI1f9L7Dkdj5q7sE=; b=UxVdHXBYUV4AHDDeIropHafe9tJLg2/w/hIDxm6iDNz9d26rNVLc3ie7U8k8qd3VjP uaMA0/aL1HPDoY+qrEKLr6LJvPmI2SC21K3jJdZjW3W4rUuf5qG9HM66E3QRo4zcQjTa kLLcdziqCBp0Q1Kg9lG6OfLJvy/gzwAwtIfDueWclGdtJyE01BK8joLB6oT9hdH6Ep51 Pvi4001yyuIoyxMivAZ4OmwccNpf/R2ic04czACwLLb/uUbzAolIBnfDn7IfpthdfC4j JbKglA5DtMqSRcRDvOAdcJBnta+I56AoKO5aPJEmu7ppGZDfN+gahLW5QWBQeg7rykV7 Xvxw== Received: by 10.50.160.198 with SMTP id xm6mr7095809igb.0.1339977432681; Sun, 17 Jun 2012 16:57:12 -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 v20csp39059ibb; Sun, 17 Jun 2012 16:57:11 -0700 (PDT) Received: by 10.180.93.99 with SMTP id ct3mr19717195wib.13.1339977431119; Sun, 17 Jun 2012 16:57:11 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id c54si19329546wec.157.2012.06.17.16.57.10 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jun 2012 16:57:11 -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 1SgPLC-0006yo-0U for ; Sun, 17 Jun 2012 23:57:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id E64B3E0023 for ; Sun, 17 Jun 2012 23:57:09 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-scheduler X-Launchpad-Branch: ~linaro-validation/lava-scheduler/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 179 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 179: add a "retire" admin action Message-Id: <20120617235709.28292.78297.launchpad@ackee.canonical.com> Date: Sun, 17 Jun 2012 23:57:09 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15419"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 48b44d2de734137ff155fdbe410a10347d807d87 X-Gm-Message-State: ALoCoQlsG7bagz9Mdwk4q9AdODKEB4JmRdXJtuAhXgCmTWK76TnEOhvGf0J0EXbF1Q2hKzbMxyky ------------------------------------------------------------ revno: 179 committer: Michael Hudson-Doyle branch nick: trunk timestamp: Mon 2012-06-18 11:55:10 +1200 message: add a "retire" admin action modified: lava_scheduler_app/admin.py --- lp:lava-scheduler https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk You are subscribed to branch lp:lava-scheduler. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription === modified file 'lava_scheduler_app/admin.py' --- lava_scheduler_app/admin.py 2012-03-13 00:21:57 +0000 +++ lava_scheduler_app/admin.py 2012-06-17 23:55:10 +0000 @@ -18,6 +18,17 @@ device.put_into_online_mode(request.user, "admin action") online_action.short_description = "take online" +def retire_action(modeladmin, request, queryset): + for device in queryset: + if device.can_admin(request.user): + new_status = device.RETIRED + DeviceStateTransition.objects.create( + created_by=request.user, device=device, old_state=device.status, + new_state=new_status, message="retiring", job=None).save() + device.status = new_status + device.save() +retire_action.short_description = "retire" + def health_unknown(modeladmin, request, queryset): for device in queryset.filter(health_status=Device.HEALTH_PASS): device.health_status = Device.HEALTH_UNKNOWN @@ -25,7 +36,7 @@ health_unknown.short_description = "set health_status to unknown" class DeviceAdmin(admin.ModelAdmin): - actions = [online_action, offline_action, health_unknown] + actions = [online_action, offline_action, health_unknown, retire_action] list_filter = ['device_type', 'status'] admin.site.register(Device, DeviceAdmin)