=== modified file 'lava_scheduler_app/admin.py'
@@ -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'
@@ -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()