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
=== modified file 'providers/plainbox-provider-checkbox/bin/removable_storage_test'
--- providers/plainbox-provider-checkbox/bin/removable_storage_test 2014-05-02 09:25:50 +0000
+++ providers/plainbox-provider-checkbox/bin/removable_storage_test 2014-07-18 07:13:15 +0000
@@ -263,8 +263,9 @@
263 for udev_device_xhci in udev_devices_xhci:263 for udev_device_xhci in udev_devices_xhci:
264 pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')264 pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')
265 for udev_device in udev_devices:265 for udev_device in udev_devices:
266 if (pci_slot_name ==266 devpath = udev_device.get_property('DEVPATH')
267 udev_device.get_property('DEVPATH').split('/')[3]):267 if (self._compare_pci_slot_from_devpath(devpath,
268 pci_slot_name)):
268 self.rem_disks_xhci[269 self.rem_disks_xhci[
269 udev_device.get_property('DEVNAME')] = 'xhci'270 udev_device.get_property('DEVNAME')] = 'xhci'
270 except:271 except:
@@ -362,6 +363,23 @@
362 if not os.path.ismount(self.rem_disks_nm[disk]):363 if not os.path.ismount(self.rem_disks_nm[disk]):
363 os.rmdir(self.rem_disks_nm[disk])364 os.rmdir(self.rem_disks_nm[disk])
364365
366 def _compare_pci_slot_from_devpath(self, devpath, pci_slot_name):
367 # LP: #1334991
368 # a smarter parser to get and validate a pci slot name from DEVPATH
369 # then compare this pci slot name to the other
370 dl = devpath.split('/')
371 s = set([x for x in dl if dl.count(x) > 1])
372 if ((pci_slot_name in dl)
373 and (dl.index(pci_slot_name) < dl.index('block'))
374 and (not(pci_slot_name in s))):
375 # 1. there is such pci_slot_name
376 # 2. sysfs topology looks like
377 # DEVPATH = ....../pci_slot_name/....../block/......
378 # 3. pci_slot_name should be unique in DEVPATH
379 return True
380 else:
381 return False
382
365383
366def main():384def main():
367 parser = argparse.ArgumentParser()385 parser = argparse.ArgumentParser()

Subscribers

People subscribed via source and target branches