summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/software/lmi/scripts/software/cmd.py12
-rw-r--r--lmi/scripts/common/command/command.py18
-rw-r--r--lmi/scripts/common/command/meta.py8
3 files changed, 30 insertions, 8 deletions
diff --git a/commands/software/lmi/scripts/software/cmd.py b/commands/software/lmi/scripts/software/cmd.py
index 2c34fa6..1566c67 100644
--- a/commands/software/lmi/scripts/software/cmd.py
+++ b/commands/software/lmi/scripts/software/cmd.py
@@ -257,8 +257,8 @@ class Install(command.LmiCheckResult):
try:
software.install_from_uri(ns, _uri, force=_force)
installed.append(_uri)
- except errors.LmiFailed:
- pass
+ except errors.LmiFailed as err:
+ LOG().warn('failed to install "%s": %s', _uri, err)
for pkg_spec in package_array:
identities = list(software.find_package(ns,
@@ -275,8 +275,8 @@ class Install(command.LmiCheckResult):
try:
software.install_package(ns, identities[-1], force=_force)
installed.append(pkg_spec)
- except errors.LmiFailed:
- pass
+ except errors.LmiFailed as err:
+ LOG().warn('failed to install "%s": %s', pkg_spec, err)
return installed
@@ -310,8 +310,8 @@ class Remove(command.LmiCheckResult):
try:
software.remove_package(ns, identity)
removed.append(pkg_spec)
- except errors.LmiFailed:
- pass
+ except errors.LmiFailed as err:
+ LOG().warn('failed to remove "%s": %s', pkg_spec, err)
return removed
Software = command.register_subcommands(
diff --git a/lmi/scripts/common/command/command.py b/lmi/scripts/common/command/command.py
index c7a8cdd..7a3802a 100644
--- a/lmi/scripts/common/command/command.py
+++ b/lmi/scripts/common/command/command.py
@@ -558,6 +558,21 @@ class LmiInstanceLister(LmiBaseListerCommand):
"""
__metaclass__ = meta.InstanceListerMetaClass
+ @abc.abstractmethod
+ def render(self, result):
+ """
+ This method can either be overriden in a subclass or left alone. In the
+ latter case it will be generated by``InstanceListerMetaClass``
+ metaclass with regard to ``PROPERTIES`` and ``DYNAMIC_PROPERTIES``.
+
+ :param result: (``LMIInstance`` or ``tuple``) Either an instance to
+ render or pair of properties and instance.
+ :rtype: (``list``) List of pairs, where the first item is a label and
+ second a value to render.
+ """
+ raise NotImplementedError(
+ "render method must be overriden in subclass")
+
def take_action(self, connection, args, kwargs):
"""
Collects results of single host.
@@ -731,7 +746,8 @@ class LmiCheckResult(LmiSessionCommand):
if isinstance(res, tuple):
if len(res) != 2:
raise ValueError('check_result() must return either boolean'
- ' or (passed_flag, error_description), not "%s"' % repr(res))
+ ' or (passed_flag, error_description), not "%s"' %
+ repr(res))
return res
return (res, None)
except Exception as exc:
diff --git a/lmi/scripts/common/command/meta.py b/lmi/scripts/common/command/meta.py
index 9569de8..8aba880 100644
--- a/lmi/scripts/common/command/meta.py
+++ b/lmi/scripts/common/command/meta.py
@@ -535,13 +535,19 @@ class CheckResultMetaClass(SessionCommandMetaClass):
if isinstance(result, LMIReturnValue):
result = result.rval
passed = expect(options, result)
+ if not passed:
+ LOG().info('got unexpected result "%s"')
return passed
else:
def _new_expect(_self, _options, result):
""" Comparison function testing by equivalence. """
if isinstance(result, LMIReturnValue):
result = result.rval
- return expect == result
+ passed = expect == result
+ if not passed:
+ LOG().info('expected "%s", got "%s"', expected, result)
+ return (False, '%s != %s' % (expected, result))
+ return passed
_new_expect.expected = expect
del dcl['EXPECT']
dcl['check_result'] = _new_expect