Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit f142d945cb3f269c00df15c187570cce43abb7d5
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Mar 24 08:28:10 2014 +0100
improve logging when calling synchro methods
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 7c32be9..8147312 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -14,6 +14,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import sys
+import logging
import pywbem
import signal
import socket
@@ -52,6 +53,8 @@ from LMIExceptions import LMISynchroMethodCallFilterError
from LMIExceptions import LMIUnknownParameterError
from LMIExceptions import LMIHandlerNamePatternError
+logger = logging.getLogger(__name__)
+
class LMISignalHelper(object):
"""
Helper class, which takes care of signal (de)registration and handling.
@@ -205,12 +208,21 @@ class LMIMethod(LMIWrapperBaseObject):
# Is job in exception state? If so, adjust corresponding error string
# from job.GetError() instance
if lmi_is_job_exception(job_inst):
- (refreshed, _, errorstr) = job_inst.refresh()
+ try:
+ (refreshed, _, errorstr) = job_inst.refresh()
+ except pywbem.cim_operations.CIMError, e:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, str(e)))
+ job_exception.value = e
if not refreshed:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, errorstr))
raise LMISynchroMethodCallError(errorstr)
(exc_rval, exc_rparams, exc_errorstr) = job_inst.GetError()
error_inst = exc_rparams.get("error", None)
if not error_inst:
+ logger.debug("Sync%s: Can not retrieve Error instance; %s"
+ % (self._method.name, exc_errorstr))
raise LMISynchroMethodCallError("Could not get Job error message")
errorstr = error_inst.Message
return LMIReturnValue(rval=rval, rparams=rparams, errorstr=errorstr)
@@ -357,9 +369,13 @@ class LMIMethod(LMIWrapperBaseObject):
try:
(refreshed, _, errorstr) = job_inst.refresh()
except pywbem.cim_operations.CIMError, e:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, str(e)))
job_exception.value = e
break
if not refreshed:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, errorstr))
job_exception.value = LMISynchroMethodCallError(errorstr)
break
@@ -377,7 +393,7 @@ class LMIMethod(LMIWrapperBaseObject):
raise job_exception.value
if LMISignalHelper().signal_handled() and not job_finished.value:
# We got SIGINT or SIGTERM, when waiting for the job, cancelling the job
- sys.stderr.write("Cancelling a job '%s'\n" % job_inst.Name)
+ logger.warn("Cancelling a job '%s'" % job_inst.Name)
job_inst.RequestStateChange(
RequestedState=job_inst.RequestStateChange.RequestedStateValues.Terminate
)
@@ -418,9 +434,13 @@ class LMIMethod(LMIWrapperBaseObject):
sleep_time *= 2
(refreshed, _, errorstr) = job_inst.refresh()
if not refreshed:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, errorstr))
job_exception = LMISynchroMethodCallError(errorstr)
break
except pywbem.cim_operations.CIMError, e:
+ logger.debug("Sync%s: Job instance can not be refreshed; %s"
+ % (self._method.name, str(e)))
job_exception = LMISynchroMethodCallError(e.message)
finally:
cond.release()
@@ -431,7 +451,7 @@ class LMIMethod(LMIWrapperBaseObject):
if LMISignalHelper().signal_handled() and not lmi_is_job_finished(job_inst):
# We got SIGINT or SIGTERM, when waiting for the job, cancelling the job
- sys.stderr.write("Cancelling a job '%s'\n" % job_inst.Name)
+ logger.warn("Cancelling a job '%s'" % job_inst.Name)
job_inst.RequestStateChange(
RequestedState=job_inst.RequestStateChange.RequestedStateValues.Terminate
)
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4921474f826e3b30a2a313a29ee133f421aca684
Author: Michal Minar <miminar(a)redhat.com>
Date: Tue Mar 11 07:57:43 2014 +0100
bumped version
>---------------------------------------------------------------
cli/lmi/shell/LMIShellVersion.py | 2 +-
doc/src/conf.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index 452176c..1bac7e4 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -13,4 +13,4 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-__version__ = "0.9"
+__version__ = "0.9.1"
diff --git a/doc/src/conf.py b/doc/src/conf.py
index a4429c2..e1f2690 100644
--- a/doc/src/conf.py
+++ b/doc/src/conf.py
@@ -106,9 +106,9 @@ copyright = '2012-2014, Red Hat Inc.'
# built documents.
#
# The short X.Y version.
-version = '0.9'
+version = '0.9.1'
# The full version, including alpha/beta/rc tags.
-release = '0.9'
+release = '0.9.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4672ffe4b12b19b608f4da5a9e741b01601cf794
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Mar 10 16:46:01 2014 +0100
merged doc changes from openlmi-scripts upstream
Updated meta-command sources.
This includes all the commits from upstream within range:
97fc31be422e833232679cfb27fbcfd4ae3fde5b ..
51a3c81224db59d4f2213b2e8d7be6624d70922c
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^4672ffe4b12b19b608f4da5a9e741b01601cf794~1 4672ffe4b12b19b608f4da5a9e741b01601cf794
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit af79deb39bc83145b6de2694db2463ddc7ad64d3
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Mar 10 16:41:41 2014 +0100
merged changes from openlmi-scripts upstream
Updated meta-command sources.
This includes all the commits from upstream in range:
97fc31be422e833232679cfb27fbcfd4ae3fde5b ..
51a3c81224db59d4f2213b2e8d7be6624d70922c
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^af79deb39bc83145b6de2694db2463ddc7ad64d3~1 af79deb39bc83145b6de2694db2463ddc7ad64d3
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
Branch 'openlmi-tools-lmiwbem' now includes:
b8fac49 fix local imports
3b862b0 fix local imports; move CWD at the end of import list
ebcb0e7 improve local imports search path
65d720f fix inverse constant values
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : 0.9-fixes
>---------------------------------------------------------------
commit c2c033dc7e9bcd65b89bb1eb19b933fc347144dc
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Mar 6 14:16:04 2014 +0100
fix inverse constant values
>---------------------------------------------------------------
cli/lmi/shell/LMIClass.py | 2 +-
cli/lmi/shell/LMIConstantValues.py | 33 ++++++++++++++++++++++++---------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index 67c21c1..7f9f19c 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -133,7 +133,7 @@ class LMIClass(LMIWrapperBaseObject):
self._namespace.name, LocalOnly=False)
# Store the constant values as a list. This can consume some time, if computed on demand.
self._valuemap_properties_list = [k for (k, v) in self._cim_class.properties.iteritems() \
- if "ValueMap" in v.qualifiers]
+ if "ValueMap" in v.qualifiers and "Values" in v.qualifiers]
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
diff --git a/cli/lmi/shell/LMIConstantValues.py b/cli/lmi/shell/LMIConstantValues.py
index f97b831..6420e8a 100644
--- a/cli/lmi/shell/LMIConstantValues.py
+++ b/cli/lmi/shell/LMIConstantValues.py
@@ -14,7 +14,9 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import abc
+import logging
import sys
+import re
from LMIBaseObject import LMIBaseObject
from LMIUtil import lmi_cast_to_lmi
@@ -33,20 +35,33 @@ class LMIConstantValues(LMIBaseObject):
__metaclass__ = abc.ABCMeta
def __init__(self, cim_obj, cast_type):
- # Keys can contain various undesirable characters, such as python
- # operators, etc. So we drop them.
- keys = map(lambda v: "".join(c for c in v if c.isalnum()),
- cim_obj.qualifiers["Values"].value)
- values = cim_obj.qualifiers["ValueMap"].value
+ logger = logging.getLogger(__name__)
+ items = zip(
+ cim_obj.qualifiers["Values"].value,
+ cim_obj.qualifiers["ValueMap"].value)
self._value_map = {}
self._value_map_inv = {}
self._cast_type = cast_type
# Fill two dictionaries for bidirectional access to constant values.
- for i in range(0, len(keys)):
+ cnt = 1
+ for (key, value) in items:
try:
- key = keys[i]
- val = lmi_cast_to_lmi(self._cast_type, values[i])
- self._value_map[key] = val
+ # Cast constant value first. If we get ValueError, no key
+ # modifications are necessary.
+ val = lmi_cast_to_lmi(self._cast_type, value)
+
+ # Keys can contain various undesirable characters, such as
+ # python operators, etc. So we drop them.
+ mod_key = re.sub("\W", "", key)
+ if mod_key[0].isdigit():
+ mod_key = "Key_" + mod_key
+ if mod_key in self._value_map:
+ mod_key += str(cnt)
+ cnt += 1
+ logger.warn("Constant value mapped as: '%s' -> '%s'" % (key, mod_key))
+
+ self._value_map[mod_key] = val
+ # For inverse mapping, we use unmodified key.
self._value_map_inv[val] = key
except ValueError, e:
# Can not cast such value as interval. Can be found in
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branches: master,openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit 65d720fa243eedd0f43f0b96c5f22964f6bfb22c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Mar 6 14:16:04 2014 +0100
fix inverse constant values
>---------------------------------------------------------------
cli/lmi/shell/LMIClass.py | 2 +-
cli/lmi/shell/LMIConstantValues.py | 33 ++++++++++++++++++++++++---------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index f8a0a69..730fddc 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -133,7 +133,7 @@ class LMIClass(LMIWrapperBaseObject):
self._namespace.name, LocalOnly=False)
# Store the constant values as a list. This can consume some time, if computed on demand.
self._valuemap_properties_list = [k for (k, v) in self._cim_class.properties.iteritems() \
- if "ValueMap" in v.qualifiers]
+ if "ValueMap" in v.qualifiers and "Values" in v.qualifiers]
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
diff --git a/cli/lmi/shell/LMIConstantValues.py b/cli/lmi/shell/LMIConstantValues.py
index 93fe796..f2550f4 100644
--- a/cli/lmi/shell/LMIConstantValues.py
+++ b/cli/lmi/shell/LMIConstantValues.py
@@ -14,7 +14,9 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import abc
+import logging
import sys
+import re
from LMIUtil import lmi_cast_to_lmi
@@ -32,20 +34,33 @@ class LMIConstantValues(object):
__metaclass__ = abc.ABCMeta
def __init__(self, cim_obj, cast_type):
- # Keys can contain various undesirable characters, such as python
- # operators, etc. So we drop them.
- keys = map(lambda v: "".join(c for c in v if c.isalnum()),
- cim_obj.qualifiers["Values"].value)
- values = cim_obj.qualifiers["ValueMap"].value
+ logger = logging.getLogger(__name__)
+ items = zip(
+ cim_obj.qualifiers["Values"].value,
+ cim_obj.qualifiers["ValueMap"].value)
self._value_map = {}
self._value_map_inv = {}
self._cast_type = cast_type
# Fill two dictionaries for bidirectional access to constant values.
- for i in range(0, len(keys)):
+ cnt = 1
+ for (key, value) in items:
try:
- key = keys[i]
- val = lmi_cast_to_lmi(self._cast_type, values[i])
- self._value_map[key] = val
+ # Cast constant value first. If we get ValueError, no key
+ # modifications are necessary.
+ val = lmi_cast_to_lmi(self._cast_type, value)
+
+ # Keys can contain various undesirable characters, such as
+ # python operators, etc. So we drop them.
+ mod_key = re.sub("\W", "", key)
+ if mod_key[0].isdigit():
+ mod_key = "Key_" + mod_key
+ if mod_key in self._value_map:
+ mod_key += str(cnt)
+ cnt += 1
+ logger.warn("Constant value mapped as: '%s' -> '%s'" % (key, mod_key))
+
+ self._value_map[mod_key] = val
+ # For inverse mapping, we use unmodified key.
self._value_map_inv[val] = key
except ValueError, e:
# Can not cast such value as interval. Can be found in