
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1208191444 25200 # Node ID 327cfc9f69191f5a2f0454290c8ecf02e223d4dd # Parent 2afa2a7d1d5a4e7d026f2f6cf8b5a1a8a266b5a0 Add ability to get a default pool of a given type to the pool provider Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 2afa2a7d1d5a -r 327cfc9f6919 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Apr 14 09:44:03 2008 -0700 +++ b/src/Virt_DevicePool.c Mon Apr 14 09:44:04 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, "ProcPool/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 2afa2a7d1d5a -r 327cfc9f6919 src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Mon Apr 14 09:44:03 2008 -0700 +++ b/src/Virt_DevicePool.h Mon Apr 14 09:44:04 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 /*