OLD | NEW |
1 """\ | 1 """\ |
2 Functions to expose over the RPC interface. | 2 Functions to expose over the RPC interface. |
3 | 3 |
4 For all modify* and delete* functions that ask for an 'id' parameter to | 4 For all modify* and delete* functions that ask for an 'id' parameter to |
5 identify the object to operate on, the id may be either | 5 identify the object to operate on, the id may be either |
6 * the database row ID | 6 * the database row ID |
7 * the name of the object (label name, hostname, user login, etc.) | 7 * the name of the object (label name, hostname, user login, etc.) |
8 * a dictionary containing uniquely identifying field (this option should seldom | 8 * a dictionary containing uniquely identifying field (this option should seldom |
9 be used) | 9 be used) |
10 | 10 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 parameterized_job.delete() | 482 parameterized_job.delete() |
483 raise | 483 raise |
484 | 484 |
485 | 485 |
486 def create_job(name, priority, control_file, control_type, | 486 def create_job(name, priority, control_file, control_type, |
487 hosts=(), meta_hosts=(), one_time_hosts=(), | 487 hosts=(), meta_hosts=(), one_time_hosts=(), |
488 atomic_group_name=None, synch_count=None, is_template=False, | 488 atomic_group_name=None, synch_count=None, is_template=False, |
489 timeout=None, max_runtime_hrs=None, run_verify=True, | 489 timeout=None, max_runtime_hrs=None, run_verify=True, |
490 email_list='', dependencies=(), reboot_before=None, | 490 email_list='', dependencies=(), reboot_before=None, |
491 reboot_after=None, parse_failed_repair=None, hostless=False, | 491 reboot_after=None, parse_failed_repair=None, hostless=False, |
492 keyvals=None, drone_set=None): | 492 keyvals=None, drone_set=None, image=None): |
493 """\ | 493 """\ |
494 Create and enqueue a job. | 494 Create and enqueue a job. |
495 | 495 |
496 @param name name of this job | 496 @param name name of this job |
497 @param priority Low, Medium, High, Urgent | 497 @param priority Low, Medium, High, Urgent |
498 @param control_file String contents of the control file. | 498 @param control_file String contents of the control file. |
499 @param control_type Type of control file, Client or Server. | 499 @param control_type Type of control file, Client or Server. |
500 @param synch_count How many machines the job uses per autoserv execution. | 500 @param synch_count How many machines the job uses per autoserv execution. |
501 synch_count == 1 means the job is asynchronous. If an atomic group is | 501 synch_count == 1 means the job is asynchronous. If an atomic group is |
502 given this value is treated as a minimum. | 502 given this value is treated as a minimum. |
503 @param is_template If true then create a template job. | 503 @param is_template If true then create a template job. |
504 @param timeout Hours after this call returns until the job times out. | 504 @param timeout Hours after this call returns until the job times out. |
505 @param max_runtime_hrs Hours from job starting time until job times out | 505 @param max_runtime_hrs Hours from job starting time until job times out |
506 @param run_verify Should the host be verified before running the test? | 506 @param run_verify Should the host be verified before running the test? |
507 @param email_list String containing emails to mail when the job is done | 507 @param email_list String containing emails to mail when the job is done |
508 @param dependencies List of label names on which this job depends | 508 @param dependencies List of label names on which this job depends |
509 @param reboot_before Never, If dirty, or Always | 509 @param reboot_before Never, If dirty, or Always |
510 @param reboot_after Never, If all tests passed, or Always | 510 @param reboot_after Never, If all tests passed, or Always |
511 @param parse_failed_repair if true, results of failed repairs launched by | 511 @param parse_failed_repair if true, results of failed repairs launched by |
512 this job will be parsed as part of the job. | 512 this job will be parsed as part of the job. |
513 @param hostless if true, create a hostless job | 513 @param hostless if true, create a hostless job |
514 @param keyvals dict of keyvals to associate with the job | 514 @param keyvals dict of keyvals to associate with the job |
515 | 515 |
516 @param hosts List of hosts to run job on. | 516 @param hosts List of hosts to run job on. |
517 @param meta_hosts List where each entry is a label name, and for each entry | 517 @param meta_hosts List where each entry is a label name, and for each entry |
518 one host will be chosen from that label to run the job on. | 518 one host will be chosen from that label to run the job on. |
519 @param one_time_hosts List of hosts not in the database to run the job on. | 519 @param one_time_hosts List of hosts not in the database to run the job on. |
520 @param atomic_group_name The name of an atomic group to schedule the job on. | 520 @param atomic_group_name The name of an atomic group to schedule the job on. |
521 @param drone_set The name of the drone set to run this test on. | 521 @param drone_set The name of the drone set to run this test on. |
| 522 @param image OS image to install before running job. |
522 | 523 |
523 | 524 |
524 @returns The created Job id number. | 525 @returns The created Job id number. |
525 """ | 526 """ |
| 527 |
| 528 if image is None: |
| 529 return rpc_utils.create_job_common( |
| 530 **rpc_utils.get_create_job_common_args(locals())) |
| 531 |
| 532 # When image is supplied use a known parameterized test already in the |
| 533 # database to pass the OS image path from the front end, through the |
| 534 # scheduler, and finally to autoserv as the --image parameter. |
| 535 |
| 536 # The test autoupdate_ParameterizedJob is in afe_autotests and used to |
| 537 # instantiate a Test object and from there a ParameterizedJob. |
| 538 known_test_obj = models.Test.smart_get('autoupdate_ParameterizedJob') |
| 539 known_parameterized_job = models.ParameterizedJob.objects.create( |
| 540 test=known_test_obj) |
| 541 |
| 542 # autoupdate_ParameterizedJob has a single parameter, the image parameter, |
| 543 # stored in the table afe_test_parameters. We retrieve and set this |
| 544 # instance of the parameter to the OS image path. |
| 545 image_parameter = known_test_obj.testparameter_set.get(id=1) |
| 546 known_parameterized_job.parameterizedjobparameter_set.create( |
| 547 test_parameter=image_parameter, parameter_value=image, |
| 548 parameter_type='string') |
| 549 |
| 550 # By passing a parameterized_job to create_job_common the job entry in |
| 551 # the afe_jobs table will have the field parameterized_job_id set. |
| 552 # The scheduler uses this id in the afe_parameterized_jobs table to |
| 553 # match this job to our known test, and then with the |
| 554 # afe_parameterized_job_parameters table to get the actual image path. |
526 return rpc_utils.create_job_common( | 555 return rpc_utils.create_job_common( |
| 556 parameterized_job=known_parameterized_job.id, |
527 **rpc_utils.get_create_job_common_args(locals())) | 557 **rpc_utils.get_create_job_common_args(locals())) |
528 | 558 |
529 | 559 |
530 def abort_host_queue_entries(**filter_data): | 560 def abort_host_queue_entries(**filter_data): |
531 """\ | 561 """\ |
532 Abort a set of host queue entries. | 562 Abort a set of host queue entries. |
533 """ | 563 """ |
534 query = models.HostQueueEntry.query_objects(filter_data) | 564 query = models.HostQueueEntry.query_objects(filter_data) |
535 query = query.filter(complete=False) | 565 query = query.filter(complete=False) |
536 models.AclGroup.check_abort_permissions(query) | 566 models.AclGroup.check_abort_permissions(query) |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 "Parsing": "Awaiting parse of final results", | 866 "Parsing": "Awaiting parse of final results", |
837 "Gathering": "Gathering log files", | 867 "Gathering": "Gathering log files", |
838 "Template": "Template job for recurring run", | 868 "Template": "Template job for recurring run", |
839 "Waiting": "Waiting for scheduler action", | 869 "Waiting": "Waiting for scheduler action", |
840 "Archiving": "Archiving results"} | 870 "Archiving": "Archiving results"} |
841 return result | 871 return result |
842 | 872 |
843 | 873 |
844 def get_server_time(): | 874 def get_server_time(): |
845 return datetime.datetime.now().strftime("%Y-%m-%d %H:%M") | 875 return datetime.datetime.now().strftime("%Y-%m-%d %H:%M") |
OLD | NEW |