[cmpi-bindings] Fixed passing NULL array from get_instance, Add bindings for CMTraceMessage

vcrhonek vcrhonek at fedoraproject.org
Thu Jan 10 12:31:07 UTC 2013


commit 8b0964e90881ea5fcc30635fe60bf7c00585d284
Author: Vitezslav Crhonek <vcrhonek at redhat.com>
Date:   Thu Jan 10 13:30:54 2013 +0100

    Fixed passing NULL array from get_instance, Add bindings for CMTraceMessage

 cmpi-bindings-0.5.2-null.patch  |   30 ++++++++++++++++
 cmpi-bindings-0.5.2-trace.patch |   71 +++++++++++++++++++++++++++++++++++++++
 cmpi-bindings.spec              |   13 ++++++-
 3 files changed, 113 insertions(+), 1 deletions(-)
---
diff --git a/cmpi-bindings-0.5.2-null.patch b/cmpi-bindings-0.5.2-null.patch
new file mode 100644
index 0000000..f7969b6
--- /dev/null
+++ b/cmpi-bindings-0.5.2-null.patch
@@ -0,0 +1,30 @@
+diff -up cmpi-bindings-0.5.2/swig/cmpi.i.orig cmpi-bindings-0.5.2/swig/cmpi.i
+--- cmpi-bindings-0.5.2/swig/cmpi.i.orig	2013-01-10 08:45:50.640372951 +0100
++++ cmpi-bindings-0.5.2/swig/cmpi.i	2013-01-10 08:54:10.930703349 +0100
+@@ -258,11 +258,10 @@ data_value(const CMPIData *dp)
+   else if (dp->state & (unsigned short)CMPI_badValue) {
+     SWIG_exception(SWIG_ValueError, "bad value");
+   }
+-  else if (dp->state & CMPI_nullValue) {
+-    result = Target_Null;
+-    Target_INCREF(result);
++  else if (dp->state & CMPI_null) {
++    result = value_value(&(dp->value), CMPI_null);
+   }
+-  else if ((dp->type) & CMPI_ARRAY) {
++  else if (!(dp->state & CMPI_nullValue) && (dp->type & CMPI_ARRAY)) {
+     int size = CMGetArrayCount(dp->value.array, NULL);
+     int i;
+     result = Target_SizedArray(size);
+diff -up cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py.orig cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py
+--- cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py.orig	2013-01-10 08:50:28.072663502 +0100
++++ cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py	2013-01-10 08:52:04.124110228 +0100
+@@ -872,6 +872,8 @@ class CMPIProxyProvider(object):
+     def cmpi2pywbem_data(self, cdata, _type=None, is_array=None):
+         #TODO check for valid cdata.state
+         #TODO error handling
++        if (cdata.state & cmpi.CMPI_nullValue) > 0:
++            return None
+         if _type is None:
+             _type, is_array = _cmpi_type2string(cdata.type)
+         attr = _type
diff --git a/cmpi-bindings-0.5.2-trace.patch b/cmpi-bindings-0.5.2-trace.patch
new file mode 100644
index 0000000..ade8a8d
--- /dev/null
+++ b/cmpi-bindings-0.5.2-trace.patch
@@ -0,0 +1,71 @@
+diff -up cmpi-bindings-0.5.2/swig/cmpi_callbacks.i.trace cmpi-bindings-0.5.2/swig/cmpi_callbacks.i
+--- cmpi-bindings-0.5.2/swig/cmpi_callbacks.i.trace	2012-05-04 15:47:18.000000000 +0200
++++ cmpi-bindings-0.5.2/swig/cmpi_callbacks.i	2012-12-05 09:18:07.044502907 +0100
+@@ -44,6 +44,14 @@ typedef struct _CMPIBroker {} CMPIBroker
+     RAISE_IF(CMLogMessage($self, severity, id, text, NULL)); 
+   }
+ 
++  void TraceMessage(
++    int severity, 
++    const char *component, 
++    const char *text) 
++  {
++    RAISE_IF(CMTraceMessage($self, severity, component, text, NULL)); 
++  }
++
+   int version() 
+   {
+     return CBBrokerVersion($self);
+diff -up cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py.trace cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py
+--- cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py.trace	2012-12-05 09:18:07.040502914 +0100
++++ cmpi-bindings-0.5.2/swig/python/cmpi_pywbem_bindings.py	2012-12-05 09:49:03.673962824 +0100
+@@ -384,6 +384,12 @@ _log_pri_map = {
+         cmpi.CMPI_DEV_DEBUG    :syslog.LOG_DEBUG,
+         }
+ 
++_trace_prefix_map = {
++    cmpi.CMPI_LEV_VERBOSE      :"DEBG",
++    cmpi.CMPI_LEV_INFO         :"INFO",
++    cmpi.CMPI_LEV_WARNING      :"WARN",
++}
++
+ class Logger(object):
+     def __init__(self, broker, miname):
+         #self.broker = ExceptionClassWrapper(broker)
+@@ -396,6 +402,14 @@ class Logger(object):
+             if e.get_error_code() == cmpi.CMPI_RC_ERR_NOT_SUPPORTED: 
+                 syslog.syslog(syslog.LOG_DAEMON | _log_pri_map[severity], 
+                         '%s: %s' % (self.miname, msg))
++    def __trace_message(self, severity, component, msg):
++        try:
++            self.broker.TraceMessage(severity, component, msg);
++        except cmpi.CMPIException, e:
++            if e.get_error_code() == cmpi.CMPI_RC_ERR_NOT_SUPPORTED:
++                # fall back to log_debug if tracing is not supported
++                self.log_debug("%s:%s: %s" % (
++                        component, _trace_prefix_map[severity], msg))
+     def log_error(self, msg):
+         self.__log_message(cmpi.CMPI_SEV_ERROR, msg);
+     def log_info(self, msg):
+@@ -404,6 +418,12 @@ class Logger(object):
+         self.__log_message(cmpi.CMPI_SEV_WARNING, msg);
+     def log_debug(self, msg):
+         self.__log_message(cmpi.CMPI_DEV_DEBUG, msg);
++    def trace_verbose(self, component, msg):
++        self.__trace_message(cmpi.CMPI_LEV_VERBOSE, component, msg)
++    def trace_info(self, component, msg):
++        self.__trace_message(cmpi.CMPI_LEV_INFO, component, msg)
++    def trace_warn(self, component, msg):
++        self.__trace_message(cmpi.CMPI_LEV_WARNING, component, msg)
+ 
+ class ProviderEnvironment(object):
+     def __init__(self, proxy, ctx):
+@@ -437,7 +457,7 @@ class CMPIProxyProvider(object):
+         env = ProviderEnvironment(self, None)
+         provmod = miname
+         if provmod[0] != '/':
+-            provmod = '/usr/lib/pycim/' + provmod
++            provmod = '/usr/lib/python2.7/site-packages/pycim/' + provmod
+         if not provmod.endswith('.py'):
+             provmod+= '.py'
+         self.proxy = ProviderProxy(env, provmod)
diff --git a/cmpi-bindings.spec b/cmpi-bindings.spec
index 5b3dbf4..f8d5e3f 100644
--- a/cmpi-bindings.spec
+++ b/cmpi-bindings.spec
@@ -1,6 +1,6 @@
 Name:           cmpi-bindings
 Version:        0.5.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Adapter to write and run CMPI-type CIM providers
 
 Group:          Development/Libraries
@@ -17,6 +17,10 @@ Source0:         %{name}-%{version}.tar.bz2
 Patch0:         cmpi-bindings-0.4.17-no-ruby-perl.patch
 #Patch1: removes workaround no longer needed
 Patch1:         cmpi-bindings-0.4.17-sblim-sigsegv.patch
+#Patch2: bz#883041, fixes passing passing NULL array from get_instance
+Patch2:         cmpi-bindings-0.5.2-null.patch
+#Patch3: bz#883462, adds bindings for CMTraceMessage
+Patch3:         cmpi-bindings-0.5.2-trace.patch
 
 BuildRequires:  cmake gcc-c++ swig >= 1.3.34
 BuildRequires:  curl-devel pkgconfig sed
@@ -40,6 +44,8 @@ CMPI-compliant provider interface for Python
 %setup -q
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
+%patch3 -p1
 
 # change hardcoded path from /usr/lib/pycim/ to something better
 sed -i 's@/usr/lib/pycim/@'`echo %{python_sitelib}/pycim/`'@' swig/python/cmpi_pywbem_bindings.py
@@ -92,6 +98,11 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Thu Jan 10 2013 Vitezslav Crhonek <vcrhonek at redhat.com> - 0.5.2-3
+- Fixed passing NULL array from get_instance
+- Add bindings for CMTraceMessage
+  (patches by Jan Safranek)
+
 * Wed Jul 18 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.5.2-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 


More information about the scm-commits mailing list