summaryrefslogtreecommitdiffstats
path: root/src/logicalfile/LMI_FileIdentityProvider.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2013-02-08 13:16:31 +0100
committerJan Synacek <jsynacek@redhat.com>2013-02-11 13:10:40 +0100
commit7f40ebbf575d93a9d0bc540c484969ec614f308b (patch)
tree3a698f3560c626c5e9ca6aa060dc1c4b3e836b0a /src/logicalfile/LMI_FileIdentityProvider.c
parent80a4e2961a65f9922e000d27ce642a4789588648 (diff)
downloadopenlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.tar.gz
openlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.tar.xz
openlmi-providers-7f40ebbf575d93a9d0bc540c484969ec614f308b.zip
New provider: LogicalFile
Diffstat (limited to 'src/logicalfile/LMI_FileIdentityProvider.c')
-rw-r--r--src/logicalfile/LMI_FileIdentityProvider.c302
1 files changed, 302 insertions, 0 deletions
diff --git a/src/logicalfile/LMI_FileIdentityProvider.c b/src/logicalfile/LMI_FileIdentityProvider.c
new file mode 100644
index 0000000..453764e
--- /dev/null
+++ b/src/logicalfile/LMI_FileIdentityProvider.c
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2012 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: Jan Synacek <jsynacek@redhat.com>
+ */
+#include <konkret/konkret.h>
+#include "CIM_LogicalFile.h"
+#include "CIM_UnixFile.h"
+#include "LMI_FileIdentity.h"
+#include "LMI_UnixFile.h"
+#include "LMI_DataFile.h"
+#include "file.h"
+
+static const CMPIBroker* _cb;
+
+static CMPIStatus associators(
+ 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,
+ int names)
+{
+ CMPIStatus st, res;
+ CMPIInstance *ci;
+
+ /* TODO filtering */
+ if (names) {
+ res = CMReturnObjectPath(cr, cop);
+ } else {
+ ci = _cb->bft->getInstance(_cb, cc, cop, properties, &st);
+ res = CMReturnInstance(cr, ci);
+ }
+
+ return res;
+}
+
+static CMPIStatus references(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const char** properties,
+ int names)
+{
+ LMI_FileIdentity lmi_fi;
+ /* SameElement */
+ LMI_UnixFile lmi_uf;
+ /* SystemElement */
+ CIM_LogicalFileRef lmi_lfr;
+ CMPIStatus st;
+ CMPIData pathd;
+ CMPIData cnd;
+ const char *ns = KNameSpace(cop);
+ CMPIInstance *ci;
+
+ LMI_FileIdentity_Init(&lmi_fi, _cb, ns);
+
+ if (CMClassPathIsA(_cb, cop, LMI_UnixFile_ClassName, &st)) {
+ /* got SameElement - UnixFile */
+ LMI_FileIdentity_SetObjectPath_SameElement(&lmi_fi, cop);
+
+ st = lmi_check_required(_cb, cop, UNIXFILE);
+ if (st.rc != CMPI_RC_OK) {
+ return st;
+ }
+
+ pathd = CMGetKey(cop, "LFName", &st);
+ cnd = CMGetKey(cop, "LFCreationClassName", &st);
+ const char *path = KChars(pathd.value.string);
+ const char *ccname = KChars(cnd.value.string);
+
+ /* SystemElement */
+ CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns);
+ fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, ccname);
+ CMPIObjectPath *o = CIM_LogicalFileRef_ToObjectPath(&lmi_lfr, &st);
+ CMSetClassName(o, ccname);
+
+ if (names) {
+ LMI_FileIdentity_SetObjectPath_SystemElement(&lmi_fi, o);
+ } else {
+ ci = _cb->bft->getInstance(_cb, cc, o, properties, &st);
+ CMReturnInstance(cr, ci);
+ }
+ } else {
+ /* got SystemElement - LogicalFile */
+ LMI_FileIdentity_SetObjectPath_SystemElement(&lmi_fi, cop);
+
+ st = lmi_check_required(_cb, cop, LOGICALFILE);
+ if (st.rc != CMPI_RC_OK) {
+ return st;
+ }
+
+ pathd = CMGetKey(cop, "Name", &st);
+ cnd = CMGetKey(cop, "CreationClassName", &st);
+ const char *path = KChars(pathd.value.string);
+ const char *ccname = KChars(cnd.value.string);
+
+ /* SameElement */
+ LMI_UnixFile_Init(&lmi_uf, _cb, ns);
+ LMI_UnixFile_Set_LFName(&lmi_uf, path);
+ LMI_UnixFile_Set_CSCreationClassName(&lmi_uf, get_system_creation_class_name());
+ LMI_UnixFile_Set_CSName(&lmi_uf, get_system_name());
+ LMI_UnixFile_Set_FSCreationClassName(&lmi_uf, FSCREATIONCLASSNAME);
+ LMI_UnixFile_Set_FSName(&lmi_uf, FSNAME);
+ LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, ccname);
+ CMPIObjectPath *o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st);
+ if (names) {
+ LMI_FileIdentity_SetObjectPath_SameElement(&lmi_fi, o);
+ } else {
+ ci = _cb->bft->getInstance(_cb, cc, o, properties, &st);
+ CMReturnInstance(cr, ci);
+ }
+ }
+
+ if (names) {
+ return CMReturnObjectPath(cr, LMI_FileIdentity_ToObjectPath(&lmi_fi, &st));
+ }
+ CMReturn(CMPI_RC_OK);
+}
+
+static void LMI_FileIdentityInitialize()
+{
+}
+
+static CMPIStatus LMI_FileIdentityCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_FileIdentityEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_FileIdentityEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_FileIdentityGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ /* TODO TBI */
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_FileIdentityCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_FileIdentityModifyInstance(
+ 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_FileIdentityDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_FileIdentityExecQuery(
+ 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_FileIdentityAssociationCleanup(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_FileIdentityAssociators(
+ 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 associators(mi, cc, cr, cop, assocClass, resultClass,
+ role, resultRole, properties, 0);
+}
+
+static CMPIStatus LMI_FileIdentityAssociatorNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole)
+{
+ return associators(mi, cc, cr, cop, assocClass, resultClass,
+ role, resultRole, NULL, 1);
+}
+
+static CMPIStatus LMI_FileIdentityReferences(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const char** properties)
+{
+ return references(mi, cc, cr, cop, assocClass, role, properties, 0);
+}
+
+static CMPIStatus LMI_FileIdentityReferenceNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role)
+{
+ return references(mi, cc, cr, cop, assocClass, role, NULL, 1);
+}
+
+CMInstanceMIStub(
+ LMI_FileIdentity,
+ LMI_FileIdentity,
+ _cb,
+ LMI_FileIdentityInitialize())
+
+CMAssociationMIStub(
+ LMI_FileIdentity,
+ LMI_FileIdentity,
+ _cb,
+ LMI_FileIdentityInitialize())
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "LMI_FileIdentity",
+ "LMI_FileIdentity",
+ "instance association")
+/* vi: set et: */