• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 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, sys
6
7from config import rpm_config
8import rpm_controller
9
10LOGGING_FORMAT = rpm_config.get('GENERAL','logging_format')
11oyster_rpm_name_format = 'chromeos1-rack%d-rpm1'
12atlantis_rpm_name_format = 'chromeos2-row%d-rack%d-rpm1'
13DEFAULT_OYSTERBAY_OUTLET_MAP = {
14    1 : 'host1',
15    2 : 'host2',
16    4 : 'host3',
17    5 : 'host4',
18    7 : 'host5',
19    8 : 'host6',
20    9 : 'host7',
21    10 : 'host8',
22    12 : 'host9',
23    13 : 'host10',
24    15 : 'host11',
25    16 : 'host12'
26}
27DEFAULT_ATLANTIS_OUTLET_MAP = {
28    1 : 'host1',
29    2 : 'host7',
30    4 : 'host2',
31    5 : 'host8',
32    7 : 'host3',
33    8 : 'host9',
34    9 : 'host4',
35    10 : 'host10',
36    12 : 'host5',
37    13 : 'host11',
38    15 : 'host6',
39    16 : 'host12'
40}
41
42
43def setup_rpm(rpm_name):
44    logging.debug('Setting up %s.', rpm_name)
45    rpm = rpm_controller.SentryRPMController(rpm_name)
46    if rpm_name.startswith('chromeos1'):
47        outlet_mapping = DEFAULT_OYSTERBAY_OUTLET_MAP
48    else:
49        outlet_mapping = DEFAULT_ATLANTIS_OUTLET_MAP
50    if not rpm.setup(outlet_mapping):
51        logging.error('Failed to set up %s.', rpm_name)
52
53
54def main():
55    if len(sys.argv) != 2:
56        print 'USAGE: python %s [rpm|atlantis|oyster]' % sys.argv[0]
57        print 'atlantis|oyster: implies all RPMs inside that lab.'
58        return
59    if sys.argv[1] != 'atlantis' and sys.argv[1] != 'oyster':
60        setup_rpm(sys.argv[1])
61        return
62    if sys.argv[1] == 'oyster':
63        logging.debug('Setting up All RPM devices in lab: Oyster Bay.')
64        for rack in range(3,8):
65            setup_rpm(oyster_rpm_name_format % rack)
66        return
67    logging.debug('Setting up All RPM devices in lab: Atlantis.')
68    for row in range(1,6):
69        for rack in range(1,8):
70            if ((row == 1 and rack == 1) or (row == 1 and rack == 2) or
71                (row == 5 and rack == 6) or (row ==5 and rack == 7)):
72                # These RPM's do not follow the normal layout.
73                continue
74            setup_rpm(atlantis_rpm_name_format % (row, rack))
75
76
77if __name__ == '__main__':
78    logging.basicConfig(level=logging.DEBUG, format=LOGGING_FORMAT)
79    main()
80