
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1199971252 -3600 # Node ID fd476f08b35e235ba7e50d326e5602018ebc3730 # Parent a45042de9fd40ef1cb150c854f506baf03690ed5 Make alloc_cap_instances() available for external use by EC The association provider ElementCapabilities needs the alloc_cap_instances() function to access to the list of available AllocationCapabilities. To return this instance to the association provider a CMPIInstance** is added to the parameter list. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r a45042de9fd4 -r fd476f08b35e src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Thu Jan 10 14:20:51 2008 +0100 +++ b/src/Virt_AllocationCapabilities.c Thu Jan 10 14:20:52 2008 +0100 @@ -31,6 +31,7 @@ #include "misc_util.h" +#include "Virt_AllocationCapabilities.h" #include "Virt_DevicePool.h" const static CMPIBroker *_BROKER; @@ -71,12 +72,13 @@ static CMPIStatus ac_from_pool(const CMP return s; } -static CMPIStatus alloc_cap_instances(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const CMPIResult *results, - bool names_only, - const char **properties, - const char *id) +CMPIStatus alloc_cap_instances(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + const char **properties, + const char *id, + CMPIInstance **inst) { int i; virConnectPtr conn = NULL; @@ -86,21 +88,19 @@ static CMPIStatus alloc_cap_instances(co CMPIStatus s = {CMPI_RC_OK, NULL}; const char *inst_id; - CU_DEBUG("In alloc_cap_instances()"); + if (!provider_is_responsible(broker, ref, &s)) + goto out; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Could not connect to hypervisor"); + goto out; + } inst_list_init(&device_pool_list); inst_list_init(&alloc_cap_list); - - if (!provider_is_responsible(broker, ref, &s)) - goto out; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Could not connect to hypervisor"); - goto out; - } s = get_all_pools(broker, conn, NAMESPACE(ref), &device_pool_list); if (s.rc != CMPI_RC_OK) { @@ -138,19 +138,25 @@ static CMPIStatus alloc_cap_instances(co if (id && !inst_id) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "Requested Object could not be found."); + "No such instance (%s)", id); goto out; } - if (names_only) - cu_return_instance_names(results, &alloc_cap_list); - else - cu_return_instances(results, &alloc_cap_list); + if (results) { + if (names_only) + cu_return_instance_names(results, &alloc_cap_list); + else + cu_return_instances(results, &alloc_cap_list); + } else { + if (inst) + *inst = alloc_cap_list.list[0]; + } out: virConnectClose(conn); inst_list_free(&alloc_cap_list); inst_list_free(&device_pool_list); + return s; } @@ -175,7 +181,8 @@ static CMPIStatus GetInstance(CMPIInstan results, false, properties, - id); + id, + NULL); } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -188,6 +195,7 @@ static CMPIStatus EnumInstanceNames(CMPI results, true, NULL, + NULL, NULL); } @@ -202,6 +210,7 @@ static CMPIStatus EnumInstances(CMPIInst results, false, properties, + NULL, NULL); } diff -r a45042de9fd4 -r fd476f08b35e src/Virt_AllocationCapabilities.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_AllocationCapabilities.h Thu Jan 10 14:20:52 2008 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Heidi Eckhart <heidieck@linux.vnet.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __VIRT_ALLOCATIONCAPABILITIES_H +#define __VIRT_ALLOCATIONCAPABILITIES_H + +#include "misc_util.h" + +/** + * Return the instance of the AllocationCapabilities instance, + * defined by the id + * + * @param broker A pointer to the current broker + * @param ref The reference + * @param results The results pointer used to return results to the broker + * @param names_only True returns object pathes, false returns instances + * @param properties list of properties to set + * @param id The InstanceID of the AllocationCapabilities + * @param inst Contains the instance pointer in case of success + * @returns The status of this operation + */ +CMPIStatus alloc_cap_instances(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + const char **properties, + const char *id, + CMPIInstance **inst); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */