summaryrefslogtreecommitdiffstats
path: root/src/hardware/LMI_PhysicalMemoryRealizesProvider.c
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-04-23 15:43:40 +0200
committerPeter Schiffer <pschiffe@redhat.com>2013-04-23 15:43:40 +0200
commit1e4187b50657065445a33148bfb2224005fb0dff (patch)
treebe2a363d74215eab1c98be2776b408dfc98cff23 /src/hardware/LMI_PhysicalMemoryRealizesProvider.c
parente229f6f4752c30c4fb48c429174f81bbda02242d (diff)
downloadopenlmi-providers-1e4187b50657065445a33148bfb2224005fb0dff.tar.gz
openlmi-providers-1e4187b50657065445a33148bfb2224005fb0dff.tar.xz
openlmi-providers-1e4187b50657065445a33148bfb2224005fb0dff.zip
Hardware: Added Physical Memory Provider
New Providers: * LMI_PhysicalMemoryProvider * LMI_PhysicalMemoryRealizesProvider Other Changes: * Fixed InstanceID in hardware to match the rest of the providers * Removed some unused variables
Diffstat (limited to 'src/hardware/LMI_PhysicalMemoryRealizesProvider.c')
-rw-r--r--src/hardware/LMI_PhysicalMemoryRealizesProvider.c263
1 files changed, 263 insertions, 0 deletions
diff --git a/src/hardware/LMI_PhysicalMemoryRealizesProvider.c b/src/hardware/LMI_PhysicalMemoryRealizesProvider.c
new file mode 100644
index 0000000..0da8d33
--- /dev/null
+++ b/src/hardware/LMI_PhysicalMemoryRealizesProvider.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#include <konkret/konkret.h>
+#include "LMI_PhysicalMemoryRealizes.h"
+#include "LMI_Hardware.h"
+#include "globals.h"
+#include "dmidecode.h"
+
+static const CMPIBroker* _cb;
+
+static void LMI_PhysicalMemoryRealizesInitialize()
+{
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ LMI_PhysicalMemoryRealizes lmi_phys_mem_realizes;
+ LMI_PhysicalMemoryRef lmi_phys_mem;
+ LMI_MemoryRef lmi_mem;
+ const char *ns = KNameSpace(cop);
+ unsigned i;
+ DmiMemory dmi_memory;
+
+ if (dmi_get_memory(&dmi_memory) != 0 || dmi_memory.modules_nb < 1) {
+ goto done;
+ }
+
+ LMI_MemoryRef_Init(&lmi_mem, _cb, ns);
+ LMI_MemoryRef_Set_SystemCreationClassName(&lmi_mem,
+ get_system_creation_class_name());
+ LMI_MemoryRef_Set_SystemName(&lmi_mem, get_system_name());
+ LMI_MemoryRef_Set_CreationClassName(&lmi_mem, ORGID "_" MEM_CLASS_NAME);
+ LMI_MemoryRef_Set_DeviceID(&lmi_mem, "0");
+
+ for (i = 0; i < dmi_memory.modules_nb; i++) {
+ LMI_PhysicalMemoryRealizes_Init(&lmi_phys_mem_realizes, _cb, ns);
+
+ LMI_PhysicalMemoryRef_Init(&lmi_phys_mem, _cb, ns);
+ LMI_PhysicalMemoryRef_Set_CreationClassName(&lmi_phys_mem,
+ ORGID "_" PHYS_MEM_CLASS_NAME);
+ LMI_PhysicalMemoryRef_Set_Tag(&lmi_phys_mem,
+ dmi_memory.modules[i].serial_number);
+
+ LMI_PhysicalMemoryRealizes_Set_Antecedent(&lmi_phys_mem_realizes,
+ &lmi_phys_mem);
+ LMI_PhysicalMemoryRealizes_Set_Dependent(&lmi_phys_mem_realizes,
+ &lmi_mem);
+
+ KReturnInstance(cr, lmi_phys_mem_realizes);
+ }
+
+done:
+ dmi_free_memory(&dmi_memory);
+
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesModifyInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci,
+ const char**properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesAssociationCleanup(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesAssociators(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole,
+ const char** properties)
+{
+ return KDefaultAssociators(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PhysicalMemoryRealizes_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole,
+ properties);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesAssociatorNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole)
+{
+ return KDefaultAssociatorNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PhysicalMemoryRealizes_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesReferences(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const char** properties)
+{
+ return KDefaultReferences(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PhysicalMemoryRealizes_ClassName,
+ assocClass,
+ role,
+ properties);
+}
+
+static CMPIStatus LMI_PhysicalMemoryRealizesReferenceNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role)
+{
+ return KDefaultReferenceNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PhysicalMemoryRealizes_ClassName,
+ assocClass,
+ role);
+}
+
+CMInstanceMIStub(
+ LMI_PhysicalMemoryRealizes,
+ LMI_PhysicalMemoryRealizes,
+ _cb,
+ LMI_PhysicalMemoryRealizesInitialize())
+
+CMAssociationMIStub(
+ LMI_PhysicalMemoryRealizes,
+ LMI_PhysicalMemoryRealizes,
+ _cb,
+ LMI_PhysicalMemoryRealizesInitialize())
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "LMI_PhysicalMemoryRealizes",
+ "LMI_PhysicalMemoryRealizes",
+ "instance association")