# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1203439144 28800
# Node ID 95c56a7a865df18bbdf1066d8b04d5d4b75e7d44
# Parent 030c012f1698cbccc0cdd0b34f51e377ced6eb16
(#3) Add Enumeration support to RASD
Supports enumerating a specific RASD type, as well as the parent classes
KVM_RASD, Xen_RASD, as well as CIM_RASD.
Changes:
- Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to
complain, I'll have you know)
- Fix silly compile error
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 030c012f1698 -r 95c56a7a865d src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Feb 19 17:04:52 2008 +0800
+++ b/src/Virt_RASD.c Tue Feb 19 08:39:04 2008 -0800
@@ -34,6 +34,7 @@
#include "device_parsing.h"
#include "misc_util.h"
+#include "cs_util.h"
#include "Virt_RASD.h"
#include "svpc_types.h"
@@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t
return rc;
}
+static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+ struct inst_list *list)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr *domains = NULL;
+ int count;
+ int i, j;
+ uint16_t type;
+ CMPIStatus s;
+ uint16_t types[] = {CIM_RASD_TYPE_PROC,
+ CIM_RASD_TYPE_DISK,
+ CIM_RASD_TYPE_NET,
+ CIM_RASD_TYPE_MEM,
+ 0};
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+ if (conn == NULL)
+ return s;
+
+ count = get_domain_list(conn, &domains);
+ if (count <= 0) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get domain list");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) {
+ types[0] = type;
+ types[1] = 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ for (j = 0; types[j] != 0; j++) {
+ CU_DEBUG("Doing RASD type %i for %s",
+ type, virDomainGetName(domains[i]));
+ rasds_for_domain(_BROKER,
+ virDomainGetName(domains[i]),
+ types[j],
+ ref,
+ list);
+ }
+ virDomainFree(domains[i]);
+ }
+
+ s = (CMPIStatus){CMPI_RC_OK, NULL};
+
+ out:
+ virConnectClose(conn);
+ free(domains);
+
+ return s;
+}
+
+static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ const bool names_only)
+{
+ struct inst_list list;
+ CMPIStatus s;
+
+ inst_list_init(&list);
+
+ s = _enum_rasds(ref, &list);
+ if (s.rc == CMPI_RC_OK) {
+ if (names_only)
+ cu_return_instance_names(results, &list);
+ else
+ cu_return_instances(results, &list);
+ }
+
+ inst_list_free(&list);
+
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_enum_rasds(reference, results, true);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+
+ return return_enum_rasds(reference, results, false);
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -516,8 +611,6 @@ DEFAULT_CI();
DEFAULT_CI();
DEFAULT_MI();
DEFAULT_DI();
-DEFAULT_EI();
-DEFAULT_EIN();
DEFAULT_INST_CLEANUP();
DEFAULT_EQ();