# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1208196681 25200
# Node ID 4d7ede1d251ba8c8982a2bc65f53b8de3982a04e
# Parent b342662208d69fb8f3c7189b1f227e3dff04fd59
Add ability to get a default pool of a given type to the pool provider
Changes:
- Make ProcPool ProcessorPool
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r b342662208d6 -r 4d7ede1d251b src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Mon Apr 14 10:57:32 2008 -0700
+++ b/src/Virt_DevicePool.c Mon Apr 14 11:11:21 2008 -0700
@@ -991,6 +991,39 @@ CMPIStatus enum_pools(const CMPIBroker *
return _get_pools(broker, reference, type, NULL, list);
}
+CMPIInstance *default_device_pool(const CMPIBroker *broker,
+ const CMPIObjectPath *reference,
+ uint16_t type,
+ CMPIStatus *s)
+{
+ CMPIInstance *inst = NULL;
+ struct inst_list list;
+
+ inst_list_init(&list);
+
+ if (type == CIM_RES_TYPE_MEM) {
+ *s = get_pool_by_name(broker, reference, "MemoryPool/0",
&inst);
+ } else if (type == CIM_RES_TYPE_PROC) {
+ *s = get_pool_by_name(broker, reference, "ProcessorPool/0",
&inst);
+ } else if (type == CIM_RES_TYPE_DISK) {
+ *s = enum_pools(broker, reference, type, &list);
+ if (s->rc == CMPI_RC_OK)
+ inst = list.list[0];
+ } else if (type == CIM_RES_TYPE_NET) {
+ *s = enum_pools(broker, reference, type, &list);
+ if (s->rc == CMPI_RC_OK)
+ inst = list.list[0];
+ } else {
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "No such device type `%s'", type);
+ }
+
+ inst_list_free(&list);
+
+ return inst;
+}
+
static CMPIStatus return_pool(const CMPIObjectPath *ref,
const CMPIResult *results,
bool names_only)
diff -r b342662208d6 -r 4d7ede1d251b src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h Mon Apr 14 10:57:32 2008 -0700
+++ b/src/Virt_DevicePool.h Mon Apr 14 11:11:21 2008 -0700
@@ -105,6 +105,20 @@ CMPIStatus get_pool_by_name(const CMPIBr
const char *id,
CMPIInstance **_inst);
+/**
+ * Get the default pool for a given device type
+ *
+ * @param broker A pointer to the current broker
+ * @param ref The object path containing namespace and prefix info
+ * @param type The device type in question
+ * @param status The returned status
+ * @returns Default instance of a pool
+ */
+CMPIInstance *default_device_pool(const CMPIBroker *broker,
+ const CMPIObjectPath *reference,
+ uint16_t type,
+ CMPIStatus *status);
+
#endif
/*