Martin Polednik has uploaded a new change for review. Change subject: hostdev: report relevant information in 'scsi' device ......................................................................
hostdev: report relevant information in 'scsi' device Change-Id: I789f49c9abca2dff1487acf3e8a04ae1407956f4 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Martin Polednik <[email protected]> --- M lib/vdsm/hostdev.py A tests/devices/data/scsi_generic_sg0.xml 2 files changed, 31 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/56038/1 diff --git a/lib/vdsm/hostdev.py b/lib/vdsm/hostdev.py index 7624142..b4fff0e 100644 --- a/lib/vdsm/hostdev.py +++ b/lib/vdsm/hostdev.py @@ -123,6 +123,27 @@ return _parse_address(caps, ('bus', 'device')) +def _parse_scsi_device_params(device_xml): + def find_device_by_parent(device_classes, parent_name): + return {key: value for key, value in + list_by_caps(device_classes).items() if + value['params']['parent'] == parent_name}.items()[0] + + params = {} + + scsi_name = device_xml.find('name').text + storage_dev_name, storage_dev_params = find_device_by_parent( + ['storage'], scsi_name) + _, scsi_generic_dev_params = find_device_by_parent( + ['scsi_generic'], scsi_name) + + params['vendor'] = storage_dev_params['params']['vendor'] + params['product'] = storage_dev_name + params['udev_path'] = scsi_generic_dev_params['params']['udev_path'] + + return params + + def _parse_device_params(device_xml): """ Process device_xml and return dict of found known parameters, @@ -189,6 +210,8 @@ # dealing with device that is not yet supported pass + if params['capability'] == 'scsi': + params.update(_parse_scsi_device_params(devXML)) return params diff --git a/tests/devices/data/scsi_generic_sg0.xml b/tests/devices/data/scsi_generic_sg0.xml new file mode 100644 index 0000000..779191a --- /dev/null +++ b/tests/devices/data/scsi_generic_sg0.xml @@ -0,0 +1,8 @@ +<device> + <name>scsi_generic_sg0</name> + <path>/sys/devices/pci0000:00/0000:00:11.4/ata1/host0/target0:0:0/0:0:0:0/scsi_generic/sg0</path> + <parent>scsi_0_0_0_0</parent> + <capability type='scsi_generic'> + <char>/dev/sg0</char> + </capability> +</device> -- To view, visit https://gerrit.ovirt.org/56038 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I789f49c9abca2dff1487acf3e8a04ae1407956f4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Polednik <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
