
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1200052159 -3600 # Node ID 224b84cf00ac2e120d86e15d92ce50fddf6a0105 # Parent ec66d30629f4584ca30751ce3e079f5561f2985a Make alloc_cap_instances() available for external use by EC The association provider ElementCapabilities needs the enum_alloc_cap_instances() function to access to the list of available AllocationCapabilities. These are returned by the additional inst_list parameter. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r ec66d30629f4 -r 224b84cf00ac src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Fri Jan 11 12:49:18 2008 +0100 +++ b/src/Virt_AllocationCapabilities.c Fri Jan 11 12:49:19 2008 +0100 @@ -31,6 +31,7 @@ #include "misc_util.h" +#include "Virt_AllocationCapabilities.h" #include "Virt_DevicePool.h" const static CMPIBroker *_BROKER; @@ -71,30 +72,26 @@ 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 enum_alloc_cap_instances(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const char **properties, + const char *id, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *alloc_cap_inst; + virConnectPtr conn = NULL; + struct inst_list device_pool_list; + const char *inst_id; int i; - virConnectPtr conn = NULL; - CMPIInstance *alloc_cap_inst; - struct inst_list alloc_cap_list; - struct inst_list device_pool_list; - CMPIStatus s = {CMPI_RC_OK, NULL}; - const char *inst_id; - - CU_DEBUG("In alloc_cap_instances()"); - + + inst_list_init(list); 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); + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -129,7 +126,7 @@ static CMPIStatus alloc_cap_instances(co if (s.rc != CMPI_RC_OK) goto out; - inst_list_add(&alloc_cap_list, alloc_cap_inst); + inst_list_add(list, alloc_cap_inst); if (id && (STREQ(inst_id, id))) break; @@ -141,16 +138,40 @@ static CMPIStatus alloc_cap_instances(co "Requested Object could not be found."); goto out; } - - if (names_only) - cu_return_instance_names(results, &alloc_cap_list); - else - cu_return_instances(results, &alloc_cap_list); - + out: virConnectClose(conn); - inst_list_free(&alloc_cap_list); inst_list_free(&device_pool_list); + + return s; +} + +static CMPIStatus return_alloc_cap_instances(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + const char **properties, + const char *id) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct inst_list *list = NULL; + + s = enum_alloc_cap_instances(broker, + ref, + properties, + id, + list); + if (s.rc != CMPI_RC_OK) + goto out; + + if (names_only) + cu_return_instance_names(results, list); + else + cu_return_instances(results, list); + + out: + inst_list_free(list); + return s; } @@ -170,12 +191,12 @@ static CMPIStatus GetInstance(CMPIInstan return s; } - return alloc_cap_instances(_BROKER, - reference, - results, - false, - properties, - id); + return return_alloc_cap_instances(_BROKER, + reference, + results, + false, + properties, + id); } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -183,12 +204,12 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return alloc_cap_instances(_BROKER, - reference, - results, - true, - NULL, - NULL); + return return_alloc_cap_instances(_BROKER, + reference, + results, + true, + NULL, + NULL); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -197,12 +218,12 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return alloc_cap_instances(_BROKER, - reference, - results, - false, - properties, - NULL); + return return_alloc_cap_instances(_BROKER, + reference, + results, + false, + properties, + NULL); } DEFAULT_CI(); diff -r ec66d30629f4 -r 224b84cf00ac src/Virt_AllocationCapabilities.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_AllocationCapabilities.h Fri Jan 11 12:49:19 2008 +0100 @@ -0,0 +1,53 @@ +/* + * 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 properties list of properties to set + * @param id The InstanceID of the AllocationCapabilities + * @param inst The list of instance(s) in case of success + * @returns The status of this operation + */ +CMPIStatus enum_alloc_cap_instances(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const char **properties, + const char *id, + struct inst_list *list); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */