[Libvirt-cim] [PATCH 2 of 2] Adding the RASD related part

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Nov 26 17:38:50 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1196101928 28800
# Node ID 38cc6833481dd27b1d2d451b81e74aaf8f900944
# Parent  278c59f67cb1fe0520e8dfa7b118cd907e8f10a1
Adding the RASD related part.

This is based on the Resource Allocation Profile.  My understanding is that we are implementing a setup similar to Figure 3 on page 31.  In this case, we'll use the same RASD instance for State as well as Defined.

Updated to due to change in get_rasd_instance_from_ref().  Also updated structure and handler function names to avoid confusion.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 278c59f67cb1 -r 38cc6833481d src/Makefile.am
--- a/src/Makefile.am	Tue Nov 20 16:26:00 2007 -0500
+++ b/src/Makefile.am	Mon Nov 26 10:32:08 2007 -0800
@@ -133,6 +133,6 @@ libVirt_HostedService_la_SOURCES = Virt_
 libVirt_HostedService_la_SOURCES = Virt_HostedService.c
 libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService -lVirt_ResourcePoolConfigurationService
 
-libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la
+libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_RASD.la
 libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c
-libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD
+libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD -lVirt_RASD
diff -r 278c59f67cb1 -r 38cc6833481d src/Virt_ElementSettingData.c
--- a/src/Virt_ElementSettingData.c	Tue Nov 20 16:26:00 2007 -0500
+++ b/src/Virt_ElementSettingData.c	Mon Nov 26 10:32:08 2007 -0800
@@ -31,12 +31,13 @@
 #include "misc_util.h"
 
 #include "Virt_VSSD.h"
+#include "Virt_RASD.h"
 
 const static CMPIBroker *_BROKER;
 
-static CMPIStatus vssd_to_sd(const CMPIObjectPath *ref,
-                             struct std_assoc_info *info,
-                             struct inst_list *list)
+static CMPIStatus vssd_to_vssd(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
 {
         CMPIStatus s;
         CMPIInstance *inst;
@@ -83,6 +84,49 @@ static CMPIStatus vssd_to_sd(const CMPIO
         return s;
 }
 
+static CMPIStatus rasd_to_rasd(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst;
+        char *id = NULL;
+        uint16_t type;
+
+        ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
+
+        id = cu_get_str_path(ref, "InstanceID");
+        if (id == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Missing InstanceID");
+                goto out;
+        }
+
+        if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to determine RASD type");
+                goto out;
+        }
+
+        inst = get_rasd_instance(info->context, ref, _BROKER, id, type);
+        if (inst == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Error getting associated RASD");
+
+                goto out;
+        }
+
+        inst_list_add(list, inst);
+
+ out:
+        free(id);
+
+        return s;
+}
+
 static CMPIInstance *make_ref(const CMPIObjectPath *ref,
                               const CMPIInstance *inst,
                               struct std_assoc_info *info,
@@ -130,7 +174,7 @@ out:
         return refinst;
 }
 
-static struct std_assoc vssd_to_sd_fd_bkwd = {
+static struct std_assoc _vssd_to_vssd = {
         .source_class = "CIM_VirtualSystemSettingData",
         .source_prop = "ManagedElement",
 
@@ -139,12 +183,26 @@ static struct std_assoc vssd_to_sd_fd_bk
 
         .assoc_class = "CIM_ElementSettingData",
 
-        .handler = vssd_to_sd,
+        .handler = vssd_to_vssd,
         .make_ref = make_ref
 };
 
+static struct std_assoc _rasd_to_rasd = {
+        .source_class = "CIM_ResourceAllocationSettingData",
+        .source_prop = "ManagedElement",
+
+        .target_class = "CIM_ManagedElement",
+        .target_prop = "SettingData",
+
+        .assoc_class = "CIM_ElementSettingData",
+
+        .handler = rasd_to_rasd,
+        .make_ref = make_ref
+};
+
 static struct std_assoc *handlers[] = {
-        &vssd_to_sd_fd_bkwd,
+        &_vssd_to_vssd,
+        &_rasd_to_rasd,
         NULL
 };
 




More information about the Libvirt-cim mailing list