summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2014-02-25 07:45:26 +0100
committerMichal Minar <miminar@redhat.com>2014-02-25 07:45:26 +0100
commit55d422cab9729672890f4f33a4c6b0cff4cb8797 (patch)
treefd96a0ed6d05ddc22887c935475aa30ac4d24a28
parent8563d295e503cab96c3b1651fa55413a7f589641 (diff)
downloadopenlmi-scripts-55d422cab9729672890f4f33a4c6b0cff4cb8797.tar.gz
openlmi-scripts-55d422cab9729672890f4f33a4c6b0cff4cb8797.tar.xz
openlmi-scripts-55d422cab9729672890f4f33a4c6b0cff4cb8797.zip
hardware: deal properly with older versions of providers
LMI_DiskDrive class was added to openlmi-hardware just recently. Don't expect it to be present on broker.
-rw-r--r--commands/hardware/lmi/scripts/hardware/__init__.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/commands/hardware/lmi/scripts/hardware/__init__.py b/commands/hardware/lmi/scripts/hardware/__init__.py
index a110800..c077d70 100644
--- a/commands/hardware/lmi/scripts/hardware/__init__.py
+++ b/commands/hardware/lmi/scripts/hardware/__init__.py
@@ -32,6 +32,9 @@
LMI hardware provider client library.
"""
+import pywbem
+
+from lmi.scripts.common import get_logger
from lmi.scripts.common import get_computer_system
GREEN_COLOR = 1
@@ -42,6 +45,8 @@ EMPTY_LINE = ('', '')
# GLOBAL variable - modified in get_all_info(), accessed in init_result()
STANDALONE = True
+LOG = get_logger(__name__)
+
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')
+ 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):
"""