[PATCH 0 of 2] Updated ElementSettingData to support RASD instances.

Revised so that get_rasd_instance() is no longer static. This function should be used by other providers - there isn't a need for a new function. Also, cleaned up some of the confusion structure / function names in Virt_ElementSettingData. Fixed whitespace issues in Virt_RASD.h

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195662213 28800 # Node ID 140613919317633ad4b325b6321809849ecfbd41 # Parent 38cc6833481dd27b1d2d451b81e74aaf8f900944 Remove static from get_rasd_instance() Add get_rasd_instance() declaration to header file. Also add an additional broker argument so other providers can call this function. Fixed minor mem leak in GetInstance(). fixed whitespace issue in Virt_RASD.h Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 38cc6833481d -r 140613919317 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 26 10:32:08 2007 -0800 +++ b/src/Virt_RASD.c Wed Nov 21 08:23:33 2007 -0800 @@ -177,10 +177,11 @@ static CMPIInstance *rasd_from_vdev(cons return inst; } -static CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ref, - const char *id, - const uint16_t type) +CMPIInstance *get_rasd_instance(const CMPIContext *context, + const CMPIObjectPath *ref, + const CMPIBroker *broker, + const char *id, + const uint16_t type) { CMPIInstance *inst = NULL; CMPIStatus s; @@ -194,13 +195,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) goto out; dev = find_dev(conn, type, host, devid); if (dev) - inst = rasd_from_vdev(_BROKER, dev, host, ref); + inst = rasd_from_vdev(broker, dev, host, ref); out: virConnectClose(conn); @@ -264,7 +265,7 @@ static CMPIStatus GetInstance(CMPIInstan goto out; } - inst = get_rasd_instance(context, ref, id, type); + inst = get_rasd_instance(context, ref, _BROKER, id, type); if (inst != NULL) CMReturnInstance(results, inst); @@ -273,6 +274,8 @@ static CMPIStatus GetInstance(CMPIInstan CMPI_RC_ERR_FAILED, "Unknown instance"); out: + free(id); + return s; } diff -r 38cc6833481d -r 140613919317 src/Virt_RASD.h --- a/src/Virt_RASD.h Mon Nov 26 10:32:08 2007 -0800 +++ b/src/Virt_RASD.h Wed Nov 21 08:23:33 2007 -0800 @@ -41,6 +41,12 @@ int rasds_for_domain(const CMPIBroker *b CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); +CMPIInstance *get_rasd_instance(const CMPIContext *context, + const CMPIObjectPath *ref, + const CMPIBroker *broker, + const char *id, + const uint16_t type); + #endif /*

# HG changeset patch # User Kaitlin Rupert <karupert@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@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 };
participants (1)
-
Kaitlin Rupert