From patchwork Mon Jan 14 21:17:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 14033 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 2219723E27 for ; Mon, 14 Jan 2013 21:17:15 +0000 (UTC) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by fiordland.canonical.com (Postfix) with ESMTP id C3515A1916E for ; Mon, 14 Jan 2013 21:17:14 +0000 (UTC) Received: by mail-vc0-f179.google.com with SMTP id p1so4093071vcq.10 for ; Mon, 14 Jan 2013 13:17:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :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=kHbOX+b/UQlS0X26r5slw/66ONcj9x8ZUJgqQb0dsRc=; b=W1sbcsZ9vN617LhuPc3D34Blb8xb4OFuzBsgDZkPTC9WHSh4lrV3d3DcYTA+OZEhgn 5TroVgxeE6uVRkojHsXR7KppLgSUa8IW24vUty4pbKbpS7A0s7AG+assZlbTsLQsVzZs CGg5e/Y/V730Cd1p/8fkhQ4wmNSARMfQJFct1r8RfYUaNyNSaYZAiFbFsfhU8UTBS4ZK sBiBDPBkDIqfsgpMYL30y5V239Z5oZlfwAJEC9/CKxUlstn6Cfi/C0/Ld8bSO4CcjRyt 3kOaqz5fCNzmwptcbJ8BjxMh+v8d24Z7vzsX4nYzxZ1k+Ypil7wtdou1Oe/xLEpDAKi8 o5EQ== X-Received: by 10.220.238.139 with SMTP id ks11mr101237722vcb.49.1358198234240; Mon, 14 Jan 2013 13:17:14 -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.58.145.101 with SMTP id st5csp80146veb; Mon, 14 Jan 2013 13:17:13 -0800 (PST) X-Received: by 10.194.240.233 with SMTP id wd9mr19513338wjc.54.1358198233171; Mon, 14 Jan 2013 13:17:13 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id lv9si24542732wjb.36.2013.01.14.13.17.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 14 Jan 2013 13:17: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 1TurP5-0007Gj-F3 for ; Mon, 14 Jan 2013 21:17:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 47492E034E for ; Mon, 14 Jan 2013 21:17:11 +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: 235 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 235: * prevent offline admin action from touching RETIRED boards Message-Id: <20130114211711.32399.86724.launchpad@ackee.canonical.com> Date: Mon, 14 Jan 2013 21:17: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="16420"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 8a146fc164335b5b8f2d3eab05bb00cdb8ff26c4 X-Gm-Message-State: ALoCoQkdtI0zLcLnwyvDbCZ9okMO1q4rE10LKOtXwtcoAMk3OV3qjB5pioH1VYuln+w9W8Lz5fyk Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-scheduler/offline-admin-action-leave-retired/+merge/143054 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Andy Doan (doanac) ------------------------------------------------------------ revno: 235 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Tue 2013-01-15 10:16:28 +1300 message: * prevent offline admin action from touching RETIRED boards * make onlining an OFFLINING board dtrt modified: lava_scheduler_app/admin.py lava_scheduler_app/models.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 2013-01-02 19:27:56 +0000 +++ lava_scheduler_app/admin.py 2013-01-14 21:01:59 +0000 @@ -7,13 +7,13 @@ # Sounds tedious to implement though. def offline_action(modeladmin, request, queryset): - for device in queryset: + for device in queryset.filter(status__in=[Device.IDLE, Device.RUNNING]): if device.can_admin(request.user): device.put_into_maintenance_mode(request.user, "admin action") offline_action.short_description = "take offline" def online_action(modeladmin, request, queryset): - for device in queryset: + for device in queryset.filter(status__in=[Device.OFFLINE, Device.OFFLINING]): if device.can_admin(request.user): device.put_into_online_mode(request.user, "admin action") online_action.short_description = "take online" === modified file 'lava_scheduler_app/models.py' --- lava_scheduler_app/models.py 2013-01-03 16:12:15 +0000 +++ lava_scheduler_app/models.py 2013-01-14 21:01:59 +0000 @@ -175,9 +175,10 @@ self.save() def put_into_online_mode(self, user, reason): - if self.status not in [Device.OFFLINE, Device.OFFLINING]: - return - new_status = self.IDLE + if self.status == Device.OFFLINING: + new_status = self.RUNNING + else: + new_status = self.IDLE DeviceStateTransition.objects.create( created_by=user, device=self, old_state=self.status, new_state=new_status, message=reason, job=None).save()