Merge ~rodsmith/plainbox-provider-certification-server:precheck-script-detect-underspeed into plainbox-provider-certification-server:master

Proposed by Rod Smith
Status: Merged
Approved by: Jeff Lane 
Approved revision: d6cb4becfb1006775b83e87899e8a9aea5fa2793
Merged at revision: 3ed6c28989ff299e212ccf00c59d8706e09bff1e
Proposed branch: ~rodsmith/plainbox-provider-certification-server:precheck-script-detect-underspeed
Merge into: plainbox-provider-certification-server:master
Diff against target: 75 lines (+43/-18)
1 file modified
tools/canonical-certification-precheck (+43/-18)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+314573@code.launchpad.net

Description of the change

This MR addresses bug #1566301; it adds code to check for NICs connected at less than their maximum supported speeds (e.g., a 10 Gbps NIC connected to a 1 Gbps switch). This change is added to the existing NICs_enabled test, creating a more verbose output and failures when sub-optimal speeds are detected.

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

Just one minor comment/question inline, but it doesn't block anything. LGTM

review: Approve
Revision history for this message
Rod Smith (rodsmith) wrote :

Concerning the loop -- your way is better. The code evolved from a version where the loop was necessary, but your optimization just didn't occur to me when I made other changes. I'll try to remember it for the next time I work on this script.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/canonical-certification-precheck b/tools/canonical-certification-precheck
2index 3f9f5c6..3e1ec8e 100755
3--- a/tools/canonical-certification-precheck
4+++ b/tools/canonical-certification-precheck
5@@ -372,27 +372,52 @@ else
6 fi
7 }
8
9-# All NICs are enabled
10+# All NICs are enabled and set to maximum speed
11 NICs_enabled(){
12-name="All NICs enabled"
13+name="All NICs enabled and at maximum supported speed"
14 echoname
15-for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|egrep -v "lo|br.|tun.|usb."`
16- do
17- state=$(cat /sys/class/net/$nic/operstate)
18- if [ $state = "up" ]; then
19- echo " Interface $nic is $state"
20- pass
21- elif [ $state = "down" ]; then
22- echo " Interface $nic is $state"
23- nicfail=1
24- elif [ $state = "unknown" ]; then
25- eval info${i}="unknown"
26- warn
27- fi
28+local worst_status=0
29+for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|egrep -v "lo|br.|tun.|usb."`; do
30+ local state=$(cat /sys/class/net/$nic/operstate)
31+ # /sys/class/net/wlan0/speed produces an error and returns nothing,
32+ # so protect against this as a special case.
33+ local current_speed=$(cat /sys/class/net/$nic/speed 2> /dev/null)
34+ if [ -z "$current_speed" ]; then
35+ current_speed=0
36+ fi
37+ local max_speed=0
38+ # current_speed (above) and speed (below) are computed in the same way here as
39+ # in the "network" Checkbox script (give or take bash vs. Python differences).
40+ # If one is changed, the other should be, too.
41+ for speed in $(ethtool $nic 2> /dev/null | egrep '[[:digit:]](base)([A-Z]+)|[[:digit:]](Mb/s)' | \
42+ sed 's/[^0-9 ]*//g' | tr " " "\n" | sort | uniq | sed '/^\s*$/d'); do
43+ if [ $speed -ge $max_speed ]; then
44+ max_speed="$speed"
45+ fi
46+ done
47+ echo -n " Interface $nic is $state"
48+ if [ "$state" != "down" ]; then
49+ echo -n " and running at $current_speed of $max_speed Mbps"
50+ fi
51+ if [ $current_speed -gt 0 ] && [ $current_speed -ge $max_speed ] && [ "$state" == "up" ]; then
52+ echo "; config is OK"
53+ elif ([ $current_speed -eq 0 ] && [ "$state" == "up" ]) || [ "$state" == "unknown" ]; then
54+ echo "; config is UNKNOWN"
55+ let worst_status=$(($worst_status | 1))
56+ else
57+ echo "; config is BAD"
58+ let worst_status=$(($worst_status | 2))
59+ fi
60 done
61-if [ "$nicfail" = "1" ]; then
62- fail
63-fi
64+case "$worst_status" in
65+ 0) pass
66+ ;;
67+ 1) eval info${i}=\"Unknown config\"
68+ warn
69+ ;;
70+ *) fail
71+ ;;
72+esac
73 }
74
75 #### Installed RAM (STG says 4GiB minimum) ###

Subscribers

People subscribed via source and target branches

to all changes: