This patch set includes a function that uses a resource pool InstanceID to determine the
resource type. SDC has been updated to use this function instead of using the ref's
ResourceType attribute (which might not be available).
Updates from original patchset:
Was using device_type_from_classname(), which is intended to get the resource type from
Device instance classnames. It doesn't properly support resource pool InstanceIDs.
Show replies by date
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1197394928 28800
# Node ID 23183bc1e0f3c33038cd67b69613fb081fc8c2e3
# Parent 70e9f11ed6d3ea63b342c4c3de68cc948d7c1cfd
Adding a function that returns resource type based on poolid.
The following function takes a string (the resource pool's InstanceID) and parses it
to determine the corresponding resource type.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 70e9f11ed6d3 -r 23183bc1e0f3 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Virt_DevicePool.c Tue Dec 11 09:42:08 2007 -0800
@@ -268,6 +268,20 @@ char *pool_member_of(const CMPIBroker *b
return poolid;
}
+int device_type_from_poolid(const char *id)
+{
+ if (strstr(id, "NetworkPool"))
+ return VIRT_DEV_NET;
+ else if (strstr(id, "DiskPool"))
+ return VIRT_DEV_DISK;
+ else if (strstr(id, "Memory"))
+ return VIRT_DEV_MEM;
+ else if (strstr(id, "Processor"))
+ return VIRT_DEV_VCPU;
+ else
+ return VIRT_DEV_UNKNOWN;
+}
+
static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn)
{
virNodeInfo info;
diff -r 70e9f11ed6d3 -r 23183bc1e0f3 src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Virt_DevicePool.h Tue Dec 11 09:42:08 2007 -0800
@@ -56,6 +56,13 @@ char *pool_member_of(const CMPIBroker *b
const char *id);
/**
+ * * Get the device type of a given pool from the pool's InstanceID
+ * *
+ * * @param id The InstanceID of the pool
+ * */
+int device_type_from_poolid(const char *id);
+
+/**
* Get all device pools on the system for the given connection
*
* @param broker The current Broker
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1197394944 28800
# Node ID 6c3ca59055416d7bb07716d3a750800e6087878e
# Parent 23183bc1e0f3c33038cd67b69613fb081fc8c2e3
Fix SDC - AllocationCapabilities - RASD returns error.
Querying SDC using an AllocationCapabilities instance returns: "Could not get
ResourceType". This is because SDC is expecting the AC ref to have the ResourceType
defined. But ResourceType isn't a key, so SDC can be queried without specifying a
value for ResourceType.
Instead of using the ResourceType attribute, get the resource type from the InstanceID.
Failing query:
wbemcli ai -ac Xen_SettingsDefineCapabilities
'http://localhost:5988/root/virt:Xen_AllocationCapabilities.InstanceID="ProcessorPool/0"'
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 23183bc1e0f3 -r 6c3ca5905541 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Tue Dec 11 09:42:08 2007 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Dec 11 09:42:24 2007 -0800
@@ -778,23 +778,31 @@ static CMPIStatus alloc_cap_to_rasd(cons
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK};
- int ret;
uint16_t type;
+ const char *id = NULL;
if (!match_hypervisor_prefix(ref, info))
return s;
CU_DEBUG("Getting ResourceType");
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Could not get ResourceType");
- goto out;
- }
-
+ if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing InstanceID");
+ goto out;
+ }
+
+ type = device_type_from_poolid(id);
+
CU_DEBUG("ResourceType: %hi", type);
+
+ if (type == VIRT_DEV_UNKNOWN) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine resource type");
+ goto out;
+ }
s = sdc_rasds_for_type(ref, list, type);