Merge lp:~mpontillo/maas/discover-serial-ports-during-commissioning into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 5864
Proposed branch: lp:~mpontillo/maas/discover-serial-ports-during-commissioning
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 182 lines (+151/-0)
1 file modified
src/provisioningserver/refresh/node_info_scripts.py (+151/-0)
To merge this branch: bzr merge lp:~mpontillo/maas/discover-serial-ports-during-commissioning
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+319071@code.launchpad.net

Commit message

Add informational commissioning scripts.

 * Adds a commissioning script for support information.
 * Adds a commissioning script to list serial ports.
   - This is intended to help administrators (who are adding headless machines to MAAS) determine how the serial console should be configured.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

I'm actually on the fence about just including the entire contents of this as an informational commissioning script:

https://gist.github.com/mpontillo/ecc30011d6d5889fda23c8e5e3545105

In my mind, the only reason not to is because it overlaps with existing scripts.

But it would be nice, for support purposes, to just be able to tell someone "please give us the output of the "00-maas-99-support-dump" script.

Revision history for this message
Gavin Panella (allenap) wrote :

I think that longer script would be fine to include, probably very useful, but the short one is fine too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/refresh/node_info_scripts.py'
2--- src/provisioningserver/refresh/node_info_scripts.py 2017-03-23 18:20:00 +0000
3+++ src/provisioningserver/refresh/node_info_scripts.py 2017-03-28 05:42:30 +0000
4@@ -97,6 +97,16 @@
5 lscpu -p=cpu,core,socket
6 """)
7
8+SERIAL_PORTS_SCRIPT = dedent("""\
9+ #!/bin/bash
10+ # Do not fail commissioning if this fails.
11+ set +e
12+ find /sys/class/tty/ ! -type d -print0 2> /dev/null \
13+ | xargs -0 readlink -f \
14+ | sort -u
15+ exit 0
16+ """)
17+
18 SRIOV_SCRIPT = dedent("""\
19 #!/bin/sh
20 for file in $(find /sys/devices/ -name sriov_numvfs); do
21@@ -108,6 +118,137 @@
22 done
23 """)
24
25+SUPPORT_SCRIPT = dedent("""\
26+ #!/bin/bash
27+ # Do not fail commissioning if this fails.
28+ set +e
29+ echo "-----BEGIN KERNEL INFO-----"
30+ uname -a
31+ echo "-----END KERNEL INFO-----"
32+ echo ""
33+ echo "-----BEGIN KERNEL COMMAND LINE-----"
34+ cat /proc/cmdline
35+ echo "-----END KERNEL COMMAND LINE-----"
36+ CMDLINE="$(cat /proc/cmdline)"
37+ CLOUD_CONFIG="$(echo $CMDLINE | xargs -n1 echo | grep cloud-config-url)"
38+ URL="$(echo $CLOUD_CONFIG | grep -o http.*)"
39+ if [ "$URL" != "" ]; then
40+ echo ""
41+ echo "-----BEGIN CLOUD CONFIG QUERY-----"
42+ curl -v "$URL" 2>&1
43+ echo "-----END CLOUD CONFIG QUERY-----"
44+ fi
45+ echo ""
46+ echo "-----BEGIN CPU CORE COUNT AND MODEL-----"
47+ cat /proc/cpuinfo | grep '^model name' | cut -d: -f 2- | sort | uniq -c
48+ echo "-----BEGIN CPU CORE COUNT AND MODEL-----"
49+ if [ -x "$(which lspci)" ]; then
50+ echo ""
51+ echo "-----BEGIN PCI INFO-----"
52+ lspci -nnv
53+ echo "-----END PCI INFO-----"
54+ fi
55+ if [ -x "$(which lsusb)" ]; then
56+ echo ""
57+ echo "-----BEGIN USB INFO-----"
58+ lsusb
59+ echo "-----END USB INFO-----"
60+ fi
61+ echo ""
62+ echo "-----BEGIN MODALIASES-----"
63+ find /sys -name modalias -print0 2> /dev/null | xargs -0 cat | sort \
64+ | uniq -c
65+ echo "-----END MODALIASES-----"
66+ echo ""
67+ echo "-----BEGIN SERIAL PORTS-----"
68+ find /sys/class/tty/ ! -type d -print0 2> /dev/null \
69+ | xargs -0 readlink -f \
70+ | sort -u
71+ echo "-----END SERIAL PORTS-----"
72+ echo ""
73+ echo "-----BEGIN NETWORK INTERFACES-----"
74+ ip -o link
75+ echo "-----END NETWORK INTERFACES-----"
76+ if [ -x "$(which lsblk)" ]; then
77+ echo ""
78+ echo "-----BEGIN BLOCK DEVICE SUMMARY-----"
79+ lsblk
80+ echo "-----END BLOCK DEVICE SUMMARY-----"
81+ fi
82+ # The remainder of this script only runs as root (during commissioning).
83+ if [ "$(id -u)" != "0" ]; then
84+ exit 0
85+ fi
86+ if [ -x "$(which lsblk)" ]; then
87+ echo ""
88+ echo "-----BEGIN DETAILED BLOCK DEVICE INFO-----"
89+ # Note: excluding ramdisks, floppy drives, and loopback devices.
90+ lsblk --exclude 1,2,7 -d -P -x MAJ:MIN
91+ echo ""
92+ for dev in $(lsblk -n --exclude 1,2,7 --output KNAME); do
93+ echo "$dev:"
94+ udevadm info -q all -n $dev
95+ size64="$(blockdev --getsize64 /dev/$dev 2> /dev/null || echo ?)"
96+ bsz="$(blockdev --getbsz /dev/$dev 2> /dev/null || echo ?)"
97+ echo ""
98+ echo " size64: $size64"
99+ echo " bsz: $bsz"
100+ done
101+ echo ""
102+ # Enumerate the mappings that were generated (by device).
103+ find /dev/disk -type l | xargs ls -ln | awk '{ print $9, $10, $11 }' \
104+ | sort -k2
105+ echo "-----END DETAILED BLOCK DEVICE INFO-----"
106+ fi
107+ if [ -x "$(which dmidecode)" ]; then
108+ DMI_OUTFILE=/root/dmi.bin
109+ echo ""
110+ dmidecode -u --dump-bin $DMI_OUTFILE && (
111+ echo "-----BEGIN DMI DATA-----" ;
112+ base64 $DMI_OUTFILE
113+ echo "-----END DMI DATA-----"
114+ ) || (echo "Unable to read DMI information."; exit 0)
115+ echo ""
116+ echo "-----BEGIN FULL DMI DECODE-----"
117+ dmidecode -u --from-dump $DMI_OUTFILE
118+ echo "-----END FULL DMI DECODE-----"
119+ # via http://git.savannah.nongnu.org/cgit/dmidecode.git/tree/dmiopt.c
120+ DMI_STRINGS="
121+ bios-vendor
122+ bios-version
123+ bios-release-date
124+ system-manufacturer
125+ system-product-name
126+ system-version
127+ system-serial-number
128+ system-uuid
129+ baseboard-manufacturer
130+ baseboard-product-name
131+ baseboard-version
132+ baseboard-serial-number
133+ baseboard-asset-tag
134+ chassis-manufacturer
135+ chassis-type
136+ chassis-version
137+ chassis-serial-number
138+ chassis-asset-tag
139+ processor-family
140+ processor-manufacturer
141+ processor-version
142+ processor-frequency
143+ "
144+ echo ""
145+ echo "-----BEGIN DMI KEYPAIRS-----"
146+ for key in $DMI_STRINGS; do
147+ value=$(dmidecode --from-dump $DMI_OUTFILE -s $key)
148+ printf "%s=%s\\n" "$key" "$(echo $value)"
149+ done
150+ echo "-----END DMI KEYPAIRS-----"
151+ fi
152+ # Do not fail commissioning if this fails.
153+ exit 0
154+ """)
155+
156
157 # Run `dhclient` on all the unconfigured interfaces.
158 # This is done to create records in the leases file for the
159@@ -418,6 +559,11 @@
160 # controller isn't running django. On the region controller we set the hooks in
161 # metadataserver/models/commissioningscript.py
162 NODE_INFO_SCRIPTS = OrderedDict([
163+ ('00-maas-00-support-info', {
164+ 'content': SUPPORT_SCRIPT.encode('ascii'),
165+ 'hook': null_hook,
166+ 'run_on_controller': True,
167+ }),
168 (LSHW_OUTPUT_NAME, {
169 'content': LSHW_SCRIPT.encode('ascii'),
170 'hook': null_hook,
171@@ -454,6 +600,11 @@
172 'hook': null_hook,
173 'run_on_controller': True,
174 }),
175+ ('00-maas-08-serial-ports', {
176+ 'content': SERIAL_PORTS_SCRIPT.encode('ascii'),
177+ 'hook': null_hook,
178+ 'run_on_controller': True,
179+ }),
180 ('99-maas-01-wait-for-lldpd', {
181 'content': make_function_call_script(
182 lldpd_wait, "/var/run/lldpd.socket", time_delay=60),