From patchwork Wed May 23 21:46:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Le Chi Thu X-Patchwork-Id: 8932 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 3433A23E01 for ; Wed, 23 May 2012 21:46:13 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id DBED5A18044 for ; Wed, 23 May 2012 21:46:12 +0000 (UTC) Received: by ggnf1 with SMTP id f1so8686610ggn.11 for ; Wed, 23 May 2012 14:46: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=m6RH/wCA2l7C5OcSLm8/RkvYS3T2XjJy1wRN5/EYnrM=; b=QO9sXLQUlZLKJsb69mBhg2WrCvUMfL5m0rE+2sMfWClbWLDIJKTVTbZztJRg3j+jHS vbrRTVQER8+H+i6lxb74EYSHszelvuDWfbdroXkVtLjoZtej8EteY6ym72IWd3pYtGTN 7eeeb+AAJW5IxZ8d10aYLYi5rr4TLzLsPg9ftVdzZjniCJr/+Nsa69QsIIHz2sZmBJo7 1IpocRfXvNp0z5Av2sOb5c/F/FEXf/9OQn3lzNhUv9dw/ZNe0HiaC5lQ3KGqU7OGlg76 9Js5Auux9V8VyW7uSUHi4Skl361X/nVx0GNhN5e8lg8pxXAwOMQr/+TLCg0frqeAyHCB +uPw== Received: by 10.43.59.205 with SMTP id wp13mr4315009icb.57.1337809572239; Wed, 23 May 2012 14:46: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.35.72 with SMTP id o8csp480125ibd; Wed, 23 May 2012 14:46:11 -0700 (PDT) Received: by 10.180.85.129 with SMTP id h1mr49747410wiz.2.1337809570948; Wed, 23 May 2012 14:46:10 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id n50si7451580wee.54.2012.05.23.14.46.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 May 2012 14:46:10 -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 1SXJNi-0006FN-7T for ; Wed, 23 May 2012 21:46:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 2C8A6E0451 for ; Wed, 23 May 2012 21:46:10 +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: 170 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 170: Add support for looping of health care jobs Message-Id: <20120523214610.4112.10639.launchpad@ackee.canonical.com> Date: Wed, 23 May 2012 21:46:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15282"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 5ca98aa80b8f03d4e3c171289c78c8e72c59568a X-Gm-Message-State: ALoCoQlykbPYqcGYcWpRecMGKn/zRyP05g90NNAqy+Fa04iBszyTMMdWhYKgo5H3yfqOxYH4grzK Merge authors: Le Chi Thu le.chi.thu@linaro.org Related merge proposals: https://code.launchpad.net/~le-chi-thu/lava-scheduler/loop-health-check-job/+merge/107019 proposed by: Le Chi Thu (le-chi-thu) review: Approve - Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 170 [merge] committer: Le Chi Thu le.chi.thu@linaro.org branch nick: trunk timestamp: Wed 2012-05-23 23:43:36 +0200 message: Add support for looping of health care jobs modified: doc/changes.rst lava_scheduler_app/models.py lava_scheduler_app/templates/lava_scheduler_app/_device_base.html lava_scheduler_app/urls.py lava_scheduler_app/views.py lava_scheduler_daemon/dbjobsource.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 'doc/changes.rst' --- doc/changes.rst 2012-04-20 03:30:58 +0000 +++ doc/changes.rst 2012-05-23 21:43:36 +0000 @@ -1,6 +1,7 @@ Version History *************** +* Add support for looping of health care jobs Version 0.13 ============ === modified file 'lava_scheduler_app/models.py' --- lava_scheduler_app/models.py 2012-04-20 03:22:44 +0000 +++ lava_scheduler_app/models.py 2012-05-23 11:42:47 +0000 @@ -74,11 +74,12 @@ ) # A device health shows a device is ready to test or not - HEALTH_UNKNOWN, HEALTH_PASS, HEALTH_FAIL = range(3) + HEALTH_UNKNOWN, HEALTH_PASS, HEALTH_FAIL, HEALTH_LOOPING = range(4) HEALTH_CHOICES = ( (HEALTH_UNKNOWN, 'Unknown'), (HEALTH_PASS, 'Pass'), (HEALTH_FAIL, 'Fail'), + (HEALTH_LOOPING, 'Looping'), ) hostname = models.CharField( @@ -147,6 +148,8 @@ created_by=user, device=self, old_state=self.status, new_state=new_status, message=reason, job=None).save() self.status = new_status + if self.health_status == Device.HEALTH_LOOPING: + self.health_status = Device.HEALTH_UNKNOWN self.save() def put_into_online_mode(self, user, reason): @@ -160,6 +163,17 @@ self.health_status = Device.HEALTH_UNKNOWN self.save() + def put_into_looping_mode(self, user): + if self.status not in [Device.OFFLINE, Device.OFFLINING]: + return + new_status = self.IDLE + DeviceStateTransition.objects.create( + created_by=user, device=self, old_state=self.status, + new_state=new_status, message="Looping mode", job=None).save() + self.status = new_status + self.health_status = Device.HEALTH_LOOPING + self.save() + #@classmethod #def find_devices_by_type(cls, device_type): # return device_type.device_set.all() === modified file 'lava_scheduler_app/templates/lava_scheduler_app/_device_base.html' --- lava_scheduler_app/templates/lava_scheduler_app/_device_base.html 2012-03-09 02:49:54 +0000 +++ lava_scheduler_app/templates/lava_scheduler_app/_device_base.html 2012-05-23 11:42:47 +0000 @@ -54,6 +54,11 @@ {% csrf_token %} +
+ {% csrf_token %} + +
{% endif %}
=== modified file 'lava_scheduler_app/urls.py' --- lava_scheduler_app/urls.py 2012-03-02 04:35:51 +0000 +++ lava_scheduler_app/urls.py 2012-05-23 11:42:47 +0000 @@ -3,33 +3,36 @@ urlpatterns = patterns( 'lava_scheduler_app.views', - url(r'^$', + url(r'^$', 'index', name='lava.scheduler'), - url(r'^active_jobs_json$', + url(r'^active_jobs_json$', 'index_active_jobs_json', name='lava.scheduler.active_jobs_json'), - url(r'^devices_json$', + url(r'^devices_json$', 'index_devices_json', name='lava.scheduler.index_devices_json'), - url(r'^alljobs$', - 'job_list', + url(r'^alljobs$', + 'job_list', name='lava.scheduler.job.list'), url(r'^alljobs_json$', 'alljobs_json', name='lava.scheduler.job.list_json'), - url(r'^device/(?P[-_a-zA-Z0-9]+)$', - 'device_detail', + url(r'^device/(?P[-_a-zA-Z0-9]+)$', + 'device_detail', name='lava.scheduler.device.detail'), - url(r'^device/(?P[-_a-zA-Z0-9]+)/recent_jobs_json$', - 'recent_jobs_json', + url(r'^device/(?P[-_a-zA-Z0-9]+)/recent_jobs_json$', + 'recent_jobs_json', name='lava.scheduler.device.recent_jobs_json'), - url(r'^device/(?P[-_a-zA-Z0-9]+)/transition_json$', - 'transition_json', + url(r'^device/(?P[-_a-zA-Z0-9]+)/transition_json$', + 'transition_json', name='lava.scheduler.device.transition_json'), - url(r'^device/(?P[-_a-zA-Z0-9]+)/maintenance$', - 'device_maintenance_mode', + url(r'^device/(?P[-_a-zA-Z0-9]+)/maintenance$', + 'device_maintenance_mode', name='lava.scheduler.device.maintenance'), + url(r'^device/(?P[-_a-zA-Z0-9]+)/looping$', + 'device_looping_mode', + name='lava.scheduler.device.looping'), url(r'^device/(?P[-_a-zA-Z0-9]+)/online$', 'device_online', name='lava.scheduler.device.online'), @@ -64,7 +67,7 @@ 'job_cancel', name='lava.scheduler.job.cancel'), url(r'^job/(?P[0-9]+)/json$', - 'job_json', + 'job_json', name='lava.scheduler.job.json'), url(r'^job/(?P[0-9]+)/output$', 'job_output', === modified file 'lava_scheduler_app/views.py' --- lava_scheduler_app/views.py 2012-03-19 02:01:59 +0000 +++ lava_scheduler_app/views.py 2012-05-23 11:42:47 +0000 @@ -573,3 +573,14 @@ else: return HttpResponseForbidden( "you cannot administer this device", content_type="text/plain") + +@post_only +def device_looping_mode(request, pk): + device = Device.objects.get(pk=pk) + if device.can_admin(request.user): + device.put_into_looping_mode(request.user) + return redirect(device) + else: + return HttpResponseForbidden( + "you cannot administer this device", content_type="text/plain") + === modified file 'lava_scheduler_daemon/dbjobsource.py' --- lava_scheduler_daemon/dbjobsource.py 2012-04-05 04:34:13 +0000 +++ lava_scheduler_daemon/dbjobsource.py 2012-05-22 14:33:13 +0000 @@ -152,6 +152,8 @@ run_health_check = False elif device.health_status == Device.HEALTH_UNKNOWN: run_health_check = True + elif device.health_status == Device.HEALTH_LOOPING: + run_health_check = True elif not device.last_health_report_job: run_health_check = True else: @@ -238,11 +240,12 @@ if job.health_check: device.last_health_report_job = job - if job.status == TestJob.INCOMPLETE: - device.health_status = Device.HEALTH_FAIL - device.put_into_maintenance_mode(None, "Health Check Job Failed") - elif job.status == TestJob.COMPLETE: - device.health_status = Device.HEALTH_PASS + if device.health_status != Device.HEALTH_LOOPING: + if job.status == TestJob.INCOMPLETE: + device.health_status = Device.HEALTH_FAIL + device.put_into_maintenance_mode(None, "Health Check Job Failed") + elif job.status == TestJob.COMPLETE: + device.health_status = Device.HEALTH_PASS job.end_time = datetime.datetime.utcnow() token = job.submit_token