diff mbox

[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
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Jan. 14, 2013, 9:17 p.m. UTC
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 <michael.hudson@linaro.org>
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
diff mbox

Patch

=== 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()