# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1200405813 -3600
# Node ID e4d0cd30d6852f0e45d689086dccbe481c3c9fe9
# Parent a68e6445a09548ace93e2a191fead647e378d86c
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(a)linux.vnet.ibm.com>
diff -r a68e6445a095 -r e4d0cd30d685 src/Virt_AllocationCapabilities.c
--- a/src/Virt_AllocationCapabilities.c Tue Jan 15 15:03:32 2008 +0100
+++ b/src/Virt_AllocationCapabilities.c Tue Jan 15 15:03:33 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,25 @@ 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)
-{
- int i;
+CMPIStatus enum_alloc_cap_instances(const CMPIBroker *broker,
+ const CMPIObjectPath *ref,
+ const char **properties,
+ const char *id,
+ struct inst_list *list)
+{
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()");
+ int i;
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 +125,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 +137,42 @@ 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;
+
+ inst_list_init(&list);
+
+ 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 +192,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 +205,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 +219,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 a68e6445a095 -r e4d0cd30d685 src/Virt_AllocationCapabilities.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_AllocationCapabilities.h Tue Jan 15 15:03:33 2008 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright IBM Corp. 2008
+ *
+ * Authors:
+ * Heidi Eckhart <heidieck(a)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:
+ */