blob: a1823c654c9db09045b22cb84fadf1accf800b72 [file] [log] [blame]
Alex Miller0516e4c2013-06-03 18:07:48 -07001# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6from autotest_lib.client.common_lib import utils
7from autotest_lib.server.cros import provision
8
9
10# provision_labels should be a string like "name:setting,name:setting"
11# non-provisionable labels are currently skipped, so they're safe to pass in.
12# However, this is more of a current safeguard/leftover from some shady code in
13# the proof of concept, so I don't assure that passing in non-provisionable
14# labels will always be an okay and accepted thing to do.
15provision_labels = locals().get('provision_labels') or ','.join(args)
16
17
18def provision_machine(machine):
19 """
20 Run the appropriate provisioning tests to make the machine's labels match
21 those given in provision_labels.
22 """
23 host = hosts.create_host(machine)
24
25 labels_list = provision_labels.split(',')
26 fixed, provisionable = provision.filter_labels(labels_list)
27
28 job.record('START', None, 'provision')
29 for label in fixed:
30 job.record('INFO', None, 'provision',
31 "Can't provision label '%s'. Skipping." % label)
32
33 try:
34 for name, value in provision.split_labels(provisionable).items():
35 test = provision.provisioner_for(name)
36 # sysinfo isn't really going to get us anything incredibly
37 # interesting here, and it takes a non-trivial amount of time, so
38 # we might as well just turn it off.
39 job.run_test(test, host=host, value=value, disable_sysinfo=True)
40 except Exception as e:
41 job.record('END FAIL', None, 'provision',
42 'Failed on %s with: %s' % (machine, e))
43 else:
44 job.record('END GOOD', None, 'provision',
45 '%s provisioned successfully' % machine)
46
47
48job.parallel_simple(provision_machine, machines)
49
50# vim: set syntax=python :