summaryrefslogtreecommitdiff
path: root/roles/colo-console-server/files/serial-connect-dl320
blob: 2c18003e7e669adb9628555f340d0ba1072457c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python

# DO NOT EDIT! MANAGED BY ANSIBLE

import argparse
import os
import sys

DEVICES = {
    # t1
    't1-p1': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.1/1-1.2.1:1.0',
    't1-p2': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0',
    't1-p3': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.1/1-1.2.3.1:1.0',  # discoverable but broke
    't1-p4': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.2/1-1.2.3.2:1.0',
    't1-p5': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.3/1-1.2.3.3:1.0',
    't1-p6': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.4/1-1.2.3.4:1.0',
    't1-p7': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.5/1-1.2.3.5:1.0',
    't1-p8': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.6/1-1.2.3.6:1.0',
    't1-p9': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.3/1-1.2.3.7/1-1.2.3.7:1.0',
    't1-p10': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.1/1-1.2.4.1:1.0',
    't1-p11': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.2/1-1.2.4.2:1.0',
    't1-p12': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.3/1-1.2.4.3:1.0',
    't1-p13': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.4/1-1.2.4.4:1.0',
    't1-p14': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.5/1-1.2.4.5:1.0',
    't1-p15': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.6/1-1.2.4.6:1.0',
    't1-p16': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4.7/1-1.2.4.7:1.0',

     # t2
    't2-p1': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0',
    't2-p2': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.2/1-1.3.2:1.0',
    't2-p3': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.1/1-1.3.3.1:1.0',
    't2-p4': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.2/1-1.3.3.2:1.0',
    't2-p5': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.3/1-1.3.3.3:1.0',
    't2-p6': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.4/1-1.3.3.4:1.0',
    't2-p7': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.5/1-1.3.3.5:1.0',
    't2-p8': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.6/1-1.3.3.6:1.0',
    't2-p9': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3.7/1-1.3.3.7:1.0',
    't2-p10': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.1/1-1.3.4.1:1.0',
    't2-p11': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.2/1-1.3.4.2:1.0',
    't2-p12': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.3/1-1.3.4.3:1.0',
    't2-p13': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.4/1-1.3.4.4:1.0',
    't2-p14': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.5/1-1.3.4.5:1.0',
    't2-p15': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.6/1-1.3.4.6:1.0',
    't2-p16': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4.7/1-1.3.4.7:1.0',

    # t3
    't3-p1': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.1/1-1.4.1:1.0',
    't3-p2': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.2/1-1.4.2:1.0',
    't3-p3': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.1/1-1.4.3.1:1.0',
    't3-p4': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.2/1-1.4.3.2:1.0',
    't3-p5': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.3/1-1.4.3.3:1.0',
    't3-p6': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.4/1-1.4.3.4:1.0',
    't3-p7': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.5/1-1.4.3.5:1.0',
    't3-p8': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.6/1-1.4.3.6:1.0',
    't3-p9': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3.7/1-1.4.3.7:1.0',
    't3-p10': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4.1/1-1.4.4.1:1.0',
    't3-p11': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4.2/1-1.4.4.2:1.0',
    't3-p12': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4.5/1-1.4.4.5:1.0',   # broke
    't3-p13': '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4.6/1-1.4.4.6:1.0',   # broke?
}

parser = argparse.ArgumentParser(
    description='connect to a serial console for: %s' % DEVICES.keys())
parser.add_argument('-e', '--escape-key', default='a',
                    help='picocom escape key. default=a')
parser.add_argument('device', help='Device to connect to')

args = parser.parse_args()

if args.device not in DEVICES:
    sys.exit('Invalid device: ' + args.device)

for p in os.listdir(DEVICES[args.device]):
    if p.startswith('ttyUSB'):
        args = ['/usr/bin/sudo', 'picocom', '-e', args.escape_key,
                '-b', '115200', '/dev/' + p]
        os.execv(args[0], args)

sys.exit('ERROR: no usb device found?')