summaryrefslogtreecommitdiffstats
path: root/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c')
-rw-r--r--src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c602
1 files changed, 552 insertions, 50 deletions
diff --git a/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c b/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c
index 9332f62..d1681ff 100644
--- a/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c
+++ b/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.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_ResourceForSoftwareIdentity.h"
+#include "sw-utils.h"
static const CMPIBroker* _cb;
-static void LMI_ResourceForSoftwareIdentityInitialize()
+static void LMI_ResourceForSoftwareIdentityInitialize(const CMPIContext *ctx)
{
+ lmi_init(provider_name, _cb, ctx, provider_config_defaults);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityCleanup(
@@ -15,14 +37,187 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityCleanup(
CMReturn(CMPI_RC_OK);
}
+static void k_return_rfsi(const gchar *pkg_id,
+ const LMI_SoftwareIdentityResourceRef *sir, const CMPIResult *cr,
+ const char *ns, const short names)
+{
+ SwPackage sw_pkg;
+ char elem_name[ELEM_NAME_LEN] = "", instance_id[INSTANCE_ID_LEN] = "";
+
+ init_sw_package(&sw_pkg);
+
+ if (create_sw_package_from_pk_pkg_id(pkg_id, &sw_pkg) != 0) {
+ goto done;
+ }
+
+ sw_pkg_get_element_name(&sw_pkg, elem_name, ELEM_NAME_LEN);
+
+ create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id,
+ INSTANCE_ID_LEN);
+
+ LMI_SoftwareIdentityRef si;
+ LMI_SoftwareIdentityRef_Init(&si, _cb, ns);
+ LMI_SoftwareIdentityRef_Set_InstanceID(&si, instance_id);
+
+ LMI_ResourceForSoftwareIdentity rfsi;
+ LMI_ResourceForSoftwareIdentity_Init(&rfsi, _cb, ns);
+ LMI_ResourceForSoftwareIdentity_Set_AvailableSAP(&rfsi, sir);
+ LMI_ResourceForSoftwareIdentity_Set_ManagedElement(&rfsi, &si);
+
+ if (names) {
+ KReturnObjectPath(cr, rfsi);
+ } else {
+ KReturnInstance(cr, rfsi);
+ }
+
+done:
+ free_sw_package(&sw_pkg);
+
+ return;
+}
+
+static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns,
+ const short names, const char *repo_id_p)
+{
+ LMI_SoftwareIdentityResourceRef *sir;
+ PkPackage *pkg = NULL;
+ GPtrArray *pkg_array = NULL, *det_array = NULL, *array = NULL;
+ GHashTable *repo_hash = NULL;
+ GHashTableIter iter;
+ gchar *repo_id = NULL, *pkg_id = NULL, **values = NULL,
+ **pk_det_id_split = NULL;
+ const gchar *pkg_id_c = NULL;
+ unsigned i, j;
+ char error_msg[ERROR_MSG_LEN] = "";
+
+ /* Get all available repos, create LMI_SoftwareIdentityResourceRef for
+ * all of them and store it in hash table. */
+ get_pk_repos(&array, error_msg, ERROR_MSG_LEN);
+ if (!array) {
+ goto done;
+ }
+
+ repo_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
+ for (i = 0; i < array->len; i++) {
+ g_object_get(g_ptr_array_index(array, i), "repo-id", &repo_id, NULL);
+
+ sir = g_new0(LMI_SoftwareIdentityResourceRef, 1);
+ LMI_SoftwareIdentityResourceRef_Init(sir, _cb, ns);
+ LMI_SoftwareIdentityResourceRef_Set_SystemName(sir, get_system_name());
+ LMI_SoftwareIdentityResourceRef_Set_CreationClassName(sir,
+ ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME);
+ LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(sir,
+ get_system_creation_class_name());
+ LMI_SoftwareIdentityResourceRef_Set_Name(sir, repo_id);
+
+ g_hash_table_insert(repo_hash, repo_id, sir);
+ }
+ g_ptr_array_unref(array);
+ array = NULL;
+
+ /* Get all packages and check their repo. If found in hash table, return
+ * the LMI_ResourceForSoftwareIdentity instance. If not, save the package
+ * in array for next processing. */
+ get_pk_packages(0, &pkg_array, error_msg, ERROR_MSG_LEN);
+ if (!pkg_array) {
+ goto done;
+ }
+
+ /* Lets assume that there is about EST_OF_INSTD_PKGS installed packages
+ * (to avoid too many allocations) */
+ array = g_ptr_array_new_full(EST_OF_INSTD_PKGS, g_object_unref);
+
+ for (i = 0; i < pkg_array->len; i++) {
+ pkg = g_ptr_array_index(pkg_array, i);
+
+ sir = (LMI_SoftwareIdentityResourceRef *) g_hash_table_lookup(repo_hash,
+ pk_package_get_data(pkg));
+
+ if (sir) {
+ if (!repo_id_p || strcmp(repo_id_p, pk_package_get_data(pkg)) == 0) {
+ k_return_rfsi(pk_package_get_id(pkg), sir, cr, ns, names);
+ }
+ } else {
+ g_ptr_array_add(array, g_object_ref(pkg));
+ }
+ }
+ g_ptr_array_unref(pkg_array);
+ pkg_array = NULL;
+
+ /* For all saved packages, create package ID with every available repo.
+ * Then, get package details for all those package IDs. Package details
+ * are returned only for valid package IDs... */
+ j = 0;
+ if (!repo_id_p) {
+ values = g_new0(gchar*, array->len * g_hash_table_size(repo_hash) + 1);
+ } else {
+ values = g_new0(gchar*, array->len + 1);
+ }
+ for (i = 0; i < array->len; i++) {
+ pkg = g_ptr_array_index(array, i);
+ if (!repo_id_p) {
+ g_hash_table_iter_init(&iter, repo_hash);
+ while (g_hash_table_iter_next(&iter, (gpointer *) &repo_id, NULL)) {
+ pkg_id = pk_package_id_build(pk_package_get_name(pkg),
+ pk_package_get_version(pkg), pk_package_get_arch(pkg),
+ repo_id);
+ values[j++] = pkg_id;
+ }
+ } else {
+ pkg_id = pk_package_id_build(pk_package_get_name(pkg),
+ pk_package_get_version(pkg), pk_package_get_arch(pkg),
+ repo_id_p);
+ values[j++] = pkg_id;
+ }
+ }
+ g_ptr_array_unref(array);
+ array = NULL;
+
+ get_pk_det_from_array(values, &det_array, NULL);
+ g_strfreev(values);
+ values = NULL;
+
+ if (det_array && det_array->len > 0) {
+ for (i = 0; i < det_array->len; i++) {
+ pkg_id_c = pk_details_get_package_id(g_ptr_array_index(det_array, i));
+ pk_det_id_split = pk_package_id_split(pkg_id_c);
+ if (!pk_det_id_split) {
+ continue;
+ }
+
+ sir = (LMI_SoftwareIdentityResourceRef *) g_hash_table_lookup(
+ repo_hash, pk_det_id_split[PK_PACKAGE_ID_DATA]);
+ g_strfreev(pk_det_id_split);
+ pk_det_id_split = NULL;
+
+ if (sir) {
+ k_return_rfsi(pkg_id_c, sir, cr, ns, names);
+ }
+ }
+ g_ptr_array_unref(det_array);
+ det_array = NULL;
+ }
+
+done:
+ if (repo_hash) {
+ g_hash_table_destroy(repo_hash);
+ }
+
+ if (*error_msg) {
+ KReturn2(_cb, ERR_FAILED, "%s", error_msg);
+ }
+
+ CMReturn(CMPI_RC_OK);
+}
+
static CMPIStatus LMI_ResourceForSoftwareIdentityEnumInstanceNames(
CMPIInstanceMI* mi,
const CMPIContext* cc,
const CMPIResult* cr,
const CMPIObjectPath* cop)
{
- return KDefaultEnumerateInstanceNames(
- _cb, mi, cc, cr, cop);
+ return enum_instances(cr, KNameSpace(cop), 1, NULL);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityEnumInstances(
@@ -32,7 +227,7 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityEnumInstances(
const CMPIObjectPath* cop,
const char** properties)
{
- CMReturn(CMPI_RC_OK);
+ return enum_instances(cr, KNameSpace(cop), 0, NULL);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityGetInstance(
@@ -42,8 +237,86 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityGetInstance(
const CMPIObjectPath* cop,
const char** properties)
{
- return KDefaultGetInstance(
- _cb, mi, cc, cr, cop, properties);
+ const char *repo_id = NULL;
+ gchar *pkg_id = NULL, **values = NULL;
+ GPtrArray *array = NULL;
+ PkRepoDetail *pk_repo = NULL;
+ PkPackage *pk_pkg = NULL;
+ SwPackage sw_pkg;
+ CMPIrc rc_stat = CMPI_RC_ERR_NOT_FOUND;
+ char error_msg[ERROR_MSG_LEN] = "";
+
+ init_sw_package(&sw_pkg);
+
+ LMI_ResourceForSoftwareIdentity w;
+ LMI_ResourceForSoftwareIdentity_InitFromObjectPath(&w, _cb, cop);
+
+ /* Check repo */
+ if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "CreationClassName"),
+ ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME) != 0) {
+ goto done;
+ }
+ if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "SystemCreationClassName"),
+ get_system_creation_class_name()) != 0) {
+ goto done;
+ }
+ if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "SystemName"),
+ get_system_name()) != 0) {
+ goto done;
+ }
+ repo_id = get_str_property_from_op(w.AvailableSAP.value, "Name");
+ get_pk_repo(repo_id, &pk_repo, error_msg, ERROR_MSG_LEN);
+ if (!pk_repo) {
+ goto done;
+ }
+
+ /* Check package */
+ if (get_sw_pkg_from_sw_identity_op(w.ManagedElement.value, &sw_pkg) != 0) {
+ goto done;
+ }
+ get_pk_pkg_from_sw_pkg(&sw_pkg, 0, &pk_pkg);
+ if (!pk_pkg) {
+ goto done;
+ }
+
+ /* Is this package from this repo? */
+ if (strcmp(pk_package_get_data(pk_pkg), repo_id) != 0) {
+ pkg_id = pk_package_id_build(pk_package_get_name(pk_pkg),
+ pk_package_get_version(pk_pkg), pk_package_get_arch(pk_pkg),
+ repo_id);
+ values = g_new0(gchar*, 2);
+ values[0] = pkg_id;
+ get_pk_det_from_array(values, &array, NULL);
+ if (!array || array->len < 1) {
+ goto done;
+ }
+ }
+
+ KReturnInstance(cr, w);
+
+ rc_stat = CMPI_RC_OK;
+
+done:
+ free_sw_package(&sw_pkg);
+
+ if (values) {
+ g_strfreev(values);
+ }
+ if (array) {
+ g_ptr_array_unref(array);
+ }
+ if (pk_repo) {
+ g_object_unref(pk_repo);
+ }
+ if (pk_pkg) {
+ g_object_unref(pk_pkg);
+ }
+
+ if (*error_msg) {
+ KReturn2(_cb, ERR_FAILED, "%s", error_msg);
+ }
+
+ CMReturn(rc_stat);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityCreateInstance(
@@ -95,6 +368,190 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityAssociationCleanup(
CMReturn(CMPI_RC_OK);
}
+static void enum_sw_instance_names_for_repo(const char *repo_id_p,
+ const CMPIResult *cr, const char *ns, char *error_msg,
+ const unsigned error_msg_len)
+{
+ PkPackage *pkg = NULL;
+ GPtrArray *pkg_array = NULL, *det_array = NULL, *repo_array = NULL,
+ *array = NULL;
+ gchar *repo_id = NULL, *pkg_id = NULL, **values = NULL;
+ const gchar *pkg_id_c = NULL;
+ short found;
+ unsigned i, j;
+
+ /* Get all repos and packages. */
+ get_pk_repos(&repo_array, error_msg, error_msg_len);
+ if (!repo_array) {
+ goto done;
+ }
+
+ get_pk_packages(0, &pkg_array, error_msg, error_msg_len);
+ if (!pkg_array) {
+ goto done;
+ }
+
+ /* Lets assume that there is about EST_OF_INSTD_PKGS installed packages
+ * (to avoid too many allocations) */
+ array = g_ptr_array_new_full(EST_OF_INSTD_PKGS, g_object_unref);
+
+ /* For every package, check repo. If found, and it is required repo, return
+ * SwIdentityRef instance. If repo for pkg is not found, save the pkg
+ * for next processing. */
+ for (i = 0; i < pkg_array->len; i++) {
+ pkg = g_ptr_array_index(pkg_array, i);
+ found = 0;
+ for (j = 0; j < repo_array->len; j++) {
+ g_object_get(g_ptr_array_index(repo_array, j), "repo-id", &repo_id,
+ NULL);
+ if (strcmp(repo_id, pk_package_get_data(pkg)) == 0) {
+ found = 1;
+ if (strcmp(repo_id, repo_id_p) == 0) {
+ k_return_sw_identity_op_from_pkg_id(pk_package_get_id(pkg),
+ _cb, ns, cr);
+ }
+ break;
+ }
+ }
+ if (!found) {
+ g_ptr_array_add(array, g_object_ref(pkg));
+ }
+ }
+ g_ptr_array_unref(pkg_array);
+ pkg_array = NULL;
+ g_ptr_array_unref(repo_array);
+ repo_array = NULL;
+
+ /* For all saved packages, create package ID with required repo.
+ * Then, get package details for all those package IDs. Package details
+ * are returned only for valid package IDs... */
+ j = 0;
+ values = g_new0(gchar*, array->len + 1);
+ for (i = 0; i < array->len; i++) {
+ pkg = g_ptr_array_index(array, i);
+ pkg_id = pk_package_id_build(pk_package_get_name(pkg),
+ pk_package_get_version(pkg), pk_package_get_arch(pkg),
+ repo_id_p);
+ values[j++] = pkg_id;
+ }
+ g_ptr_array_unref(array);
+ array = NULL;
+
+ get_pk_det_from_array(values, &det_array, NULL);
+ g_strfreev(values);
+ values = NULL;
+
+ if (det_array && det_array->len > 0) {
+ for (i = 0; i < det_array->len; i++) {
+ pkg_id_c = pk_details_get_package_id(g_ptr_array_index(det_array, i));
+ k_return_sw_identity_op_from_pkg_id(pkg_id_c, _cb, ns, cr);
+ }
+ g_ptr_array_unref(det_array);
+ det_array = NULL;
+ }
+
+done:
+ return;
+}
+
+static CMPIStatus associators(
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole,
+ const char** properties,
+ const short names)
+{
+ CMPIStatus st;
+ char error_msg[ERROR_MSG_LEN] = "";
+
+ if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass,
+ ORGID "_" RESOURCE_FOR_SW_IDENTITY_CLASS_NAME)) {
+ goto done;
+ }
+
+ if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME, &st)) {
+ /* got SoftwareIdentityResource - AvailableSAP;
+ * where listing only associators names is supported */
+ if (!names) {
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+ }
+
+ if (cm_class_is_a(_cb, KNameSpace(cop), resultClass,
+ ORGID "_" SW_IDENTITY_CLASS_NAME) != 0) {
+ goto done;
+ }
+ if (role && strcmp(role, AVAIL_SAP_ATTR) != 0) {
+ goto done;
+ }
+ if (resultRole && strcmp(resultRole, MNGD_ELEM_ATTR) != 0) {
+ goto done;
+ }
+
+ enum_sw_instance_names_for_repo(get_str_property_from_op(cop, "Name"),
+ cr, KNameSpace(cop), error_msg, ERROR_MSG_LEN);
+ } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) {
+ /* got SoftwareIdentity - ManagedElement */
+ SwPackage sw_pkg;
+ gchar *repo_id = NULL;
+
+ if (cm_class_is_a(_cb, KNameSpace(cop), resultClass,
+ ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME) != 0) {
+ goto done;
+ }
+ if (role && strcmp(role, MNGD_ELEM_ATTR) != 0) {
+ goto done;
+ }
+ if (resultRole && strcmp(resultRole, AVAIL_SAP_ATTR) != 0) {
+ goto done;
+ }
+
+ init_sw_package(&sw_pkg);
+ get_sw_pkg_from_sw_identity_op(cop, &sw_pkg);
+ get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, ERROR_MSG_LEN);
+ free_sw_package(&sw_pkg);
+
+ if (*error_msg) {
+ goto done;
+ }
+ if (!repo_id) {
+ /* We don't know the repository - package can be installed from
+ * local source, etc.. I don't think this is an error. */
+ goto done;
+ }
+
+ LMI_SoftwareIdentityResourceRef sir;
+ LMI_SoftwareIdentityResourceRef_Init(&sir, _cb, KNameSpace(cop));
+ LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, get_system_name());
+ LMI_SoftwareIdentityResourceRef_Set_CreationClassName(&sir,
+ ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME);
+ LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(&sir,
+ get_system_creation_class_name());
+ LMI_SoftwareIdentityResourceRef_Set_Name(&sir, repo_id);
+
+ g_free(repo_id);
+ repo_id = NULL;
+
+ if (names) {
+ KReturnObjectPath(cr, sir);
+ } else {
+ CMPIObjectPath *o = LMI_SoftwareIdentityResourceRef_ToObjectPath(&sir, &st);
+ CMPIInstance *ci = _cb->bft->getInstance(_cb, cc, o, properties, &st);
+ CMReturnInstance(cr, ci);
+ }
+ }
+
+done:
+ if (*error_msg) {
+ KReturn2(_cb, ERR_FAILED, "%s", error_msg);
+ }
+
+ CMReturn(CMPI_RC_OK);
+}
+
static CMPIStatus LMI_ResourceForSoftwareIdentityAssociators(
CMPIAssociationMI* mi,
const CMPIContext* cc,
@@ -106,18 +563,8 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityAssociators(
const char* resultRole,
const char** properties)
{
- return KDefaultAssociators(
- _cb,
- mi,
- cc,
- cr,
- cop,
- LMI_ResourceForSoftwareIdentity_ClassName,
- assocClass,
- resultClass,
- role,
- resultRole,
- properties);
+ return associators(cc, cr, cop, assocClass, resultClass, role,
+ resultRole, properties, 0);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityAssociatorNames(
@@ -130,17 +577,89 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityAssociatorNames(
const char* role,
const char* resultRole)
{
- return KDefaultAssociatorNames(
- _cb,
- mi,
- cc,
- cr,
- cop,
- LMI_ResourceForSoftwareIdentity_ClassName,
- assocClass,
- resultClass,
- role,
- resultRole);
+ return associators(cc, cr, cop, assocClass, resultClass, role,
+ resultRole, NULL, 1);
+}
+
+static CMPIStatus references(
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const short names)
+{
+ CMPIStatus st;
+ char error_msg[ERROR_MSG_LEN] = "";
+
+ if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass,
+ ORGID "_" RESOURCE_FOR_SW_IDENTITY_CLASS_NAME)) {
+ goto done;
+ }
+
+ if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME, &st)) {
+ /* got SoftwareIdentityResource - AvailableSAP */
+ if (role && strcmp(role, AVAIL_SAP_ATTR) != 0) {
+ goto done;
+ }
+
+ return enum_instances(cr, KNameSpace(cop), names,
+ get_str_property_from_op(cop, "Name"));
+ } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) {
+ /* got SoftwareIdentity - ManagedElement */
+ SwPackage sw_pkg;
+ gchar *repo_id = NULL;
+
+ if (role && strcmp(role, MNGD_ELEM_ATTR) != 0) {
+ goto done;
+ }
+
+ init_sw_package(&sw_pkg);
+ get_sw_pkg_from_sw_identity_op(cop, &sw_pkg);
+ get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, ERROR_MSG_LEN);
+ free_sw_package(&sw_pkg);
+
+ if (*error_msg) {
+ goto done;
+ }
+ if (!repo_id) {
+ /* We don't know the repository - package can be installed from
+ * local source, etc.. I don't think this is an error. */
+ goto done;
+ }
+
+ LMI_SoftwareIdentityResourceRef sir;
+ LMI_SoftwareIdentityResourceRef_Init(&sir, _cb, KNameSpace(cop));
+ LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, get_system_name());
+ LMI_SoftwareIdentityResourceRef_Set_CreationClassName(&sir,
+ ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME);
+ LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(&sir,
+ get_system_creation_class_name());
+ LMI_SoftwareIdentityResourceRef_Set_Name(&sir, repo_id);
+
+ g_free(repo_id);
+ repo_id = NULL;
+
+ LMI_SoftwareIdentityRef si;
+ LMI_SoftwareIdentityRef_InitFromObjectPath(&si, _cb, cop);
+
+ LMI_ResourceForSoftwareIdentity rfsi;
+ LMI_ResourceForSoftwareIdentity_Init(&rfsi, _cb, KNameSpace(cop));
+ LMI_ResourceForSoftwareIdentity_Set_AvailableSAP(&rfsi, &sir);
+ LMI_ResourceForSoftwareIdentity_Set_ManagedElement(&rfsi, &si);
+
+ if (names) {
+ KReturnObjectPath(cr, rfsi);
+ } else {
+ KReturnInstance(cr, rfsi);
+ }
+ }
+
+done:
+ if (*error_msg) {
+ KReturn2(_cb, ERR_FAILED, "%s", error_msg);
+ }
+
+ CMReturn(CMPI_RC_OK);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityReferences(
@@ -152,16 +671,7 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityReferences(
const char* role,
const char** properties)
{
- return KDefaultReferences(
- _cb,
- mi,
- cc,
- cr,
- cop,
- LMI_ResourceForSoftwareIdentity_ClassName,
- assocClass,
- role,
- properties);
+ return references(cr, cop, assocClass, role, 0);
}
static CMPIStatus LMI_ResourceForSoftwareIdentityReferenceNames(
@@ -172,28 +682,20 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityReferenceNames(
const char* assocClass,
const char* role)
{
- return KDefaultReferenceNames(
- _cb,
- mi,
- cc,
- cr,
- cop,
- LMI_ResourceForSoftwareIdentity_ClassName,
- assocClass,
- role);
+ return references(cr, cop, assocClass, role, 1);
}
CMInstanceMIStub(
LMI_ResourceForSoftwareIdentity,
LMI_ResourceForSoftwareIdentity,
_cb,
- LMI_ResourceForSoftwareIdentityInitialize())
+ LMI_ResourceForSoftwareIdentityInitialize(ctx))
CMAssociationMIStub(
LMI_ResourceForSoftwareIdentity,
LMI_ResourceForSoftwareIdentity,
_cb,
- LMI_ResourceForSoftwareIdentityInitialize())
+ LMI_ResourceForSoftwareIdentityInitialize(ctx))
KONKRET_REGISTRATION(
"root/cimv2",