
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1251232703 25200 # Node ID f31abcfc4e9d141c8e83adfdffee50d45b9f1e1f # Parent eb113fed5210d9d31e3b5eae684f27631c0a2ef2 Add delete_resource_in_pool to RPCS. This can be tested in a similar manner to how create_resource_in_pool() is tested. Create a storage volume within an existing pool prior to calling DeleteResourceInPool(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r eb113fed5210 -r f31abcfc4e9d src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Tue Aug 25 13:38:23 2009 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Tue Aug 25 13:38:23 2009 -0700 @@ -959,6 +959,94 @@ return s; } +static CMPIStatus delete_resource_parse_args(const CMPIArgs *argsin, + CMPIObjectPath **resource, + CMPIObjectPath **pool) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (cu_get_ref_arg(argsin, "Resource", resource) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Resource arg"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Resource'"); + goto out; + } + + if (cu_get_ref_arg(argsin, "Pool", pool) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Pool reference arg"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Pool'"); + goto out; + } + + out: + return s; +} + +static CMPIStatus delete_resource_in_pool(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + uint32_t rc = CIM_SVPC_RETURN_FAILED; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *resource; + CMPIObjectPath *pool; + const char *id = NULL; + virConnectPtr conn = NULL; + uint16_t type; + + CU_DEBUG("DeleteResourceInPool"); + + s = delete_resource_parse_args(argsin, &resource, &pool); + if (s.rc != CMPI_RC_OK) + goto out; + + if (res_type_from_rasd_classname(CLASSNAME(resource), &type) != + CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get resource type"); + goto out; + } + + if (cu_get_str_path(resource, "InstanceID", &id) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID in resource RASD"); + goto out; + } + + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "libvirt connection failed"); + goto out; + } + + if (delete_resource(conn, id, type) == 0) { + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + conn, + "Unable to delete resource"); + goto out; + } + + out: + virConnectClose(conn); + + if (s.rc == CMPI_RC_OK) + rc = CIM_SVPC_RETURN_COMPLETED; + CMReturnData(results, &rc, CMPI_uint32); + + return s; +} + static CMPIStatus dummy_handler(CMPIMethodMI *self, const CMPIContext *context, const CMPIResult *results, @@ -1014,6 +1102,15 @@ } }; +static struct method_handler DeleteResourceInPool = { + .name = "DeleteResourceInPool", + .handler = delete_resource_in_pool, + .args = {{"Resource", CMPI_ref, true}, + {"Pool", CMPI_ref, true}, + ARG_END + } +}; + static struct method_handler *my_handlers[] = { &CreateResourcePool, &CreateChildResourcePool, @@ -1021,6 +1118,7 @@ &RemoveResourcesFromResourcePool, &DeleteResourcePool, &CreateResourceInPool, + &DeleteResourceInPool, NULL, };