Merge ~bladernr/plainbox-provider-checkbox:1895048-fail-on-carrier-disconnected into plainbox-provider-checkbox:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 10a5beb2ddac5a49e9468408cc2d4b7e12625397
Merged at revision: eeea3b9285f2e3566536f9f578a6321c69ae4484
Proposed branch: ~bladernr/plainbox-provider-checkbox:1895048-fail-on-carrier-disconnected
Merge into: plainbox-provider-checkbox:master
Diff against target: 63 lines (+19/-1)
2 files modified
bin/network_device_info.py (+18/-0)
units/ethernet/jobs.pxu (+1/-1)
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+390510@code.launchpad.net

Description of the change

Add an arg to trigger script fail and list any disconnected devices, if desired. This is to trigger extra review for server as we require all NICs to be connected and configured prior to testing. Original behaviour is preserved.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

LGTM, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/network_device_info.py b/bin/network_device_info.py
2index 925b3f5..bba546b 100755
3--- a/bin/network_device_info.py
4+++ b/bin/network_device_info.py
5@@ -148,6 +148,10 @@ class NetworkDeviceInfo():
6 self._interface_populate()
7
8 @property
9+ def carrier_status(self):
10+ return self._carrier_status
11+
12+ @property
13 def driver(self):
14 return self._driver
15
16@@ -342,9 +346,13 @@ if __name__ == "__main__":
17 help='Don\'t attempt to get info from network manager')
18 parser.add_argument('--interface',
19 help='Restrict info action to specified interface')
20+ parser.add_argument('--fail-on-disconnected', action='store_true',
21+ help=('Script will exit with a non-zero return code if'
22+ ' any interface is not connected'))
23 args = parser.parse_args()
24
25 udev = UdevDevices(args.category)
26+ disconnected_ifaces = []
27
28 # The detect action should indicate presence of a device belonging to the
29 # category and cause the job to fail if none present
30@@ -371,6 +379,8 @@ if __name__ == "__main__":
31 print("[ Devices found by udev ]".center(80, '-'))
32 for device in udev.devices():
33 print(device)
34+ if device.carrier_status == "Disconnected":
35+ disconnected_ifaces.append(device.interface)
36
37 # Attempt to report devices found by NetworkManager. This can be
38 # skipped as doesn't make sense for server installs
39@@ -379,3 +389,11 @@ if __name__ == "__main__":
40 print("[ Devices found by Network Manager ]".center(80, '-'))
41 for device in nm.devices():
42 print(device)
43+
44+ if disconnected_ifaces and args.fail_on_disconnected:
45+ print("WARNING: The following interfaces are not connected:")
46+ for iface in disconnected_ifaces:
47+ print(iface)
48+ sys.exit(1)
49+
50+ sys.exit(0)
51diff --git a/units/ethernet/jobs.pxu b/units/ethernet/jobs.pxu
52index 36c25f4..69e7760 100644
53--- a/units/ethernet/jobs.pxu
54+++ b/units/ethernet/jobs.pxu
55@@ -32,7 +32,7 @@ id: ethernet/info_automated_server
56 requires:
57 device.category == 'NETWORK'
58 user: root
59-command: network_device_info.py info NETWORK --no-nm
60+command: network_device_info.py info NETWORK --no-nm --fail-on-disconnected
61 estimated_duration: 2.0
62 _summary:
63 Provide information about detected ethernet devices

Subscribers

People subscribed via source and target branches