Merge ~sylvain-pineau/checkbox-support:usb_partion_hub_version into checkbox-support:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 3d121ec03056e09fec11ab45e0ab4b3743f61ee6
Merged at revision: e8696ddf6179ae41bdbf1270145d9440281ea297
Proposed branch: ~sylvain-pineau/checkbox-support:usb_partion_hub_version
Merge into: checkbox-support:master
Diff against target: 17 lines (+6/-1)
1 file modified
checkbox_support/parsers/udevadm.py (+6/-1)
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+327870@code.launchpad.net

Description of the change

This MR tweaks the bus property of PARTITION "devices". The original usb is kept for usb2 versions (needless to change the corresponding jobs using the removable_partition resource). But for usb3, the bus is then changed to usb3.

To test it, just run from the resource provider bin dir:

plainbox-provider-resource/bin$ ./udev_resource -f PARTITION
path: /devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/host15/target15:0:0/15:0:0:0/block/sdb/sdb1
name: sdb1
bus: usb3
category: PARTITION
product: sdb1
product_slug: sdb1

Note that a usb2 device plugged into a usb3 port will report bus: usb.

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

Cool use of a for/else idiom!
Also LGTM, +1

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

First time I see an obvious case to use it, I'm quite proud :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
2index 7f5acc7..55efe46 100644
3--- a/checkbox_support/parsers/udevadm.py
4+++ b/checkbox_support/parsers/udevadm.py
5@@ -186,7 +186,12 @@ class UdevadmDevice(object):
6 self._environment.get("DEVTYPE") == "partition" and self._stack
7 ):
8 if any(d.bus == 'usb' for d in self._stack):
9- return 'usb'
10+ for d in self._stack:
11+ # Report the current usb hub version
12+ if d._environment.get("ID_MODEL_ID") == '0003':
13+ return 'usb3'
14+ else:
15+ return 'usb'
16 else:
17 return self._stack[-2]._environment.get("SUBSYSTEM")
18

Subscribers

People subscribed via source and target branches