
# 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 /*