client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py | 58 ++++++++--
1 file changed, 51 insertions(+), 7 deletions(-)
New commits:
commit 5a420638be55f710b47e3362a96d85818a2d159d
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 16:47:41 2010 +0100
564352 - populate optional items for usb devices
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index 10dbf9b..7ac1ee3 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -84,6 +84,11 @@ def get_devices():
if subsystem =='scsi':
if device.get_devtype =='scsi_device':
type = _get_scsi_dev_type(device)
+ if subsystem == 'usb':
+ if device.has_property('ID_VENDOR_ID'):
+ result_item['prop1'] =
device.get_property('ID_VENDOR_ID')
+ if device.has_property('ID_MODEL_ID'):
+ result_item['prop2'] =
device.get_property('ID_MODEL_ID')
result.append(result_item)
return result
commit eaac8154fea2139bfbfbddbb9f7e14b4df31625b
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 16:37:07 2010 +0100
564352 - properly clasify scsi devices
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index 92456a0..10dbf9b 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -261,6 +261,9 @@ def _clasify_class(device):
if m:
return 'PRINTER'
+ if subsystem == 'scsi':
+ return 'SCSI'
+
# Catchall for specific devices, only do this after all the others
if subsystem == 'pci' or subsystem == 'usb':
return 'OTHER'
commit 79da826a7b180e8cabf6ad5d8c40befbb164b2aa
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 15:52:39 2010 +0100
564352 - fix syntax error
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index ad2bdbc..92456a0 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -276,12 +276,12 @@ def _get_device_desc(device):
if subsystem == 'pci':
(vendor_id, device_id) =
device.get_property('PCI_ID').split(':')
pci = PCI()
- result = "%s|%s" % (pci.get_vendor(vendor_id) + '|' +
pci.get_device(vendor_id, device_id))
+ result = "%s|%s" % (pci.get_vendor(vendor_id),
pci.get_device(vendor_id, device_id))
elif subsystem == 'usb':
vendor_id = device.get_property('ID_VENDOR_ID')
if vendor_id:
usb = USB()
- result = "%s|%s" % (usb.get_vendor(vendor_id) + '|' +
usb.get_device(vendor_id, device.get_property('ID_MODEL_ID')))
+ result = "%s|%s" % (usb.get_vendor(vendor_id),
usb.get_device(vendor_id, device.get_property('ID_MODEL_ID')))
elif device.get_devtype() == 'usb_interface':
if device.get_driver() == 'usbhid':
result = 'USB HID Interface'
commit b592095dbad1e77400fc6de3f5ce2b99bfe70f56
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 15:49:27 2010 +0100
564352 - report correct bus for block subsystem
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index c281abc..ad2bdbc 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -46,6 +46,8 @@ def get_devices():
'desc': _get_device_desc(device),
}
if subsystem == 'block':
+ if device.has_property('ID_BUS'):
+ result_item['bus'] = device.get_property('ID_BUS')
result_item['device'] = device.get_name()
if device.get_devtype() == 'partition':
# do not report partitions, just whole disks
commit 84076a4552693a2c88d0f3d92f44fdc81f2f12ad
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 15:45:00 2010 +0100
564352 - clasify printers and cdroms
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index f752dd0..c281abc 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -83,7 +83,6 @@ def get_devices():
if device.get_devtype =='scsi_device':
type = _get_scsi_dev_type(device)
-
result.append(result_item)
return result
@@ -94,7 +93,6 @@ def get_computer_info():
'system.kernel.machine': 'i686'
'system.kernel.name': 'Linux'
"""
- #FIXME do we need to add smbios information?
uname = os.uname()
result = {
'system.kernel.name': uname[0],
@@ -221,6 +219,8 @@ def _clasify_class(device):
return 'SCSI'
elif sub_class == PCI_CLASS_STORAGE_RAID:
return 'RAID'
+ elif sub_class == PCI_CLASS_STORAGE_FLOPPY:
+ return 'FLOPPY'
elif base_class == PCI_BASE_CLASS_COMMUNICATION and sub_class ==
PCI_CLASS_COMMUNICATION_MODEM:
return 'MODEM'
elif base_class == PCI_BASE_CLASS_INPUT and sub_class ==
PCI_CLASS_INPUT_SCANNER:
@@ -235,10 +235,11 @@ def _clasify_class(device):
return 'SOCKET'
if subsystem == 'block':
- if device.has_property('ID_CDROM'):
+ if device.has_property('ID_CDROM') or (
+ device.has_property('ID_TYPE') and
device.get_property('ID_TYPE') == 'cd'):
return 'CDROM'
else:
- return 'HD' #FIXME had to distinguis HD, FLOPY, TAPE and flash disks
+ return 'HD'
elif subsystem == 'sound':
return 'AUDIO'
commit 1aa0720cc06c087c6e974d89a49d86a2d25d5794
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 14:54:29 2010 +0100
564352 - clasify printers
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index 10b2cd6..f752dd0 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -254,7 +254,9 @@ def _clasify_class(device):
else:
return 'OTHER'
# PRINTER
- pass #FIXME
+ m = re.search('.*/lp\d+$', device.get_sysfs_path())
+ if m:
+ return 'PRINTER'
# Catchall for specific devices, only do this after all the others
if subsystem == 'pci' or subsystem == 'usb':
commit 8c87c3dae72dbd7c947aca955d47295e157d5efa
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 12:18:30 2010 +0100
564352 - read scsi devices
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index a5802a4..10b2cd6 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -33,7 +33,7 @@ def get_devices():
# listen to uevents on all subsystems
client = gudev.Client([""])
# FIX ME - change to None to list all devices once it is fixed in gudev
- devices = client.query_by_subsystem("pci") +
client.query_by_subsystem("usb") + client.query_by_subsystem("block")
+ client.query_by_subsystem("ccw")
+ devices = client.query_by_subsystem("pci") +
client.query_by_subsystem("usb") + client.query_by_subsystem("block")
+ client.query_by_subsystem("ccw") +
client.query_by_subsystem("scsi")
result = []
for device in devices:
subsystem = device.get_subsystem()
@@ -79,6 +79,11 @@ def get_devices():
result_item['prop2'] = m.group(2) # DEV_ID
result_item['prop3'] = m.group(3) # DEV_CHANNEL
result_item['prop4'] = m.group(4) # DEV_LUN
+ if subsystem =='scsi':
+ if device.get_devtype =='scsi_device':
+ type = _get_scsi_dev_type(device)
+
+
result.append(result_item)
return result
@@ -237,6 +242,17 @@ def _clasify_class(device):
elif subsystem == 'sound':
return 'AUDIO'
+ if subsystem =='scsi':
+ if device.get_devtype =='scsi_device':
+ type = _get_scsi_dev_type(device)
+ if type == 0 or type == 14:
+ return 'HD'
+ elif type == 1:
+ return 'TAPE'
+ elif type == 5:
+ return 'CDROM'
+ else:
+ return 'OTHER'
# PRINTER
pass #FIXME
@@ -293,3 +309,12 @@ def _parse_pci_class(pci_class):
else:
return (pci_class[-6:-4], pci_class[-4:-2])
+def _get_scsi_dev_type(device):
+ """ Return SCSI type of device in raw format as presented in
/sys/...devpath../type """
+ try:
+ f = open("%s/type" % device.get_sysfs_path(), 'r')
+ except IOError:
+ return -1
+ result = f.readline()
+ f.close()
+ return result
commit 3f19b04f71d015406aebbf41aed87fd34cfd21f2
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 11:49:34 2010 +0100
564352 - format string using %
if model is not known we will get TypeError
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index 33b25d0..a5802a4 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -255,12 +255,12 @@ def _get_device_desc(device):
if subsystem == 'pci':
(vendor_id, device_id) =
device.get_property('PCI_ID').split(':')
pci = PCI()
- result = pci.get_vendor(vendor_id) + '|' + pci.get_device(vendor_id,
device_id)
+ result = "%s|%s" % (pci.get_vendor(vendor_id) + '|' +
pci.get_device(vendor_id, device_id))
elif subsystem == 'usb':
vendor_id = device.get_property('ID_VENDOR_ID')
if vendor_id:
usb = USB()
- result = usb.get_vendor(vendor_id) + '|' + usb.get_device(vendor_id,
device.get_property('ID_MODEL_ID'))
+ result = "%s|%s" % (usb.get_vendor(vendor_id) + '|' +
usb.get_device(vendor_id, device.get_property('ID_MODEL_ID')))
elif device.get_devtype() == 'usb_interface':
if device.get_driver() == 'usbhid':
result = 'USB HID Interface'
@@ -273,7 +273,7 @@ def _get_device_desc(device):
# left pad it with 0 to 4 digits
vendor_id = '%.4x' % int(vendor_id, 16)
model_id = '%.4x' % int(model_id, 16)
- result = usb.get_vendor(vendor_id) + '|' + usb.get_device(vendor_id,
device.get_property('ID_MODEL_ID'))
+ result = "%s|%s" % (usb.get_vendor(vendor_id),
usb.get_device(vendor_id, device.get_property('ID_MODEL_ID')))
elif subsystem == 'block':
result = device.get_property('ID_MODEL')
if result:
commit dea1b88ce70fa49d6f7f12cd90026e59d90734f4
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 23 12:48:01 2010 +0100
564352 - parse PRODUCT to get vendor and model
I find at least one usb printer which do not set vendor and model but has set product,
which has needed information
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
index dfccbce..33b25d0 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware_gudev.py
@@ -268,6 +268,12 @@ def _get_device_desc(device):
result = 'USB Hub Interface'
else:
result = 'USB Interface'
+ elif device.get_devtype() == 'usb_device' and
device.get_property('PRODUCT'):
+ (vendor_id, model_id) =
device.get_property('product').split('/')[:2]
+ # left pad it with 0 to 4 digits
+ vendor_id = '%.4x' % int(vendor_id, 16)
+ model_id = '%.4x' % int(model_id, 16)
+ result = usb.get_vendor(vendor_id) + '|' + usb.get_device(vendor_id,
device.get_property('ID_MODEL_ID'))
elif subsystem == 'block':
result = device.get_property('ID_MODEL')
if result: