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

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195544369 28800 # Node ID 5bbff08351e4c05cb8ce63fe905f6742adc9b119 # Parent a71690c7cf6caae2a3f55461980159b8d8fb92e3 Add get_rasd_instance_from_ref() to RASD. This allows other providers to get a specific RASD instance without having to do a CBGetInstance(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r a71690c7cf6c -r 5bbff08351e4 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 19 23:39:25 2007 -0800 +++ b/src/Virt_RASD.c Mon Nov 19 23:39:29 2007 -0800 @@ -176,6 +176,7 @@ static CMPIInstance *rasd_from_vdev(cons static CMPIInstance *get_rasd_instance(const CMPIContext *context, const CMPIObjectPath *ns, + const CMPIBroker *broker, const char *id, const uint16_t type) { @@ -191,13 +192,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL; - conn = lv_connect(_BROKER, &s); + conn = lv_connect(broker, &s); if (conn == NULL) goto out; dev = find_dev(conn, type, host, devid); if (dev) - inst = rasd_from_vdev(_BROKER, dev, host, NAMESPACE(ns)); + inst = rasd_from_vdev(broker, dev, host, NAMESPACE(ns)); out: virConnectClose(conn); @@ -235,6 +236,38 @@ CMPIrc rasd_type_from_classname(const ch return rc; } +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, + const CMPIObjectPath *ref, + const CMPIBroker *broker) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + char *id = NULL; + uint16_t type; + + 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(context, ref, broker, id, type); + + out: + free(id); + + return inst; +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -243,25 +276,8 @@ static CMPIStatus GetInstance(CMPIInstan { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - char *id = NULL; - uint16_t type; - - 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(context, ref, id, type); + + inst = get_rasd_instance_from_ref(context, ref, _BROKER); if (inst != NULL) CMReturnInstance(results, inst); @@ -269,7 +285,6 @@ static CMPIStatus GetInstance(CMPIInstan cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unknown instance"); - out: return s; } diff -r a71690c7cf6c -r 5bbff08351e4 src/Virt_RASD.h --- a/src/Virt_RASD.h Mon Nov 19 23:39:25 2007 -0800 +++ b/src/Virt_RASD.h Mon Nov 19 23:39:29 2007 -0800 @@ -29,6 +29,10 @@ int rasds_for_domain(const CMPIBroker *b struct inst_list *_list); CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, + const CMPIObjectPath *ref, + const CMPIBroker *broker); + #endif /*

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195544369 28800 # Node ID 5bbff08351e4c05cb8ce63fe905f6742adc9b119 # Parent a71690c7cf6caae2a3f55461980159b8d8fb92e3 Add get_rasd_instance_from_ref() to RASD.
This allows other providers to get a specific RASD instance without having to do a CBGetInstance().
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r a71690c7cf6c -r 5bbff08351e4 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 19 23:39:25 2007 -0800 +++ b/src/Virt_RASD.c Mon Nov 19 23:39:29 2007 -0800 @@ -176,6 +176,7 @@ static CMPIInstance *rasd_from_vdev(cons
static CMPIInstance *get_rasd_instance(const CMPIContext *context, const CMPIObjectPath *ns, + const CMPIBroker *broker, const char *id, const uint16_t type) { @@ -191,13 +192,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL;
- conn = lv_connect(_BROKER, &s); + conn = lv_connect(broker, &s);
Should this part be connect_by_classname() now? Other than that, looks great. -- -Jay

Jay Gagnon wrote:
Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195544369 28800 # Node ID 5bbff08351e4c05cb8ce63fe905f6742adc9b119 # Parent a71690c7cf6caae2a3f55461980159b8d8fb92e3 Add get_rasd_instance_from_ref() to RASD.
This allows other providers to get a specific RASD instance without having to do a CBGetInstance().
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r a71690c7cf6c -r 5bbff08351e4 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 19 23:39:25 2007 -0800 +++ b/src/Virt_RASD.c Mon Nov 19 23:39:29 2007 -0800 @@ -176,6 +176,7 @@ static CMPIInstance *rasd_from_vdev(cons
static CMPIInstance *get_rasd_instance(const CMPIContext *context, const CMPIObjectPath *ns, + const CMPIBroker *broker, const char *id, const uint16_t type) { @@ -191,13 +192,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL;
- conn = lv_connect(_BROKER, &s); + conn = lv_connect(broker, &s);
Should this part be connect_by_classname() now? Other than that, looks great.
Yes, thanks. I think I didn't have the connect_by_classname() patch applied when I generated this. I'll synch up my tree and resend.. =) -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

KR> +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, KR> + const CMPIObjectPath *ref, KR> + const CMPIBroker *broker) KR> +{ Since this is the expected external interface for RASDs, I would rather it take an id and a type, instead of a ref. If we're using this elsewhere later and we want to grab a RASD, having to assemble a ref just to get it would be pretty annoying :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195544365 28800 # Node ID a71690c7cf6caae2a3f55461980159b8d8fb92e3 # Parent 8cbe28df0e8e53c34c38620ce169dcea4091e72e 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. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 8cbe28df0e8e -r a71690c7cf6c src/Makefile.am --- a/src/Makefile.am Mon Nov 19 16:19:06 2007 -0500 +++ b/src/Makefile.am Mon Nov 19 23:39:25 2007 -0800 @@ -135,4 +135,4 @@ libVirt_HostedService_la_LIBADD = -lVirt libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c -libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD +libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD -lVirt_RASD diff -r 8cbe28df0e8e -r a71690c7cf6c src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Nov 19 16:19:06 2007 -0500 +++ b/src/Virt_ElementSettingData.c Mon Nov 19 23:39:25 2007 -0800 @@ -31,6 +31,7 @@ #include "misc_util.h" #include "Virt_VSSD.h" +#include "Virt_RASD.h" const static CMPIBroker *_BROKER; @@ -83,6 +84,28 @@ static CMPIStatus vssd_to_sd(const CMPIO return s; } +static CMPIStatus rasd_to_sd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + + ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); + + inst = get_rasd_instance_from_ref(info->context, ref, _BROKER); + if (inst == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Error getting associated RASD"); + } + + else + inst_list_add(list, inst); + + return s; +} + static CMPIInstance *make_ref(const CMPIObjectPath *ref, const CMPIInstance *inst, struct std_assoc_info *info, @@ -129,7 +152,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", @@ -142,8 +165,22 @@ static struct std_assoc vssd_to_sd_fd_bk .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_sd, + .make_ref = make_ref +}; + static struct std_assoc *handlers[] = { - &vssd_to_sd_fd_bkwd, + &vssd_to_vssd, + &rasd_to_rasd, NULL };

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195544365 28800 # Node ID a71690c7cf6caae2a3f55461980159b8d8fb92e3 # Parent 8cbe28df0e8e53c34c38620ce169dcea4091e72e 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.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
Looks good, +1. -- -Jay

KR> +static struct std_assoc rasd_to_rasd = { KR> + .source_class = "CIM_ResourceAllocationSettingData", KR> + .source_prop = "ManagedElement", KR> + KR> + .target_class = "CIM_ManagedElement", KR> + .target_prop = "SettingData", KR> + KR> + .assoc_class = "CIM_ElementSettingData", KR> + KR> + .handler = rasd_to_sd, KR> + .make_ref = make_ref KR> +}; A relatively minor comment, but this block confused me at first, since your function is rasd_to_sd, but your block is rasd_to_rasd. Perhaps a better name could make it more clear? I think tacking on a leading '_' to disambiguate the std_assoc block from the handler function is a reasonable way to do this (and how I've done it in the past, IIRC). -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (3)
-
Dan Smith
-
Jay Gagnon
-
Kaitlin Rupert