# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193761666 25200
# Node ID 02556a928bf33c5f796009ae4ad2fb1cd37d6283
# Parent 6f68b7da0f6bfa6f1c709f56b2879c62e8831639
Make RASD not dependent on ResourceType key
I have tested DefineSystem() and some of the ResourcePool associations.
(removed the AllocationCapabilities changes)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 6f68b7da0f6b -r 02556a928bf3 schema/KVM_ResourceAllocationSettingData.mof
--- a/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 09:25:06 2007 -0700
+++ b/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 09:27:46 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class KVM_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 6f68b7da0f6b -r 02556a928bf3 schema/Xen_ResourceAllocationSettingData.mof
--- a/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 09:25:06 2007 -0700
+++ b/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 09:27:46 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class Xen_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Makefile.am
--- a/src/Makefile.am Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Makefile.am Tue Oct 30 09:27:46 2007 -0700
@@ -83,8 +83,10 @@ libVirt_ElementCapabilities_la_LIBADD =
-lVirt_HostSystem
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
+libVirt_AllocationCapabilities_la_LIBADD = -lVirt_RASD
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
+libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD
libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_RASD.c Tue Oct 30 09:27:46 2007 -0700
@@ -205,10 +205,38 @@ static CMPIInstance *get_rasd_instance(c
return inst;
}
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type)
+{
+ char *base = NULL;
+ CMPIrc rc = CMPI_RC_ERR_FAILED;
+
+ base = class_base_name(cn);
+ if (base == NULL)
+ goto out;
+
+ if (STREQ(base, "DiskResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_DISK;
+ else if (STREQ(base, "NetResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_NET;
+ else if (STREQ(base, "ProcResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_PROC;
+ else if (STREQ(base, "MemResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_MEM;
+ else
+ goto out;
+
+ rc = CMPI_RC_OK;
+
+ out:
+ free(base);
+
+ return rc;
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
- const CMPIObjectPath *reference,
+ const CMPIObjectPath *ref,
const char **properties)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -216,7 +244,7 @@ static CMPIStatus GetInstance(CMPIInstan
char *id = NULL;
uint16_t type;
- id = cu_get_str_path(reference, "InstanceID");
+ id = cu_get_str_path(ref, "InstanceID");
if (id == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -224,14 +252,14 @@ static CMPIStatus GetInstance(CMPIInstan
goto out;
}
- if (!cu_get_u16_path(reference, "ResourceType", &type)) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Missing or invalid ResourceType");
- goto out;
- }
-
- inst = get_rasd_instance(context, reference, id, type);
+ "Unable to determine RASD type");
+ goto out;
+ }
+
+ inst = get_rasd_instance(context, ref, id, type);
if (inst != NULL)
CMReturnInstance(results, inst);
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_RASD.h
--- a/src/Virt_RASD.h Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_RASD.h Tue Oct 30 09:27:46 2007 -0700
@@ -27,6 +27,7 @@ int rasds_for_domain(const CMPIBroker *b
const uint16_t type,
const char *ns,
struct inst_list *_list);
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
#endif
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 09:27:46 2007 -0700
@@ -42,7 +42,6 @@ static CMPIStatus rasd_to_pool(const CMP
struct inst_list *list)
{
CMPIStatus s;
- int ret;
uint16_t type;
char *id = NULL;
char *poolid = NULL;
@@ -52,11 +51,10 @@ static CMPIStatus rasd_to_pool(const CMP
inst_list_init(&_list);
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
@@ -113,8 +111,16 @@ static int filter_by_pool(struct inst_li
for (i = 0; i < src->cur; i++) {
CMPIInstance *inst = src->list[i];
-
- cu_get_u16_prop(inst, "ResourceType", &type);
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
+ continue;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
+ continue;
+
cu_get_str_prop(inst, "InstanceID", &rasd_id);
poolid = pool_member_of(_BROKER, type, rasd_id);
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Oct 30 09:27:46 2007 -0700
@@ -37,6 +37,7 @@
#include "svpc_types.h"
#include "Virt_SettingsDefineCapabilities.h"
+#include "Virt_RASD.h"
const static CMPIBroker *_BROKER;
@@ -315,13 +316,11 @@ static CMPIStatus alloc_cap_to_rasd(cons
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK};
- int ret;
uint16_t type;
CU_DEBUG("Getting ResourceType.\n");
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != 1) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED,
"Could not get ResourceType.");
goto out;
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_SettingsDefineState.c Tue Oct 30 09:27:46 2007 -0700
@@ -162,7 +162,6 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s;
CMPIInstance *dev = NULL;
char *id = NULL;
- int ret;
uint16_t type;
ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
@@ -175,8 +174,7 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing ResourceType");
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Tue Oct 30 09:27:46 2007 -0700
@@ -158,9 +158,15 @@ static int rasd_to_vdev(CMPIInstance *in
char *id = NULL;
char *name = NULL;
char *devid = NULL;
-
- if (cu_get_u16_prop(inst, "ResourceType", &type) != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
goto err;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK)
+ goto err;
+
dev->type = (int)type;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK)
@@ -207,7 +213,6 @@ static int classify_resources(struct ins
static int classify_resources(struct inst_list *all,
struct domain *domain)
{
- int ret;
int i;
uint16_t type;
@@ -220,8 +225,14 @@ static int classify_resources(struct ins
domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
for (i = 0; i < all->cur; i++) {
- ret = cu_get_u16_prop(all->list[i], "ResourceType",
&type);
- if (ret != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(all->list[i], NULL);
+ if (op == NULL)
+ return 0;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
return 0;
if (type == CIM_RASD_TYPE_PROC)
@@ -682,6 +693,7 @@ static CMPIStatus _update_resources_for(
struct domain *dominfo = NULL;
uint16_t type;
char *xml = NULL;
+ CMPIObjectPath *op;
if (!get_dominfo(dom, &dominfo)) {
cu_statusf(_BROKER, &s,
@@ -690,10 +702,18 @@ static CMPIStatus _update_resources_for(
goto out;
}
- if (cu_get_u16_prop(rasd, "ResourceType", &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ op = CMGetObjectPath(rasd, NULL);
+ if (op == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get RASD path");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}