# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1198173843 28800
# Node ID ddf699b9cf98f9258b8959676dcd915b24d25a3d
# Parent 615554f6eca4cd21e5715a3af73a616637e54f96
Replace large if-else statement in RAFP.
This can be handled using device_type_from_poolid() instead.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 615554f6eca4 -r ddf699b9cf98 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Fri Dec 14 16:13:18 2007 -0800
+++ b/src/Virt_ResourceAllocationFromPool.c Thu Dec 20 10:04:03 2007 -0800
@@ -182,6 +182,7 @@ static CMPIStatus pool_to_rasd(const CMP
{
CMPIStatus s = {CMPI_RC_OK, NULL};
const char *poolid;
+ uint16_t type;
if (!match_hypervisor_prefix(ref, info))
return s;
@@ -193,32 +194,19 @@ static CMPIStatus pool_to_rasd(const CMP
goto out;
}
- if (STARTS_WITH(poolid, "ProcessorPool"))
- rasds_from_pool(CIM_RASD_TYPE_PROC,
- ref,
- poolid,
- list);
- else if (STARTS_WITH(poolid, "MemoryPool"))
- rasds_from_pool(CIM_RASD_TYPE_MEM,
- ref,
- poolid,
- list);
- else if (STARTS_WITH(poolid, "NetworkPool"))
- rasds_from_pool(CIM_RASD_TYPE_NET,
- ref,
- poolid,
- list);
- else if (STARTS_WITH(poolid, "DiskPool"))
- rasds_from_pool(CIM_RASD_TYPE_DISK,
- ref,
- poolid,
- list);
- else {
+ type = device_type_from_poolid(poolid);
+ if (type == VIRT_DEV_UNKNOWN) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Invalid InstanceID or unsupported pool type");
goto out;
}
+
+
+ rasds_from_pool(type,
+ ref,
+ poolid,
+ list);
CMSetStatus(&s, CMPI_RC_OK);