mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 1 | """\ |
| 2 | Functions to expose over the RPC interface. |
| 3 | |
| 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 |
| 6 | * the database row ID |
| 7 | * the name of the object (label name, hostname, user login, etc.) |
| 8 | * a dictionary containing uniquely identifying field (this option should seldom |
| 9 | be used) |
| 10 | |
| 11 | When specifying foreign key fields (i.e. adding hosts to a label, or adding |
| 12 | users to an ACL group), the given value may be either the database row ID or the |
| 13 | name of the object. |
| 14 | |
| 15 | All get* functions return lists of dictionaries. Each dictionary represents one |
| 16 | object and maps field names to values. |
| 17 | |
| 18 | Some examples: |
| 19 | modify_host(2, hostname='myhost') # modify hostname of host with database ID 2 |
| 20 | modify_host('ipaj2', hostname='myhost') # modify hostname of host 'ipaj2' |
| 21 | modify_test('sleeptest', test_type='Client', params=', seconds=60') |
| 22 | delete_acl_group(1) # delete by ID |
| 23 | delete_acl_group('Everyone') # delete by name |
| 24 | acl_group_add_users('Everyone', ['mbligh', 'showard']) |
| 25 | get_jobs(owner='showard', status='Queued') |
| 26 | |
mbligh | 93c80e6 | 2009-02-03 17:48:30 +0000 | [diff] [blame] | 27 | See doctests/001_rpc_test.txt for (lots) more examples. |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 28 | """ |
| 29 | |
| 30 | __author__ = 'showard@google.com (Steve Howard)' |
| 31 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 32 | import datetime |
showard | ff90138 | 2008-07-07 23:22:16 +0000 | [diff] [blame] | 33 | from frontend import thread_local |
showard | 09096d8 | 2008-07-07 23:20:49 +0000 | [diff] [blame] | 34 | from frontend.afe import models, model_logic, control_file, rpc_utils |
showard | 3bb499f | 2008-07-03 19:42:20 +0000 | [diff] [blame] | 35 | from autotest_lib.client.common_lib import global_config |
| 36 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 37 | |
| 38 | # labels |
| 39 | |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 40 | def add_label(name, kernel_config=None, platform=None, only_if_needed=None): |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 41 | return models.Label.add_object( |
| 42 | name=name, kernel_config=kernel_config, platform=platform, |
| 43 | only_if_needed=only_if_needed).id |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 44 | |
| 45 | |
| 46 | def modify_label(id, **data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 47 | models.Label.smart_get(id).update_object(data) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | def delete_label(id): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 51 | models.Label.smart_get(id).delete() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 52 | |
| 53 | |
showard | bbabf50 | 2008-06-06 00:02:02 +0000 | [diff] [blame] | 54 | def label_add_hosts(id, hosts): |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 55 | host_objs = models.Host.smart_get_bulk(hosts) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 56 | models.Label.smart_get(id).host_set.add(*host_objs) |
showard | bbabf50 | 2008-06-06 00:02:02 +0000 | [diff] [blame] | 57 | |
| 58 | |
| 59 | def label_remove_hosts(id, hosts): |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 60 | host_objs = models.Host.smart_get_bulk(hosts) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 61 | models.Label.smart_get(id).host_set.remove(*host_objs) |
showard | bbabf50 | 2008-06-06 00:02:02 +0000 | [diff] [blame] | 62 | |
| 63 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 64 | def get_labels(**filter_data): |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 65 | """\ |
| 66 | @returns A sequence of nested dictionaries of label information. |
| 67 | """ |
| 68 | return rpc_utils.prepare_rows_as_nested_dicts( |
| 69 | models.Label.query_objects(filter_data), |
| 70 | ('atomic_group',)) |
| 71 | |
| 72 | |
| 73 | # atomic groups |
| 74 | |
| 75 | def add_atomic_group(name, max_number_of_machines, description=None): |
| 76 | return models.AtomicGroup.add_object( |
| 77 | name=name, max_number_of_machines=max_number_of_machines, |
| 78 | description=description).id |
| 79 | |
| 80 | |
| 81 | def modify_atomic_group(id, **data): |
| 82 | models.AtomicGroup.smart_get(id).update_object(data) |
| 83 | |
| 84 | |
| 85 | def delete_atomic_group(id): |
| 86 | models.AtomicGroup.smart_get(id).delete() |
| 87 | |
| 88 | |
| 89 | def atomic_group_add_labels(id, labels): |
| 90 | label_objs = models.Label.smart_get_bulk(labels) |
| 91 | models.AtomicGroup.smart_get(id).label_set.add(*label_objs) |
| 92 | |
| 93 | |
| 94 | def atomic_group_remove_labels(id, labels): |
| 95 | label_objs = models.Label.smart_get_bulk(labels) |
| 96 | models.AtomicGroup.smart_get(id).label_set.remove(*label_objs) |
| 97 | |
| 98 | |
| 99 | def get_atomic_groups(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 100 | return rpc_utils.prepare_for_serialization( |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 101 | models.AtomicGroup.list_objects(filter_data)) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | # hosts |
| 105 | |
showard | df06256 | 2008-07-03 19:56:37 +0000 | [diff] [blame] | 106 | def add_host(hostname, status=None, locked=None, protection=None): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 107 | return models.Host.add_object(hostname=hostname, status=status, |
showard | df06256 | 2008-07-03 19:56:37 +0000 | [diff] [blame] | 108 | locked=locked, protection=protection).id |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 109 | |
| 110 | |
| 111 | def modify_host(id, **data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 112 | models.Host.smart_get(id).update_object(data) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 113 | |
| 114 | |
| 115 | def host_add_labels(id, labels): |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 116 | labels = models.Label.smart_get_bulk(labels) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 117 | models.Host.smart_get(id).labels.add(*labels) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 118 | |
| 119 | |
| 120 | def host_remove_labels(id, labels): |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 121 | labels = models.Label.smart_get_bulk(labels) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 122 | models.Host.smart_get(id).labels.remove(*labels) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 123 | |
| 124 | |
| 125 | def delete_host(id): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 126 | models.Host.smart_get(id).delete() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 127 | |
| 128 | |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 129 | def get_hosts(multiple_labels=[], exclude_only_if_needed_labels=False, |
| 130 | **filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 131 | """\ |
| 132 | multiple_labels: match hosts in all of the labels given. Should be a |
| 133 | list of label names. |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 134 | exclude_only_if_needed_labels: exclude hosts with at least one |
| 135 | "only_if_needed" label applied. |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 136 | """ |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 137 | hosts = rpc_utils.get_host_query(multiple_labels, |
| 138 | exclude_only_if_needed_labels, |
| 139 | filter_data) |
| 140 | host_dicts = [] |
| 141 | for host_obj in hosts: |
| 142 | host_dict = host_obj.get_object_dict() |
| 143 | host_dict['labels'] = [label.name for label in host_obj.labels.all()] |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 144 | platform = host_obj.platform() |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 145 | host_dict['platform'] = platform and platform.name or None |
showard | d04b4b6 | 2009-04-27 20:12:00 +0000 | [diff] [blame] | 146 | host_dict['acls'] = [acl.name for acl in host_obj.aclgroup_set.all()] |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 147 | host_dicts.append(host_dict) |
| 148 | return rpc_utils.prepare_for_serialization(host_dicts) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 149 | |
| 150 | |
showard | 43a3d26 | 2008-11-12 18:17:05 +0000 | [diff] [blame] | 151 | def get_num_hosts(multiple_labels=[], exclude_only_if_needed_labels=False, |
| 152 | **filter_data): |
| 153 | hosts = rpc_utils.get_host_query(multiple_labels, |
| 154 | exclude_only_if_needed_labels, |
| 155 | filter_data) |
| 156 | return hosts.count() |
showard | 1385b16 | 2008-03-13 15:59:40 +0000 | [diff] [blame] | 157 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 158 | |
| 159 | # tests |
| 160 | |
showard | 909c7a6 | 2008-07-15 21:52:38 +0000 | [diff] [blame] | 161 | def add_test(name, test_type, path, author=None, dependencies=None, |
showard | 3d9899a | 2008-07-31 02:11:58 +0000 | [diff] [blame] | 162 | experimental=True, run_verify=None, test_class=None, |
showard | 909c7a6 | 2008-07-15 21:52:38 +0000 | [diff] [blame] | 163 | test_time=None, test_category=None, description=None, |
| 164 | sync_count=1): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 165 | return models.Test.add_object(name=name, test_type=test_type, path=path, |
showard | 909c7a6 | 2008-07-15 21:52:38 +0000 | [diff] [blame] | 166 | author=author, dependencies=dependencies, |
| 167 | experimental=experimental, |
| 168 | run_verify=run_verify, test_time=test_time, |
| 169 | test_category=test_category, |
| 170 | sync_count=sync_count, |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 171 | test_class=test_class, |
| 172 | description=description).id |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 173 | |
| 174 | |
| 175 | def modify_test(id, **data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 176 | models.Test.smart_get(id).update_object(data) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 177 | |
| 178 | |
| 179 | def delete_test(id): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 180 | models.Test.smart_get(id).delete() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 181 | |
| 182 | |
| 183 | def get_tests(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 184 | return rpc_utils.prepare_for_serialization( |
| 185 | models.Test.list_objects(filter_data)) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 186 | |
| 187 | |
showard | 2b9a88b | 2008-06-13 20:55:03 +0000 | [diff] [blame] | 188 | # profilers |
| 189 | |
| 190 | def add_profiler(name, description=None): |
| 191 | return models.Profiler.add_object(name=name, description=description).id |
| 192 | |
| 193 | |
| 194 | def modify_profiler(id, **data): |
| 195 | models.Profiler.smart_get(id).update_object(data) |
| 196 | |
| 197 | |
| 198 | def delete_profiler(id): |
| 199 | models.Profiler.smart_get(id).delete() |
| 200 | |
| 201 | |
| 202 | def get_profilers(**filter_data): |
| 203 | return rpc_utils.prepare_for_serialization( |
| 204 | models.Profiler.list_objects(filter_data)) |
| 205 | |
| 206 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 207 | # users |
| 208 | |
| 209 | def add_user(login, access_level=None): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 210 | return models.User.add_object(login=login, access_level=access_level).id |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 211 | |
| 212 | |
| 213 | def modify_user(id, **data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 214 | models.User.smart_get(id).update_object(data) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 215 | |
| 216 | |
| 217 | def delete_user(id): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 218 | models.User.smart_get(id).delete() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 219 | |
| 220 | |
| 221 | def get_users(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 222 | return rpc_utils.prepare_for_serialization( |
| 223 | models.User.list_objects(filter_data)) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 224 | |
| 225 | |
| 226 | # acl groups |
| 227 | |
| 228 | def add_acl_group(name, description=None): |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 229 | group = models.AclGroup.add_object(name=name, description=description) |
| 230 | group.users.add(thread_local.get_user()) |
| 231 | return group.id |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 232 | |
| 233 | |
| 234 | def modify_acl_group(id, **data): |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 235 | group = models.AclGroup.smart_get(id) |
| 236 | group.check_for_acl_violation_acl_group() |
| 237 | group.update_object(data) |
| 238 | group.add_current_user_if_empty() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 239 | |
| 240 | |
| 241 | def acl_group_add_users(id, users): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 242 | group = models.AclGroup.smart_get(id) |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 243 | group.check_for_acl_violation_acl_group() |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 244 | users = models.User.smart_get_bulk(users) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 245 | group.users.add(*users) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 246 | |
| 247 | |
| 248 | def acl_group_remove_users(id, users): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 249 | group = models.AclGroup.smart_get(id) |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 250 | group.check_for_acl_violation_acl_group() |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 251 | users = models.User.smart_get_bulk(users) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 252 | group.users.remove(*users) |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 253 | group.add_current_user_if_empty() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 254 | |
| 255 | |
| 256 | def acl_group_add_hosts(id, hosts): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 257 | group = models.AclGroup.smart_get(id) |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 258 | group.check_for_acl_violation_acl_group() |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 259 | hosts = models.Host.smart_get_bulk(hosts) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 260 | group.hosts.add(*hosts) |
showard | 08f981b | 2008-06-24 21:59:03 +0000 | [diff] [blame] | 261 | group.on_host_membership_change() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 262 | |
| 263 | |
| 264 | def acl_group_remove_hosts(id, hosts): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 265 | group = models.AclGroup.smart_get(id) |
showard | 04f2cd8 | 2008-07-25 20:53:31 +0000 | [diff] [blame] | 266 | group.check_for_acl_violation_acl_group() |
showard | be3ec04 | 2008-11-12 18:16:07 +0000 | [diff] [blame] | 267 | hosts = models.Host.smart_get_bulk(hosts) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 268 | group.hosts.remove(*hosts) |
showard | 08f981b | 2008-06-24 21:59:03 +0000 | [diff] [blame] | 269 | group.on_host_membership_change() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 270 | |
| 271 | |
| 272 | def delete_acl_group(id): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 273 | models.AclGroup.smart_get(id).delete() |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 274 | |
| 275 | |
| 276 | def get_acl_groups(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 277 | acl_groups = models.AclGroup.list_objects(filter_data) |
| 278 | for acl_group in acl_groups: |
| 279 | acl_group_obj = models.AclGroup.objects.get(id=acl_group['id']) |
| 280 | acl_group['users'] = [user.login |
| 281 | for user in acl_group_obj.users.all()] |
| 282 | acl_group['hosts'] = [host.hostname |
| 283 | for host in acl_group_obj.hosts.all()] |
| 284 | return rpc_utils.prepare_for_serialization(acl_groups) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 285 | |
| 286 | |
| 287 | # jobs |
| 288 | |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 289 | def generate_control_file(tests=(), kernel=None, label=None, profilers=(), |
| 290 | client_control_file='', use_container=False): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 291 | """ |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 292 | Generates a client-side control file to load a kernel and run tests. |
| 293 | |
| 294 | @param tests List of tests to run. |
| 295 | @param kernel Kernel to install in generated control file. |
| 296 | @param label Name of label to grab kernel config from. |
| 297 | @param profilers List of profilers to activate during the job. |
| 298 | @param client_control_file The contents of a client-side control file to |
| 299 | run at the end of all tests. If this is supplied, all tests must be |
| 300 | client side. |
| 301 | TODO: in the future we should support server control files directly |
| 302 | to wrap with a kernel. That'll require changing the parameter |
| 303 | name and adding a boolean to indicate if it is a client or server |
| 304 | control file. |
| 305 | @param use_container unused argument today. TODO: Enable containers |
| 306 | on the host during a client side test. |
| 307 | |
| 308 | @returns a dict with the following keys: |
| 309 | control_file: str, The control file text. |
| 310 | is_server: bool, is the control file a server-side control file? |
| 311 | synch_count: How many machines the job uses per autoserv execution. |
| 312 | synch_count == 1 means the job is asynchronous. |
| 313 | dependencies: A list of the names of labels on which the job depends. |
| 314 | """ |
| 315 | if not tests and not control_file: |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 316 | return dict(control_file='', is_server=False, synch_count=1, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 317 | dependencies=[]) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 318 | |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 319 | cf_info, test_objects, profiler_objects, label = ( |
showard | 2b9a88b | 2008-06-13 20:55:03 +0000 | [diff] [blame] | 320 | rpc_utils.prepare_generate_control_file(tests, kernel, label, |
| 321 | profilers)) |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 322 | cf_info['control_file'] = control_file.generate_control( |
| 323 | tests=test_objects, kernel=kernel, platform=label, |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 324 | profilers=profiler_objects, is_server=cf_info['is_server'], |
| 325 | client_control_file=client_control_file) |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 326 | return cf_info |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 327 | |
| 328 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 329 | def create_job(name, priority, control_file, control_type, is_template=False, |
| 330 | timeout=None, synch_count=None, hosts=(), meta_hosts=(), |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 331 | run_verify=True, one_time_hosts=(), email_list='', |
| 332 | dependencies=(), reboot_before=None, reboot_after=None, |
| 333 | atomic_group_name=None): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 334 | """\ |
| 335 | Create and enqueue a job. |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 336 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 337 | priority: Low, Medium, High, Urgent |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 338 | control_file: String contents of the control file. |
| 339 | control_type: Type of control file, Client or Server. |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 340 | is_template: If true then create a template job. |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 341 | timeout: Hours after this call returns until the job times out. |
| 342 | synch_count: How many machines the job uses per autoserv execution. |
| 343 | synch_count == 1 means the job is asynchronous. If an |
| 344 | atomic group is given this value is treated as a minimum. |
| 345 | hosts: List of hosts to run job on. |
| 346 | meta_hosts: List where each entry is a label name, and for each entry |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 347 | one host will be chosen from that label to run the job |
| 348 | on. |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 349 | run_verify: Should the host be verified before running the test? |
| 350 | one_time_hosts: List of hosts not in the database to run the job on. |
| 351 | email_list: String containing emails to mail when the job is done |
| 352 | dependencies: List of label names on which this job depends |
mbligh | 94ae6d6 | 2009-02-03 17:47:49 +0000 | [diff] [blame] | 353 | reboot_before: Never, If dirty, or Always |
| 354 | reboot_after: Never, If all tests passed, or Always |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 355 | atomic_group_name: The name of an atomic group to schedule the job on. |
| 356 | |
| 357 | @returns The created Job id number. |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 358 | """ |
showard | 3bb499f | 2008-07-03 19:42:20 +0000 | [diff] [blame] | 359 | |
| 360 | if timeout is None: |
| 361 | timeout=global_config.global_config.get_config_value( |
| 362 | 'AUTOTEST_WEB', 'job_timeout_default') |
| 363 | |
showard | ff90138 | 2008-07-07 23:22:16 +0000 | [diff] [blame] | 364 | owner = thread_local.get_user().login |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 365 | # input validation |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 366 | if not (hosts or meta_hosts or one_time_hosts or atomic_group_name): |
mbligh | ec5546d | 2008-06-16 16:51:28 +0000 | [diff] [blame] | 367 | raise model_logic.ValidationError({ |
showard | b8471e3 | 2008-07-03 19:51:08 +0000 | [diff] [blame] | 368 | 'arguments' : "You must pass at least one of 'hosts', " |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 369 | "'meta_hosts', 'one_time_hosts', " |
| 370 | "or 'atomic_group_name'" |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 371 | }) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 372 | |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 373 | # Create and sanity check an AtomicGroup object if requested. |
| 374 | if atomic_group_name: |
| 375 | if one_time_hosts: |
| 376 | raise model_logic.ValidationError( |
| 377 | {'one_time_hosts': |
| 378 | 'One time hosts cannot be used with an Atomic Group.'}) |
| 379 | atomic_group = models.AtomicGroup.smart_get(atomic_group_name) |
| 380 | if synch_count and synch_count > atomic_group.max_number_of_machines: |
| 381 | raise model_logic.ValidationError( |
| 382 | {'atomic_group_name' : |
| 383 | 'You have requested a synch_count (%d) greater than the ' |
| 384 | 'maximum machines in the requested Atomic Group (%d).' % |
| 385 | (synch_count, atomic_group.max_number_of_machines)}) |
| 386 | else: |
| 387 | atomic_group = None |
| 388 | |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 389 | labels_by_name = dict((label.name, label) |
| 390 | for label in models.Label.objects.all()) |
showard | ba87290 | 2008-06-28 00:51:08 +0000 | [diff] [blame] | 391 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 392 | # convert hostnames & meta hosts to host/label objects |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 393 | host_objects = models.Host.smart_get_bulk(hosts) |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 394 | metahost_objects = [] |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 395 | for label in meta_hosts or []: |
showard | 25087ac | 2008-11-24 22:12:03 +0000 | [diff] [blame] | 396 | if label not in labels_by_name: |
| 397 | raise model_logic.ValidationError( |
| 398 | {'meta_hosts' : 'Label "%s" not found' % label}) |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 399 | this_label = labels_by_name[label] |
| 400 | metahost_objects.append(this_label) |
showard | b8471e3 | 2008-07-03 19:51:08 +0000 | [diff] [blame] | 401 | for host in one_time_hosts or []: |
| 402 | this_host = models.Host.create_one_time_host(host) |
| 403 | host_objects.append(this_host) |
showard | ba87290 | 2008-06-28 00:51:08 +0000 | [diff] [blame] | 404 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 405 | return rpc_utils.create_new_job(owner=owner, |
| 406 | host_objects=host_objects, |
| 407 | metahost_objects=metahost_objects, |
| 408 | name=name, |
| 409 | priority=priority, |
| 410 | control_file=control_file, |
| 411 | control_type=control_type, |
| 412 | is_template=is_template, |
| 413 | synch_count=synch_count, |
| 414 | timeout=timeout, |
| 415 | run_verify=run_verify, |
| 416 | email_list=email_list, |
| 417 | dependencies=dependencies, |
| 418 | reboot_before=reboot_before, |
| 419 | reboot_after=reboot_after, |
| 420 | atomic_group=atomic_group) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 421 | |
| 422 | |
showard | 9dbdcda | 2008-10-14 17:34:36 +0000 | [diff] [blame] | 423 | def abort_host_queue_entries(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 424 | """\ |
showard | 9dbdcda | 2008-10-14 17:34:36 +0000 | [diff] [blame] | 425 | Abort a set of host queue entries. |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 426 | """ |
showard | 9dbdcda | 2008-10-14 17:34:36 +0000 | [diff] [blame] | 427 | query = models.HostQueueEntry.query_objects(filter_data) |
showard | 0c18519 | 2009-01-16 03:07:57 +0000 | [diff] [blame] | 428 | query = query.filter(complete=False) |
showard | dc81751 | 2008-11-12 18:16:41 +0000 | [diff] [blame] | 429 | models.AclGroup.check_abort_permissions(query) |
showard | 9dbdcda | 2008-10-14 17:34:36 +0000 | [diff] [blame] | 430 | host_queue_entries = list(query.select_related()) |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 431 | rpc_utils.check_abort_synchronous_jobs(host_queue_entries) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 432 | |
showard | 9dbdcda | 2008-10-14 17:34:36 +0000 | [diff] [blame] | 433 | user = thread_local.get_user() |
| 434 | for queue_entry in host_queue_entries: |
| 435 | queue_entry.abort(user) |
showard | 9d821ab | 2008-07-11 16:54:29 +0000 | [diff] [blame] | 436 | |
| 437 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 438 | def get_jobs(not_yet_run=False, running=False, finished=False, **filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 439 | """\ |
| 440 | Extra filter args for get_jobs: |
| 441 | -not_yet_run: Include only jobs that have not yet started running. |
| 442 | -running: Include only jobs that have start running but for which not |
| 443 | all hosts have completed. |
| 444 | -finished: Include only jobs for which all hosts have completed (or |
| 445 | aborted). |
| 446 | At most one of these three fields should be specified. |
| 447 | """ |
| 448 | filter_data['extra_args'] = rpc_utils.extra_job_filters(not_yet_run, |
| 449 | running, |
| 450 | finished) |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 451 | jobs = models.Job.list_objects(filter_data) |
| 452 | models.Job.objects.populate_dependencies(jobs) |
| 453 | return rpc_utils.prepare_for_serialization(jobs) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 454 | |
| 455 | |
| 456 | def get_num_jobs(not_yet_run=False, running=False, finished=False, |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 457 | **filter_data): |
| 458 | """\ |
| 459 | See get_jobs() for documentation of extra filter parameters. |
| 460 | """ |
| 461 | filter_data['extra_args'] = rpc_utils.extra_job_filters(not_yet_run, |
| 462 | running, |
| 463 | finished) |
| 464 | return models.Job.query_count(filter_data) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 465 | |
| 466 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 467 | def get_jobs_summary(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 468 | """\ |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 469 | Like get_jobs(), but adds a 'status_counts' field, which is a dictionary |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 470 | mapping status strings to the number of hosts currently with that |
| 471 | status, i.e. {'Queued' : 4, 'Running' : 2}. |
| 472 | """ |
| 473 | jobs = get_jobs(**filter_data) |
| 474 | ids = [job['id'] for job in jobs] |
| 475 | all_status_counts = models.Job.objects.get_status_counts(ids) |
| 476 | for job in jobs: |
| 477 | job['status_counts'] = all_status_counts[job['id']] |
| 478 | return rpc_utils.prepare_for_serialization(jobs) |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 479 | |
| 480 | |
showard | 945072f | 2008-09-03 20:34:59 +0000 | [diff] [blame] | 481 | def get_info_for_clone(id, preserve_metahosts): |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 482 | """\ |
| 483 | Retrieves all the information needed to clone a job. |
| 484 | """ |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 485 | |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 486 | job = models.Job.objects.get(id=id) |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 487 | job_info = rpc_utils.get_job_info(job, |
| 488 | preserve_metahosts=preserve_metahosts) |
showard | 945072f | 2008-09-03 20:34:59 +0000 | [diff] [blame] | 489 | |
showard | d9992fe | 2008-07-31 02:15:03 +0000 | [diff] [blame] | 490 | host_dicts = [] |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 491 | for host in job_info['hosts']: |
| 492 | host_dict = get_hosts(id=host.id)[0] |
| 493 | other_labels = host_dict['labels'] |
| 494 | if host_dict['platform']: |
| 495 | other_labels.remove(host_dict['platform']) |
| 496 | host_dict['other_labels'] = ', '.join(other_labels) |
showard | d9992fe | 2008-07-31 02:15:03 +0000 | [diff] [blame] | 497 | host_dicts.append(host_dict) |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 498 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 499 | for host in job_info['one_time_hosts']: |
| 500 | host_dict = dict(hostname=host.hostname, |
| 501 | id=host.id, |
| 502 | platform='(one-time host)', |
| 503 | locked_text='') |
| 504 | host_dicts.append(host_dict) |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 505 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 506 | # convert keys from Label objects to strings (names of labels |
| 507 | meta_host_counts = dict((meta_host.name, count) for meta_host, count |
| 508 | in job_info['meta_host_counts']) |
| 509 | |
| 510 | info = dict(job=job.get_object_dict(), |
| 511 | meta_host_counts=meta_host_counts, |
| 512 | hosts=host_dicts) |
| 513 | info['job']['dependencies'] = job_info['dependencies'] |
| 514 | if job_info['atomic_group']: |
| 515 | info['atomic_group_name'] = (job_info['atomic_group']).name |
| 516 | else: |
| 517 | info['atomic_group_name'] = None |
showard | a8709c5 | 2008-07-03 19:44:54 +0000 | [diff] [blame] | 518 | |
| 519 | return rpc_utils.prepare_for_serialization(info) |
| 520 | |
| 521 | |
showard | 34dc5fa | 2008-04-24 20:58:40 +0000 | [diff] [blame] | 522 | # host queue entries |
| 523 | |
| 524 | def get_host_queue_entries(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 525 | """\ |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 526 | @returns A sequence of nested dictionaries of host and job information. |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 527 | """ |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 528 | return rpc_utils.prepare_rows_as_nested_dicts( |
| 529 | models.HostQueueEntry.query_objects(filter_data), |
| 530 | ('host', 'atomic_group', 'job')) |
showard | 34dc5fa | 2008-04-24 20:58:40 +0000 | [diff] [blame] | 531 | |
| 532 | |
| 533 | def get_num_host_queue_entries(**filter_data): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 534 | """\ |
| 535 | Get the number of host queue entries associated with this job. |
| 536 | """ |
| 537 | return models.HostQueueEntry.query_count(filter_data) |
showard | 34dc5fa | 2008-04-24 20:58:40 +0000 | [diff] [blame] | 538 | |
| 539 | |
showard | 1e935f1 | 2008-07-11 00:11:36 +0000 | [diff] [blame] | 540 | def get_hqe_percentage_complete(**filter_data): |
| 541 | """ |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 542 | Computes the fraction of host queue entries matching the given filter data |
showard | 1e935f1 | 2008-07-11 00:11:36 +0000 | [diff] [blame] | 543 | that are complete. |
| 544 | """ |
| 545 | query = models.HostQueueEntry.query_objects(filter_data) |
| 546 | complete_count = query.filter(complete=True).count() |
| 547 | total_count = query.count() |
| 548 | if total_count == 0: |
| 549 | return 1 |
| 550 | return float(complete_count) / total_count |
| 551 | |
| 552 | |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 553 | # recurring run |
| 554 | |
| 555 | def get_recurring(**filter_data): |
| 556 | return rpc_utils.prepare_rows_as_nested_dicts( |
| 557 | models.RecurringRun.query_objects(filter_data), |
| 558 | ('job', 'owner')) |
| 559 | |
| 560 | |
| 561 | def get_num_recurring(**filter_data): |
| 562 | return models.RecurringRun.query_count(filter_data) |
| 563 | |
| 564 | |
| 565 | def delete_recurring_runs(**filter_data): |
| 566 | to_delete = models.RecurringRun.query_objects(filter_data) |
| 567 | to_delete.delete() |
| 568 | |
| 569 | |
| 570 | def create_recurring_run(job_id, start_date, loop_period, loop_count): |
| 571 | owner = thread_local.get_user().login |
| 572 | job = models.Job.objects.get(id=job_id) |
| 573 | return job.create_recurring_job(start_date=start_date, |
| 574 | loop_period=loop_period, |
| 575 | loop_count=loop_count, |
| 576 | owner=owner) |
| 577 | |
| 578 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 579 | # other |
| 580 | |
showard | e0b6362 | 2008-08-04 20:58:47 +0000 | [diff] [blame] | 581 | def echo(data=""): |
| 582 | """\ |
| 583 | Returns a passed in string. For doing a basic test to see if RPC calls |
| 584 | can successfully be made. |
| 585 | """ |
| 586 | return data |
| 587 | |
| 588 | |
showard | b7a52fd | 2009-04-27 20:10:56 +0000 | [diff] [blame] | 589 | def get_motd(): |
| 590 | """\ |
| 591 | Returns the message of the day as a string. |
| 592 | """ |
| 593 | return rpc_utils.get_motd() |
| 594 | |
| 595 | |
mbligh | e8819cd | 2008-02-15 16:48:40 +0000 | [diff] [blame] | 596 | def get_static_data(): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 597 | """\ |
| 598 | Returns a dictionary containing a bunch of data that shouldn't change |
| 599 | often and is otherwise inaccessible. This includes: |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 600 | |
| 601 | priorities: List of job priority choices. |
| 602 | default_priority: Default priority value for new jobs. |
| 603 | users: Sorted list of all users. |
| 604 | labels: Sorted list of all labels. |
| 605 | atomic_groups: Sorted list of all atomic groups. |
| 606 | tests: Sorted list of all tests. |
| 607 | profilers: Sorted list of all profilers. |
| 608 | current_user: Logged-in username. |
| 609 | host_statuses: Sorted list of possible Host statuses. |
| 610 | job_statuses: Sorted list of possible HostQueueEntry statuses. |
| 611 | job_timeout_default: The default job timeout length in hours. |
| 612 | reboot_before_options: A list of valid RebootBefore string enums. |
| 613 | reboot_after_options: A list of valid RebootAfter string enums. |
| 614 | motd: Server's message of the day. |
| 615 | status_dictionary: A mapping from one word job status names to a more |
| 616 | informative description. |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 617 | """ |
showard | 21baa45 | 2008-10-21 00:08:39 +0000 | [diff] [blame] | 618 | |
| 619 | job_fields = models.Job.get_field_dict() |
| 620 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 621 | result = {} |
| 622 | result['priorities'] = models.Job.Priority.choices() |
showard | 21baa45 | 2008-10-21 00:08:39 +0000 | [diff] [blame] | 623 | default_priority = job_fields['priority'].default |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 624 | default_string = models.Job.Priority.get_string(default_priority) |
| 625 | result['default_priority'] = default_string |
| 626 | result['users'] = get_users(sort_by=['login']) |
| 627 | result['labels'] = get_labels(sort_by=['-platform', 'name']) |
showard | c92da83 | 2009-04-07 18:14:34 +0000 | [diff] [blame] | 628 | result['atomic_groups'] = get_atomic_groups(sort_by=['name']) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 629 | result['tests'] = get_tests(sort_by=['name']) |
showard | 2b9a88b | 2008-06-13 20:55:03 +0000 | [diff] [blame] | 630 | result['profilers'] = get_profilers(sort_by=['name']) |
showard | 0fc3830 | 2008-10-23 00:44:07 +0000 | [diff] [blame] | 631 | result['current_user'] = rpc_utils.prepare_for_serialization( |
| 632 | thread_local.get_user().get_object_dict()) |
showard | 2b9a88b | 2008-06-13 20:55:03 +0000 | [diff] [blame] | 633 | result['host_statuses'] = sorted(models.Host.Status.names) |
mbligh | 5a198b9 | 2008-12-11 19:33:29 +0000 | [diff] [blame] | 634 | result['job_statuses'] = sorted(models.HostQueueEntry.Status.names) |
showard | b1e5187 | 2008-10-07 11:08:18 +0000 | [diff] [blame] | 635 | result['job_timeout_default'] = models.Job.DEFAULT_TIMEOUT |
showard | 0fc3830 | 2008-10-23 00:44:07 +0000 | [diff] [blame] | 636 | result['reboot_before_options'] = models.RebootBefore.names |
| 637 | result['reboot_after_options'] = models.RebootAfter.names |
showard | 8fbae65 | 2009-01-20 23:23:10 +0000 | [diff] [blame] | 638 | result['motd'] = rpc_utils.get_motd() |
showard | 8ac29b4 | 2008-07-17 17:01:55 +0000 | [diff] [blame] | 639 | |
showard | d3dc199 | 2009-04-22 21:01:40 +0000 | [diff] [blame] | 640 | result['status_dictionary'] = {"Aborted": "Aborted", |
showard | 8ac29b4 | 2008-07-17 17:01:55 +0000 | [diff] [blame] | 641 | "Verifying": "Verifying Host", |
| 642 | "Pending": "Waiting on other hosts", |
| 643 | "Running": "Running autoserv", |
| 644 | "Completed": "Autoserv completed", |
| 645 | "Failed": "Failed to complete", |
showard | d823b36 | 2008-07-24 16:35:46 +0000 | [diff] [blame] | 646 | "Queued": "Queued", |
showard | 5deb677 | 2008-11-04 21:54:33 +0000 | [diff] [blame] | 647 | "Starting": "Next in host's queue", |
| 648 | "Stopped": "Other host(s) failed verify", |
showard | d3dc199 | 2009-04-22 21:01:40 +0000 | [diff] [blame] | 649 | "Parsing": "Awaiting parse of final results", |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 650 | "Gathering": "Gathering log files", |
| 651 | "Template": "Template job for recurring run"} |
| 652 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 653 | return result |
showard | 29f7cd2 | 2009-04-29 21:16:24 +0000 | [diff] [blame] | 654 | |
| 655 | |
| 656 | def get_server_time(): |
| 657 | return datetime.datetime.now().strftime("%Y-%m-%d %H:%M") |