Merge lp:~tai271828/checkbox/fix-lp1334991 into lp:checkbox

Proposed by Taihsiang Ho
Status: Merged
Approved by: Daniel Manrique
Approved revision: 3123
Merged at revision: 3126
Proposed branch: lp:~tai271828/checkbox/fix-lp1334991
Merge into: lp:checkbox
Diff against target: 39 lines (+20/-2)
1 file modified
providers/plainbox-provider-checkbox/bin/removable_storage_test (+20/-2)
To merge this branch: bzr merge lp:~tai271828/checkbox/fix-lp1334991
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+227284@code.launchpad.net

Commit message

implement a smarter parser to get pci slot names from DEVPATH (LP: #1334991)

Description of the change

implement a smarter parser to get pci slot names from DEVPATH (LP: #1334991)

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1 though I'm not quite sure about what's going on

+100 if we can drop the whole code and ask another, higher-level subsystem about the same topic

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'providers/plainbox-provider-checkbox/bin/removable_storage_test'
2--- providers/plainbox-provider-checkbox/bin/removable_storage_test 2014-05-02 09:25:50 +0000
3+++ providers/plainbox-provider-checkbox/bin/removable_storage_test 2014-07-18 07:13:15 +0000
4@@ -263,8 +263,9 @@
5 for udev_device_xhci in udev_devices_xhci:
6 pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')
7 for udev_device in udev_devices:
8- if (pci_slot_name ==
9- udev_device.get_property('DEVPATH').split('/')[3]):
10+ devpath = udev_device.get_property('DEVPATH')
11+ if (self._compare_pci_slot_from_devpath(devpath,
12+ pci_slot_name)):
13 self.rem_disks_xhci[
14 udev_device.get_property('DEVNAME')] = 'xhci'
15 except:
16@@ -362,6 +363,23 @@
17 if not os.path.ismount(self.rem_disks_nm[disk]):
18 os.rmdir(self.rem_disks_nm[disk])
19
20+ def _compare_pci_slot_from_devpath(self, devpath, pci_slot_name):
21+ # LP: #1334991
22+ # a smarter parser to get and validate a pci slot name from DEVPATH
23+ # then compare this pci slot name to the other
24+ dl = devpath.split('/')
25+ s = set([x for x in dl if dl.count(x) > 1])
26+ if ((pci_slot_name in dl)
27+ and (dl.index(pci_slot_name) < dl.index('block'))
28+ and (not(pci_slot_name in s))):
29+ # 1. there is such pci_slot_name
30+ # 2. sysfs topology looks like
31+ # DEVPATH = ....../pci_slot_name/....../block/......
32+ # 3. pci_slot_name should be unique in DEVPATH
33+ return True
34+ else:
35+ return False
36+
37
38 def main():
39 parser = argparse.ArgumentParser()

Subscribers

People subscribed via source and target branches