[openlmi-scripts] removed unstable features out of hardware script
Michal Minar
miminar at fedoraproject.org
Tue Feb 25 16:00:57 UTC 2014
commit fb010a236d74f7a0462034ac8bf637759509fb6a
Author: Michal Minar <miminar at redhat.com>
Date: Tue Feb 25 16:56:09 2014 +0100
removed unstable features out of hardware script
Disks introspection is not yet stable in rhel and fedora. Remove
this support from scripts temporarily.
...ts-0.2.7-hardware_support_older_providers.patch | 206 ++++++++++++++++++--
openlmi-scripts.spec | 5 +-
2 files changed, 192 insertions(+), 19 deletions(-)
---
diff --git a/openlmi-scripts-0.2.7-hardware_support_older_providers.patch b/openlmi-scripts-0.2.7-hardware_support_older_providers.patch
index 1580f89..d27f4f6 100644
--- a/openlmi-scripts-0.2.7-hardware_support_older_providers.patch
+++ b/openlmi-scripts-0.2.7-hardware_support_older_providers.patch
@@ -1,18 +1,19 @@
diff --git a/commands/hardware/lmi/scripts/hardware/__init__.py b/commands/hardware/lmi/scripts/hardware/__init__.py
-index a110800..c077d70 100644
+index a110800..56e1f04 100644
--- a/commands/hardware/lmi/scripts/hardware/__init__.py
+++ b/commands/hardware/lmi/scripts/hardware/__init__.py
-@@ -32,6 +32,9 @@
+@@ -32,6 +32,10 @@
LMI hardware provider client library.
"""
+import pywbem
+
++from lmi.shell import LMIClassNotFound
+from lmi.scripts.common import get_logger
from lmi.scripts.common import get_computer_system
GREEN_COLOR = 1
-@@ -42,6 +45,8 @@ EMPTY_LINE = ('', '')
+@@ -42,6 +46,8 @@ EMPTY_LINE = ('', '')
# GLOBAL variable - modified in get_all_info(), accessed in init_result()
STANDALONE = True
@@ -21,19 +22,188 @@ index a110800..c077d70 100644
def _cache_replies(ns, class_name, method):
"""
Get the reply from cimom and cache it. Cache is cleared
-@@ -83,7 +88,14 @@ def get_all_instances(ns, class_name):
- :returns: List of instances of instance_name
- :rtype: List of :py:class:`lmi.shell.LMIInstance`
- """
-- return _cache_replies(ns, class_name, 'instances')
+@@ -58,9 +64,17 @@ def _cache_replies(ns, class_name, method):
+ # keep the cache until namespace object changes
+ cache.clear()
+ _cache_replies.cache = (ns, cache)
+- if not (class_name, method) in cache:
+- i = getattr(ns, class_name)
+- cache[(class_name, method)] = getattr(i, method)()
+ try:
-+ return _cache_replies(ns, class_name, 'instances')
-+ except pywbem.CIMError as err:
-+ if err.args[0] == pywbem.CIM_ERR_NOT_SUPPORTED:
-+ LOG().info('System has old openlmi-hardware package installed,'
-+ ' class "%s" is not available.', class_name)
-+ return []
-+ raise
-
- def get_hostname(ns):
- """
++ if not (class_name, method) in cache:
++ i = getattr(ns, class_name)
++ cache[(class_name, method)] = getattr(i, method)()
++ except (LMIClassNotFound, pywbem.CIMError) as err:
++ if ( isinstance(err, pywbem.CIMError)
++ and err.args[0] != pywbem.CIM_ERR_NOT_SUPPORTED):
++ raise
++ LOG().info('System has old openlmi-hardware package installed,'
++ ' class "%s" is not available.', class_name)
++ return []
+ return cache[(class_name, method)]
+
+ def get_single_instance(ns, class_name):
+@@ -164,8 +178,6 @@ def get_all_info(ns):
+ result += get_cpu_info(ns)
+ result.append(EMPTY_LINE)
+ result += get_memory_info(ns)
+- result.append(EMPTY_LINE)
+- result += get_disks_info(ns)
+ STANDALONE = True
+ return result
+
+@@ -301,116 +313,3 @@ def get_memory_info(ns):
+ result.append(('Slots:', slots))
+ return result
+
+-def get_disks_info(ns):
+- """
+- :returns: Tabular data of disk info.
+- :rtype: List of tuples
+- """
+- result = init_result(ns)
+- result.append(('Disks:', ''))
+-
+- hdds = get_all_instances(ns, 'LMI_DiskDrive')
+- if not hdds:
+- result.append((' N/A', ''))
+- return result
+-
+- first_disk = True
+-
+- for hdd in hdds:
+- phys_hdds = hdd.associators(ResultClass='LMI_DiskPhysicalPackage')
+- manufacturer = ''
+- model = ''
+- if phys_hdds:
+- manufacturer = phys_hdds[0].Manufacturer
+- model = phys_hdds[0].Model
+- if not manufacturer:
+- manufacturer = 'N/A'
+- if not model:
+- model = 'N/A'
+-
+- form_factor_dict = {
+- 3: '5.25"',
+- 4: '3.5"',
+- 5: '2.5"',
+- 6: '1.8"',}
+- if hdd.FormFactor in form_factor_dict:
+- form_factor = form_factor_dict[hdd.FormFactor]
+- else:
+- form_factor = 'N/A'
+-
+- if hdd.RPM != 0xffffffff:
+- rpm = hdd.RPM
+- else:
+- rpm = 'N/A'
+-
+- if hdd.DiskType == 2:
+- disk_type = 'HDD'
+- elif hdd.DiskType == 3:
+- disk_type = 'SSD'
+- else:
+- disk_type = 'N/A'
+-
+- port_type = ''
+- port_speed_current = ''
+- port_speed_max = ''
+- hdd_endpoints = hdd.associators(
+- ResultClass='LMI_DiskDriveATAProtocolEndpoint')
+- if hdd_endpoints:
+- hdd_ports = hdd_endpoints[0].associators(
+- ResultClass='LMI_DiskDriveATAPort')
+- if hdd_ports:
+- if hdd_ports[0].PortType:
+- port_type = ns.LMI_DiskDriveATAPort.PortTypeValues.value_name(
+- hdd_ports[0].PortType)
+- if hdd_ports[0].Speed:
+- port_speed_current = '%.1f Gb/s' % \
+- (float(hdd_ports[0].Speed) / 1000000000.0)
+- if hdd_ports[0].MaxSpeed:
+- port_speed_max = '%.1f Gb/s' % \
+- (float(hdd_ports[0].MaxSpeed) / 1000000000.0)
+- if not port_type:
+- port_type = 'N/A'
+- if not port_speed_current:
+- port_speed_current = 'N/A Gb/s'
+- if not port_speed_max:
+- port_speed_max = 'N/A Gb/s'
+-
+- status_to_color = {
+- 'OK': GREEN_COLOR,
+- 'Unknown': YELLOW_COLOR,
+- 'Predictive Failure': RED_COLOR,}
+- if hdd.OperationalStatus:
+- smart = ns.LMI_DiskDrive.OperationalStatusValues.value_name(
+- hdd.OperationalStatus[0])
+- smart = get_colored_string(smart, status_to_color[smart])
+- else:
+- smart = get_colored_string('Unknown', YELLOW_COLOR)
+-
+- temp = getattr(hdd, 'Temperature', None)
+- if temp:
+- temp_str = '%d' % temp
+- else:
+- temp_str = 'N/A'
+- temp_str += u' °C'
+-
+- if not first_disk:
+- result.append(EMPTY_LINE)
+- else:
+- first_disk = False
+-
+- if hdd.Name != hdd.DeviceID and hdd.Name != model:
+- result.append((' %s' % hdd.DeviceID, hdd.Name))
+- else:
+- result.append((' %s' % hdd.DeviceID, ''))
+- result += [(' Manufacturer:', manufacturer),
+- (' Model:', model),
+- (' Capacity:', format_memory_size(hdd.Capacity)),
+- (' Form Factor:', form_factor),
+- (' HDD/SSD:', disk_type),
+- (' RPM:', rpm),
+- (' Port Type:', port_type),
+- (' Port Speed:', '%s current, %s max' % \
+- (port_speed_current, port_speed_max)),
+- (' SMART Status:', smart),
+- (' Temperature:', temp_str)]
+- return result
+diff --git a/commands/hardware/lmi/scripts/hardware/cmd.py b/commands/hardware/lmi/scripts/hardware/cmd.py
+index e57e3be..985645d 100644
+--- a/commands/hardware/lmi/scripts/hardware/cmd.py
++++ b/commands/hardware/lmi/scripts/hardware/cmd.py
+@@ -36,7 +36,6 @@ Usage:
+ %(cmd)s motherboard
+ %(cmd)s cpu
+ %(cmd)s memory
+- %(cmd)s disks
+
+ Commands:
+ all Display all available information.
+@@ -44,7 +43,6 @@ Commands:
+ motherboard Display motherboard information.
+ cpu Display processor information.
+ memory Display memory information.
+- disks Display disks information.
+ """
+
+ from lmi.scripts.common import command
+@@ -67,9 +65,6 @@ class Cpu(HwBase):
+ class Memory(HwBase):
+ CALLABLE = 'lmi.scripts.hardware:get_memory_info'
+
+-class Disks(HwBase):
+- CALLABLE = 'lmi.scripts.hardware:get_disks_info'
+-
+ Hardware = command.register_subcommands(
+ 'Hardware', __doc__,
+ { 'all' : All
+@@ -77,7 +72,6 @@ Hardware = command.register_subcommands(
+ , 'motherboard' : Motherboard
+ , 'cpu' : Cpu
+ , 'memory' : Memory
+- , 'disks' : Disks
+ },
+ fallback_command=All
+ )
diff --git a/openlmi-scripts.spec b/openlmi-scripts.spec
index 364d8e4..1c37cc9 100644
--- a/openlmi-scripts.spec
+++ b/openlmi-scripts.spec
@@ -6,7 +6,7 @@
Name: openlmi-scripts
Version: %{openlmi_scripts_version}
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Client-side python modules and command line utilities
License: BSD
@@ -239,6 +239,9 @@ install -m 644 README.md COPYING Changelog $RPM_BUILD_ROOT/%{_docdir}/%{name}
%{python_sitelib}/openlmi_scripts_powermanagement-*
%changelog
+* Tue Feb 25 2014 Michal Minar <miminar at redhat.com> 0.2.7-4
+- Removed unstable features from hardware scripts.
+
* Tue Feb 25 2014 Michal Minar <miminar at redhat.com> 0.2.7-3
- Added account and powermanagement commands.
More information about the scm-commits
mailing list