Add job maximum runtime, a new per-job timeout that counts time since the job actually started.
* added started_on field to host_queue_entries, so that we could actually compute this timeout
* added max_runtime_hrs to jobs, with default in global config, and added option to create_job() RPC
* added the usual controls to AFE and the CLI for the new job option
* added new max runtime timeout method to 
* added migration to add new fields and set a safe default max runtime for existing jobs

Signed-off-by: Steve Howard <showard@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3132 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/job.py b/cli/job.py
index d0ef9b7..1dfc3e5 100755
--- a/cli/job.py
+++ b/cli/job.py
@@ -210,8 +210,9 @@
     [--mlist </path/to/machinelist>] [--machine <host1 host2 host3>]
     [--labels <list of labels of machines to run on>]
     [--reboot_before <option>] [--reboot_after <option>]
-    [--noverify] [--timeout <timeout>] [--one-time-hosts <hosts>]
-    [--email <email>] [--dependencies <labels this job is dependent on>]
+    [--noverify] [--timeout <timeout>] [--max_runtime <max runtime>]
+    [--one-time-hosts <hosts>] [--email <email>]
+    [--dependencies <labels this job is dependent on>]
     [--atomic_group <atomic group name>] [--parse-failed-repair <option>]
     job_name
 
@@ -289,6 +290,8 @@
                                default=False, action='store_true')
         self.parser.add_option('-o', '--timeout', help='Job timeout in hours.',
                                metavar='TIMEOUT')
+        self.parser.add_option('--max_runtime',
+                               help='Job maximum runtime in hours')
 
 
     def parse(self):
@@ -375,6 +378,8 @@
             self.data['run_verify'] = False
         if options.timeout:
             self.data['timeout'] = options.timeout
+        if options.max_runtime:
+            self.data['max_runtime_hrs'] = options.max_runtime
 
         if self.one_time_hosts:
             self.data['one_time_hosts'] = self.one_time_hosts