# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1198262431 28800
# Node ID 58166b55f2b923859186c9d4bab47778c209e032
# Parent 40de750e13d37994bee0f7031e82f612d02ebe4d
Roll DevicePool GetInstance() functionality into a seperate function.
Add this function to DevicePool.h so that other providers can use this to get a
ResourcePool instance.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 40de750e13d3 -r 58166b55f2b9 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Fri Dec 21 10:21:48 2007 -0800
+++ b/src/Virt_DevicePool.c Fri Dec 21 10:40:31 2007 -0800
@@ -712,47 +712,28 @@ static CMPIStatus return_pool(const CMPI
return s;
}
-static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
- const CMPIContext *context,
- const CMPIResult *results,
- const CMPIObjectPath *reference)
-{
- return return_pool(reference, results, true, false);
-}
-
-static CMPIStatus EnumInstances(CMPIInstanceMI *self,
- const CMPIContext *context,
- const CMPIResult *results,
- const CMPIObjectPath *reference,
- const char **properties)
-{
- return return_pool(reference, results, false, false);
-}
-
-static CMPIStatus GetInstance(CMPIInstanceMI *self,
- const CMPIContext *context,
- const CMPIResult *results,
- const CMPIObjectPath *reference,
- const char **properties)
+CMPIStatus get_pool_inst(const CMPIBroker *broker,
+ const CMPIObjectPath *reference,
+ CMPIInstance **instance)
{
CMPIStatus s;
- CMPIInstance *inst;
+ CMPIInstance *inst = NULL;
virConnectPtr conn = NULL;
const char *id = NULL;
const char *prop;
if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
+ cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"Missing InstanceID");
goto out;
}
- conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL)
goto out;
- inst = get_pool_by_id(_BROKER, conn, id, NAMESPACE(reference));
+ inst = get_pool_by_id(broker, conn, id, NAMESPACE(reference));
if (inst) {
prop = cu_compare_ref(reference, inst);
if (prop != NULL) {
@@ -760,17 +741,48 @@ static CMPIStatus GetInstance(CMPIInstan
CMPI_RC_ERR_NOT_FOUND,
"No such ResourcePool instance (%s)",
prop);
}
- CMReturnInstance(results, inst);
- CMSetStatus(&s, CMPI_RC_OK);
} else {
- cu_statusf(_BROKER, &s,
+ cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"No such instance `%s'", id);
}
-
out:
virConnectClose(conn);
+ *instance = inst;
+
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_pool(reference, results, true, false);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+ return return_pool(reference, results, false, false);
+}
+
+static CMPIStatus GetInstance(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+ CMPIStatus s;
+ CMPIInstance *inst = NULL;
+
+ s = get_pool_inst(_BROKER, reference, &inst);
+ if ((s.rc == CMPI_RC_OK) && (inst != NULL))
+ CMReturnInstance(results, inst);
return s;
}
diff -r 40de750e13d3 -r 58166b55f2b9 src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h Fri Dec 21 10:21:48 2007 -0800
+++ b/src/Virt_DevicePool.h Fri Dec 21 10:40:31 2007 -0800
@@ -74,6 +74,18 @@ CMPIStatus get_all_pools(const CMPIBroke
virConnectPtr conn,
const char *ns,
struct inst_list *list);
+
+/**
+ * Get a device pools instance for the given reference
+ *
+ * @param broker The current Broker
+ * @param reference The reference passed to the CIMOM
+ * @param instance Return corresponding instance
+ */
+CMPIStatus get_pool_inst(const CMPIBroker *broker,
+ const CMPIObjectPath *reference,
+ CMPIInstance **instance);
+
#endif
/*