# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1249937578 25200
# Node ID 615da7491c145fa283e658df520fd9e31615f4d4
# Parent aa8fb78cb7fc77496f962e80b2ff2468f91a6625
Pull config options from params to CreateResourceInPool()
Store configuration options into a virt_pool_resource struct. This struct will
be used when creating a new image.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r aa8fb78cb7fc -r 615da7491c14 src/Virt_RASD.c
--- a/src/Virt_RASD.c Mon Aug 10 13:52:57 2009 -0700
+++ b/src/Virt_RASD.c Mon Aug 10 13:52:58 2009 -0700
@@ -592,6 +592,8 @@
*type = CIM_RES_TYPE_GRAPHICS;
else if (STREQ(base, "InputResourceAllocationSettingData"))
*type = CIM_RES_TYPE_INPUT;
+ else if (STREQ(base, "StorageVolumeResourceAllocationSettingData"))
+ *type = CIM_RES_TYPE_IMAGE;
else
goto out;
diff -r aa8fb78cb7fc -r 615da7491c14 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Mon Aug 10 13:52:57 2009 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c Mon Aug 10 13:52:58 2009 -0700
@@ -690,6 +690,87 @@
return s;
}
+static const char *storage_vol_rasd_to_res(CMPIInstance *inst,
+ struct virt_pool_res *res)
+{
+ uint16_t int_val;
+ const char *val;
+ const char *msg;
+
+ if (cu_get_u16_prop(inst, "FormatType", &int_val) != CMPI_RC_OK) {
+ msg = "StorageVolumeRASD FormatType field not valid";
+ goto out;
+ }
+ res->res.storage_vol.format_type = int_val;
+
+ if (cu_get_str_prop(inst, "VolumeName", &val) != CMPI_RC_OK) {
+ msg = "StorageVolumeRASD VolumeName field not valid";
+ goto out;
+ }
+ free(res->res.storage_vol.vol_name);
+ res->res.storage_vol.vol_name = strdup(val);
+
+ if (cu_get_str_prop(inst, "Path", &val) != CMPI_RC_OK) {
+ msg = "StorageVolumeRASD Path field not valid";
+ goto out;
+ }
+ free(res->res.storage_vol.path);
+ res->res.storage_vol.path = strdup(val);
+
+ if (cu_get_u16_prop(inst, "AllocationQuantity", &int_val) ==
CMPI_RC_OK)
+ res->res.storage_vol.alloc = int_val;
+
+ if (cu_get_u16_prop(inst, "Capacity", &int_val) != CMPI_RC_OK) {
+ msg = "StorageVolumeRASD Capacity field not valid";
+ goto out;
+ }
+ res->res.storage_vol.cap = int_val;
+
+ free(res->res.storage_vol.cap_units);
+ if (cu_get_str_prop(inst, "AllocationUnits", &val) != CMPI_RC_OK)
+ res->res.storage_vol.cap_units = strdup("G");
+ else
+ res->res.storage_vol.cap_units = strdup(val);
+
+ out:
+
+ return msg;
+}
+
+static const char *rasd_to_res(CMPIInstance *inst,
+ struct virt_pool_res *res,
+ const char *ns)
+{
+ uint16_t type;
+ CMPIObjectPath *op;
+ const char *msg = NULL;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL) {
+ msg = "Unable to get path for resource instance";
+ goto out;
+ }
+
+ if (res_type_from_rasd_classname(CLASSNAME(op), &type) != CMPI_RC_OK) {
+ msg = "Unable to get resource type";
+ goto out;
+ }
+
+ res->type = (int)type;
+
+ if (type == CIM_RES_TYPE_IMAGE) {
+ msg = storage_vol_rasd_to_res(inst, res);
+ }
+ else
+ msg = "This function does not support this resource type";
+
+ out:
+ if (msg)
+ CU_DEBUG("rasd_to_res(%s): %s", CLASSNAME(op), msg);
+
+ return msg;
+}
+
static CMPIStatus create_resource_in_pool(CMPIMethodMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -701,6 +782,8 @@
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *settings;
CMPIObjectPath *pool;
+ struct virt_pool_res *res = NULL;
+ const char* msg = NULL;
CU_DEBUG("CreateResourceInPool");
@@ -708,6 +791,23 @@
if (s.rc != CMPI_RC_OK)
goto out;
+ res = calloc(1, sizeof(*res));
+ if (res == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to allocate new resource struct");
+ goto out;
+ }
+
+ msg = rasd_to_res(settings, res, NAMESPACE(reference));
+ if (msg != NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get attributes for resource: %s",
+ msg);
+ goto out;
+ }
+
if (s.rc == CMPI_RC_OK)
rc = CIM_SVPC_RETURN_COMPLETED;
CMReturnData(results, &rc, CMPI_uint32);