[PATCH 0 of 2] Updates to DevicePool

Add some external interfaces to DevicePool Unchanged from previous versions in the NetRASD set

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1208191443 25200 # Node ID 2afa2a7d1d5a4e7d026f2f6cf8b5a1a8a266b5a0 # Parent 857848be56f0bdc3480bb9f5a7ae6d0598b4d9a8 Add function to parse out pool name from InstanceID Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 857848be56f0 -r 2afa2a7d1d5a src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Apr 14 09:42:32 2008 -0700 +++ b/src/Virt_DevicePool.c Mon Apr 14 09:44:03 2008 -0700 @@ -500,6 +500,17 @@ uint16_t res_type_from_pool_id(const cha return CIM_RES_TYPE_UNKNOWN; } +char *name_from_pool_id(const char *id) +{ + char *s; + + s = strchr(id, '/'); + if (s == NULL) + return NULL; + + return strdup((char *)s+1); +} + static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn) { virNodeInfo info; diff -r 857848be56f0 -r 2afa2a7d1d5a src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Mon Apr 14 09:42:32 2008 -0700 +++ b/src/Virt_DevicePool.h Mon Apr 14 09:44:03 2008 -0700 @@ -58,6 +58,14 @@ uint16_t res_type_from_pool_id(const cha uint16_t res_type_from_pool_id(const char *id); /** + * Get the pool name from a given pool's InstanceID + * + * @param id The InstanceID of the pool + * @returns the name (must be free'd by the caller) + */ +char *name_from_pool_id(const char *id); + +/** * Get all device pools on the system for the given type * *

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

Dan Smith wrote:
# 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);
This should be ProcessorPool, which is how the InstanceID is set elsewhere. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> This should be ProcessorPool, which is how the InstanceID is set KR> elsewhere. Well, that was stupid of me :) Replacement on the way soon. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert