blob: 07524dce926e9f8d305aa2715880a7d838f4b69e [file] [log] [blame]
Ian Lee318c7f22020-01-13 12:36:44 -08001# Copyright 2019 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
5import logging
6
7def bluetooth(hosts):
8 """Check for missing bluetooth hardware.
9 """
Kazuhiro Inaba4fa47ab2020-02-03 12:33:33 +090010 # TODO(ianrlee): Reenable, once a nice check is found in b/148621587.
11 #for host in hosts:
12 # output = host.run('hcitool dev').stdout
13 # lines = output.splitlines()
14 # if len(lines) < 2 or not lines[0].startswith('Devices:'):
15 # return False, 'Failed: Bluetooth device is missing.'\
16 # 'Stdout of the command "hcitool dev1"'\
17 # 'on host %s was %s' % (host, output)
Ian Lee318c7f22020-01-13 12:36:44 -080018 return True, ''
19
20
21def region_us(hosts):
22 """Check that region is set to "us".
23 """
24 for host in hosts:
25 output = host.run('vpd -g region').stdout
Kazuhiro Inabab90e2482020-01-24 14:07:32 +090026 if output != 'us':
Ian Lee318c7f22020-01-13 12:36:44 -080027 return False, 'Failed: Region is not "us".'\
28 'Stdout of the command "vpd -l'\
29 '| grep region" on host %s was %s'\
30 % (host, output)
31 return True, ''
32
33prerequisite_map = {
34 'bluetooth': bluetooth,
35 'region_us': region_us,
36}
37
38def check(prereq, hosts):
39 """Execute the prerequisite check.
40
41 @return boolean indicating if check passes.
42 @return string error message if check fails.
43 """
44 if prereq not in prerequisite_map:
45 logging.info('%s is not a valid prerequisite.', prereq)
46 return True, ''
47 return prerequisite_map[prereq](hosts)