[Libvirt-cim] [PATCH] Add method to merge RASDs

Sharad Mishra snmishra at us.ibm.com
Wed Dec 8 20:56:55 UTC 2010


# HG changeset patch
# User Sharad Mishra <snmishra at us.ibm.com>
# Date 1291841067 28800
# Node ID 531f151df659f030fe4fab1f6663572af356935f
# Parent  f967d9432f317685981a5b8552f049a9b644a33f
Add method to merge RASDs.

This method will take two RASDs, src and dest, and  merge the  two into dest.

Signed-off-by: Sharad Mishra <snmishra at us.ibm.com>

diff -r f967d9432f31 -r 531f151df659 instance_util.c
--- a/instance_util.c	Wed Oct 06 09:31:05 2010 -0700
+++ b/instance_util.c	Wed Dec 08 12:44:27 2010 -0800
@@ -253,6 +253,46 @@
         return dest;
 }
 
+
+CMPIStatus cu_merge_instances(CMPIInstance *src,
+                              CMPIInstance *dest)
+{
+
+        int i;
+        int prop_count;
+        CMPIData data;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+
+        CU_DEBUG("Merging instances");
+        prop_count = CMGetPropertyCount(src, &s);
+        if (s.rc != CMPI_RC_OK) {
+                CU_DEBUG("Could not get property count for merge");
+                goto out;
+        }
+
+        CU_DEBUG("Property count is %d", prop_count);
+        for (i = 0; i < prop_count; i++) {
+                CMPIString *prop;
+                const char *prop_name;
+
+                data = CMGetPropertyAt(src, i, &prop, &s);
+                if (s.rc != CMPI_RC_OK) {
+                        goto out;
+                }
+
+                prop_name = CMGetCharPtr(prop);
+
+                if(data.state == 0 ) {
+                       CU_DEBUG("setting prop %s", prop_name);
+                       CMSetProperty(dest, prop_name,
+                                     &(data.value), data.type);
+                }
+        }
+
+ out:
+        return s;
+}
+
 const char *cu_classname_from_inst(CMPIInstance *inst)
 {
         const char *ret = NULL;
diff -r f967d9432f31 -r 531f151df659 libcmpiutil.h
--- a/libcmpiutil.h	Wed Oct 06 09:31:05 2010 -0700
+++ b/libcmpiutil.h	Wed Dec 08 12:44:27 2010 -0800
@@ -167,6 +167,17 @@
                        uint16_t *target);
 
 /**
+ * Merge src and dest instances to dest.
+ *
+ * @param src Source instance
+ * @param dest Destination instance
+ * @returns {CMPI_RC_OK, NULL} if success, CMPI_RC ERR_FAILED and 
+ *          error message otherwise
+ */
+CMPIStatus cu_merge_instances(CMPIInstance *src,
+                                 CMPIInstance *dest);
+
+/**
  * Create a copy of an instance
  *
  * @param src Source instance




More information about the Libvirt-cim mailing list