summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2014-05-09 13:47:06 +0200
committerPeter Schiffer <pschiffe@redhat.com>2014-05-09 13:47:46 +0200
commitfcf9a1cb25a736fe306699ec47176fe86bc70a2f (patch)
tree873ce8ec58719ba4572404fce3bb7a875bd4b28c
parentaad2899e36739be1146e07cf634730837bd79bdb (diff)
downloadopenlmi-providers-fcf9a1cb25a736fe306699ec47176fe86bc70a2f.tar.gz
openlmi-providers-fcf9a1cb25a736fe306699ec47176fe86bc70a2f.tar.xz
openlmi-providers-fcf9a1cb25a736fe306699ec47176fe86bc70a2f.zip
Software-dbus: implemented LMI_HostedSoftwareIdentityResourceProvider
-rw-r--r--src/software-dbus/LMI_HostedSoftwareIdentityResourceProvider.c71
1 files changed, 68 insertions, 3 deletions
diff --git a/src/software-dbus/LMI_HostedSoftwareIdentityResourceProvider.c b/src/software-dbus/LMI_HostedSoftwareIdentityResourceProvider.c
index 2def768..d6f9bb6 100644
--- a/src/software-dbus/LMI_HostedSoftwareIdentityResourceProvider.c
+++ b/src/software-dbus/LMI_HostedSoftwareIdentityResourceProvider.c
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2013-2014 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_HostedSoftwareIdentityResource.h"
+#include "sw-utils.h"
static const CMPIBroker* _cb;
-static void LMI_HostedSoftwareIdentityResourceInitialize()
+static void LMI_HostedSoftwareIdentityResourceInitialize(const CMPIContext *ctx)
{
+ lmi_init(provider_name, _cb, ctx, provider_config_defaults);
}
static CMPIStatus LMI_HostedSoftwareIdentityResourceCleanup(
@@ -32,6 +54,49 @@ static CMPIStatus LMI_HostedSoftwareIdentityResourceEnumInstances(
const CMPIObjectPath* cop,
const char** properties)
{
+ GPtrArray *array = NULL;
+ gchar *repo_id = NULL;
+ unsigned i;
+ char error_msg[BUFLEN] = "";
+
+ get_pk_repos(&array, error_msg, BUFLEN);
+ if (!array) {
+ goto done;
+ }
+
+ for (i = 0; i < array->len; i++) {
+ g_object_get(g_ptr_array_index(array, i), "repo-id", &repo_id, NULL);
+
+ LMI_SoftwareIdentityResourceRef sir;
+ LMI_SoftwareIdentityResourceRef_Init(&sir, _cb, KNameSpace(cop));
+ LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, lmi_get_system_name());
+ LMI_SoftwareIdentityResourceRef_Set_CreationClassName(&sir,
+ LMI_SoftwareIdentityResource_ClassName);
+ LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(&sir,
+ lmi_get_system_creation_class_name());
+ LMI_SoftwareIdentityResourceRef_Set_Name(&sir, repo_id);
+
+ g_free(repo_id);
+ repo_id = NULL;
+
+ LMI_HostedSoftwareIdentityResource w;
+ LMI_HostedSoftwareIdentityResource_Init(&w, _cb, KNameSpace(cop));
+ LMI_HostedSoftwareIdentityResource_SetObjectPath_Antecedent(&w,
+ lmi_get_computer_system());
+ LMI_HostedSoftwareIdentityResource_Set_Dependent(&w, &sir);
+
+ KReturnInstance(cr, w);
+ }
+
+done:
+ if (array) {
+ g_ptr_array_unref(array);
+ }
+
+ if (*error_msg) {
+ KReturn2(_cb, ERR_FAILED, "%s", error_msg);
+ }
+
CMReturn(CMPI_RC_OK);
}
@@ -187,13 +252,13 @@ CMInstanceMIStub(
LMI_HostedSoftwareIdentityResource,
LMI_HostedSoftwareIdentityResource,
_cb,
- LMI_HostedSoftwareIdentityResourceInitialize())
+ LMI_HostedSoftwareIdentityResourceInitialize(ctx))
CMAssociationMIStub(
LMI_HostedSoftwareIdentityResource,
LMI_HostedSoftwareIdentityResource,
_cb,
- LMI_HostedSoftwareIdentityResourceInitialize())
+ LMI_HostedSoftwareIdentityResourceInitialize(ctx))
KONKRET_REGISTRATION(
"root/cimv2",