[Libvirt-cim] [PATCH 2 of 2] Image creation: Add support for CreateResourceInPool() method

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Aug 11 20:19:26 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1245187550 25200
# Node ID 2fb0663546797c7781119063dc6ad3af2c090e83
# Parent  ffc93d36908aa5fca483fc650393802383409890
Image creation:  Add support for CreateResourceInPool() method

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r ffc93d36908a -r 2fb066354679 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c	Tue Jun 16 14:25:50 2009 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c	Tue Jun 16 14:25:50 2009 -0700
@@ -784,6 +784,9 @@
         CMPIObjectPath *pool;
         struct virt_pool_res *res = NULL;
         const char* msg = NULL;
+        const char *id = NULL;
+        char *pool_id = NULL;
+        char *xml = NULL;
 
         CU_DEBUG("CreateResourceInPool");
 
@@ -808,12 +811,44 @@
                 goto out;
         }
 
+        if (cu_get_str_path(pool, "InstanceID", &id) != CMPI_RC_OK) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Missing InstanceID in resource pool");
+                goto out;
+        }
+
+        pool_id = name_from_pool_id(id);
+        if (pool_id == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_INVALID_PARAMETER,
+                           "Pool has invalid InstanceID");
+                goto out;
+        }
+
+        free(res->pool_id);
+        res->pool_id = strdup(pool_id);
+
+        xml = res_to_xml(res);
+        if (xml == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to generate XML for new resource");
+                goto out;
+        }
+
+        CU_DEBUG("New resource XML:\n%s", xml);
+
+        /*FIXME: Add resource here */
+
+ out:
+        free(pool_id);
+        free(xml);
+
         if (s.rc == CMPI_RC_OK)
                 rc = CIM_SVPC_RETURN_COMPLETED;
         CMReturnData(results, &rc, CMPI_uint32);
 
- out:
-
         return s;
 }
 




More information about the Libvirt-cim mailing list