summaryrefslogtreecommitdiffstats
path: root/src/power
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-10-30 15:51:12 +0100
committerRadek Novacek <rnovacek@redhat.com>2013-10-31 08:53:46 +0100
commit49394a84fe1235b692fc32d903bf3486e41f76b4 (patch)
treee702181ad69ea995e48ce103f1f3e2b90fa97597 /src/power
parent793843369a4445f8602ef176b41c828730cb4404 (diff)
downloadopenlmi-providers-49394a84fe1235b692fc32d903bf3486e41f76b4.tar.gz
openlmi-providers-49394a84fe1235b692fc32d903bf3486e41f76b4.tar.xz
openlmi-providers-49394a84fe1235b692fc32d903bf3486e41f76b4.zip
Add lmi_get_computer_system function and fix lmi_get_system_name
PG_ComputerSystem has different method how to get hostname than our providers. In order to create the associations to this class we need to enumerate it. The downside is that all providers must supply CMPIContext to the lmi_init function. New function lmi_get_computer_system returns CMPIObjectPath to the configured CIM_ComputerSystem subclass instance. This object should be used in all references with ComputerSystem. Function lmi_get_system_name has been altered to return same value as ComputerSystem "Name" property.
Diffstat (limited to 'src/power')
-rw-r--r--src/power/LMI_AssociatedPowerManagementServiceProvider.c23
-rw-r--r--src/power/LMI_ElementCapabilitiesProvider.c6
-rw-r--r--src/power/LMI_HostedPowerManagementServiceProvider.c15
-rw-r--r--src/power/LMI_PowerConcreteJobProvider.c14
-rw-r--r--src/power/LMI_PowerManagementCapabilitiesProvider.c14
-rw-r--r--src/power/LMI_PowerManagementServiceProvider.c14
-rw-r--r--src/power/power.c8
-rw-r--r--src/power/power.h2
8 files changed, 45 insertions, 51 deletions
diff --git a/src/power/LMI_AssociatedPowerManagementServiceProvider.c b/src/power/LMI_AssociatedPowerManagementServiceProvider.c
index 621fb99..a7748cb 100644
--- a/src/power/LMI_AssociatedPowerManagementServiceProvider.c
+++ b/src/power/LMI_AssociatedPowerManagementServiceProvider.c
@@ -28,14 +28,16 @@
static const CMPIBroker* _cb;
-static void LMI_AssociatedPowerManagementServiceInitialize(CMPIInstanceMI *mi)
+static void LMI_AssociatedPowerManagementServiceInitialize(CMPIInstanceMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
-static void LMI_AssociatedPowerManagementServiceAssociationInitialize(CMPIAssociationMI *mi)
+static void LMI_AssociatedPowerManagementServiceAssociationInitialize(
+ CMPIAssociationMI *mi, const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
static CMPIStatus LMI_AssociatedPowerManagementServiceCleanup(
@@ -65,19 +67,12 @@ static CMPIStatus LMI_AssociatedPowerManagementServiceEnumInstances(
const CMPIObjectPath* cop,
const char** properties)
{
- CMPIStatus rc;
const char *ns = KNameSpace(cop);
LMI_AssociatedPowerManagementService w;
LMI_AssociatedPowerManagementService_Init(&w, _cb, ns);
- CIM_ComputerSystemRef computerSystemRef;
- CIM_ComputerSystemRef_Init(&computerSystemRef, _cb, ns);
- CIM_ComputerSystemRef_Set_Name(&computerSystemRef, get_system_name());
- CIM_ComputerSystemRef_Set_CreationClassName(&computerSystemRef, get_system_creation_class_name());
- CMPIObjectPath *computerSystemOP = CIM_ComputerSystemRef_ToObjectPath(&computerSystemRef, &rc);
- computerSystemOP->ft->setClassName(computerSystemOP, get_system_creation_class_name());
- LMI_AssociatedPowerManagementService_SetObjectPath_UserOfService(&w, computerSystemOP);
+ LMI_AssociatedPowerManagementService_SetObjectPath_UserOfService(&w, lmi_get_computer_system());
LMI_PowerManagementServiceRef powerManagementServiceRef;
LMI_PowerManagementServiceRef_Init(&powerManagementServiceRef, _cb, ns);
@@ -274,13 +269,13 @@ CMInstanceMIStub(
LMI_AssociatedPowerManagementService,
LMI_AssociatedPowerManagementService,
_cb,
- LMI_AssociatedPowerManagementServiceInitialize(&mi))
+ LMI_AssociatedPowerManagementServiceInitialize(&mi, ctx))
CMAssociationMIStub(
LMI_AssociatedPowerManagementService,
LMI_AssociatedPowerManagementService,
_cb,
- LMI_AssociatedPowerManagementServiceAssociationInitialize(&mi))
+ LMI_AssociatedPowerManagementServiceAssociationInitialize(&mi, ctx))
KONKRET_REGISTRATION(
"root/cimv2",
diff --git a/src/power/LMI_ElementCapabilitiesProvider.c b/src/power/LMI_ElementCapabilitiesProvider.c
index d160bfa..9369511 100644
--- a/src/power/LMI_ElementCapabilitiesProvider.c
+++ b/src/power/LMI_ElementCapabilitiesProvider.c
@@ -24,7 +24,7 @@
static const CMPIBroker* _cb;
-static void LMI_ElementCapabilitiesInitialize()
+static void LMI_ElementCapabilitiesInitialize(const CMPIContext *ctx)
{
}
@@ -229,13 +229,13 @@ CMInstanceMIStub(
LMI_ElementCapabilities,
LMI_ElementCapabilities,
_cb,
- LMI_ElementCapabilitiesInitialize())
+ LMI_ElementCapabilitiesInitialize(ctx))
CMAssociationMIStub(
LMI_ElementCapabilities,
LMI_ElementCapabilities,
_cb,
- LMI_ElementCapabilitiesInitialize())
+ LMI_ElementCapabilitiesInitialize(ctx))
KONKRET_REGISTRATION(
"root/cimv2",
diff --git a/src/power/LMI_HostedPowerManagementServiceProvider.c b/src/power/LMI_HostedPowerManagementServiceProvider.c
index 889dd2c..b41021b 100644
--- a/src/power/LMI_HostedPowerManagementServiceProvider.c
+++ b/src/power/LMI_HostedPowerManagementServiceProvider.c
@@ -26,7 +26,7 @@
static const CMPIBroker* _cb;
-static void LMI_HostedPowerManagementServiceInitialize()
+static void LMI_HostedPowerManagementServiceInitialize(const CMPIContext *ctx)
{
}
@@ -55,19 +55,12 @@ static CMPIStatus LMI_HostedPowerManagementServiceEnumInstances(
const CMPIObjectPath* cop,
const char** properties)
{
- CMPIStatus rc;
const char *ns = KNameSpace(cop);
LMI_HostedPowerManagementService w;
LMI_HostedPowerManagementService_Init(&w, _cb, ns);
- CIM_ComputerSystemRef computerSystemRef;
- CIM_ComputerSystemRef_Init(&computerSystemRef, _cb, ns);
- CIM_ComputerSystemRef_Set_Name(&computerSystemRef, get_system_name());
- CIM_ComputerSystemRef_Set_CreationClassName(&computerSystemRef, get_system_creation_class_name());
- CMPIObjectPath *computerSystemOP = CIM_ComputerSystemRef_ToObjectPath(&computerSystemRef, &rc);
- computerSystemOP->ft->setClassName(computerSystemOP, get_system_creation_class_name());
- LMI_HostedPowerManagementService_SetObjectPath_Antecedent(&w, computerSystemOP);
+ LMI_HostedPowerManagementService_SetObjectPath_Antecedent(&w, lmi_get_computer_system());
LMI_PowerManagementServiceRef powerManagementServiceRef;
LMI_PowerManagementServiceRef_Init(&powerManagementServiceRef, _cb, ns);
@@ -233,13 +226,13 @@ CMInstanceMIStub(
LMI_HostedPowerManagementService,
LMI_HostedPowerManagementService,
_cb,
- LMI_HostedPowerManagementServiceInitialize())
+ LMI_HostedPowerManagementServiceInitialize(ctx))
CMAssociationMIStub(
LMI_HostedPowerManagementService,
LMI_HostedPowerManagementService,
_cb,
- LMI_HostedPowerManagementServiceInitialize())
+ LMI_HostedPowerManagementServiceInitialize(ctx))
KONKRET_REGISTRATION(
"root/cimv2",
diff --git a/src/power/LMI_PowerConcreteJobProvider.c b/src/power/LMI_PowerConcreteJobProvider.c
index b6830ab..63da07b 100644
--- a/src/power/LMI_PowerConcreteJobProvider.c
+++ b/src/power/LMI_PowerConcreteJobProvider.c
@@ -27,14 +27,16 @@ static const CMPIBroker* _cb = NULL;
#include "power.h"
-static void LMI_PowerConcreteJobInitializeInstance(CMPIInstanceMI *mi)
+static void LMI_PowerConcreteJobInitializeInstance(CMPIInstanceMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
-static void LMI_PowerConcreteJobInitializeMethod(CMPIMethodMI *mi)
+static void LMI_PowerConcreteJobInitializeMethod(CMPIMethodMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
static CMPIStatus LMI_PowerConcreteJobCleanup(
@@ -149,7 +151,7 @@ CMInstanceMIStub(
LMI_PowerConcreteJob,
LMI_PowerConcreteJob,
_cb,
- LMI_PowerConcreteJobInitializeInstance(&mi))
+ LMI_PowerConcreteJobInitializeInstance(&mi, ctx))
static CMPIStatus LMI_PowerConcreteJobMethodCleanup(
CMPIMethodMI* mi,
@@ -176,7 +178,7 @@ CMMethodMIStub(
LMI_PowerConcreteJob,
LMI_PowerConcreteJob,
_cb,
- LMI_PowerConcreteJobInitializeMethod(&mi))
+ LMI_PowerConcreteJobInitializeMethod(&mi, ctx))
KUint32 LMI_PowerConcreteJob_KillJob(
const CMPIBroker* cb,
diff --git a/src/power/LMI_PowerManagementCapabilitiesProvider.c b/src/power/LMI_PowerManagementCapabilitiesProvider.c
index 67a0f0f..1024ea9 100644
--- a/src/power/LMI_PowerManagementCapabilitiesProvider.c
+++ b/src/power/LMI_PowerManagementCapabilitiesProvider.c
@@ -25,14 +25,16 @@
static const CMPIBroker* _cb = NULL;
-static void LMI_PowerManagementCapabilitiesInitialize(CMPIInstanceMI *mi)
+static void LMI_PowerManagementCapabilitiesInitialize(CMPIInstanceMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
-static void LMI_PowerManagementCapabilitiesInitializeMethod(CMPIMethodMI *mi)
+static void LMI_PowerManagementCapabilitiesInitializeMethod(CMPIMethodMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
static CMPIStatus LMI_PowerManagementCapabilitiesCleanup(
@@ -144,7 +146,7 @@ CMInstanceMIStub(
LMI_PowerManagementCapabilities,
LMI_PowerManagementCapabilities,
_cb,
- LMI_PowerManagementCapabilitiesInitialize(&mi))
+ LMI_PowerManagementCapabilitiesInitialize(&mi, ctx))
static CMPIStatus LMI_PowerManagementCapabilitiesMethodCleanup(
CMPIMethodMI* mi,
@@ -174,7 +176,7 @@ CMMethodMIStub(
LMI_PowerManagementCapabilities,
LMI_PowerManagementCapabilities,
_cb,
- LMI_PowerManagementCapabilitiesInitializeMethod(&mi))
+ LMI_PowerManagementCapabilitiesInitializeMethod(&mi, ctx))
KUint16 LMI_PowerManagementCapabilities_CreateGoalSettings(
const CMPIBroker* cb,
diff --git a/src/power/LMI_PowerManagementServiceProvider.c b/src/power/LMI_PowerManagementServiceProvider.c
index 00aebb2..f5256bd 100644
--- a/src/power/LMI_PowerManagementServiceProvider.c
+++ b/src/power/LMI_PowerManagementServiceProvider.c
@@ -25,14 +25,16 @@
static const CMPIBroker* _cb = NULL;
-static void LMI_PowerManagementServiceInitialize(CMPIInstanceMI *mi)
+static void LMI_PowerManagementServiceInitialize(CMPIInstanceMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
-static void LMI_PowerManagementServiceMethodInitialize(CMPIMethodMI *mi)
+static void LMI_PowerManagementServiceMethodInitialize(CMPIMethodMI *mi,
+ const CMPIContext *ctx)
{
- mi->hdl = power_ref(_cb);
+ mi->hdl = power_ref(_cb, ctx);
}
@@ -150,7 +152,7 @@ CMInstanceMIStub(
LMI_PowerManagementService,
LMI_PowerManagementService,
_cb,
- LMI_PowerManagementServiceInitialize(&mi))
+ LMI_PowerManagementServiceInitialize(&mi, ctx))
static CMPIStatus LMI_PowerManagementServiceMethodCleanup(
CMPIMethodMI* mi,
@@ -179,7 +181,7 @@ CMMethodMIStub(
LMI_PowerManagementService,
LMI_PowerManagementService,
_cb,
- LMI_PowerManagementServiceMethodInitialize(&mi))
+ LMI_PowerManagementServiceMethodInitialize(&mi, ctx))
KUint32 LMI_PowerManagementService_RequestStateChange(
const CMPIBroker* cb,
diff --git a/src/power/power.c b/src/power/power.c
index bfc6121..646aa45 100644
--- a/src/power/power.c
+++ b/src/power/power.c
@@ -74,9 +74,9 @@ static size_t job_max_id = 0;
Power *_power = NULL;
-Power *power_new(const CMPIBroker *_cb)
+Power *power_new(const CMPIBroker *_cb, const CMPIContext *ctx)
{
- lmi_init(provider_name, _cb, provider_config_defaults);
+ lmi_init(provider_name, _cb, ctx, provider_config_defaults);
Power *power = malloc(sizeof(Power));
power->broker = _cb;
power->instances = 0;
@@ -101,10 +101,10 @@ void power_destroy(Power *power)
#endif
}
-Power *power_ref(const CMPIBroker *_cb)
+Power *power_ref(const CMPIBroker *_cb, const CMPIContext *ctx)
{
if (_power == NULL) {
- _power = power_new(_cb);
+ _power = power_new(_cb, ctx);
}
MUTEX_LOCK(_power);
_power->instances++;
diff --git a/src/power/power.h b/src/power/power.h
index 2f923c8..a533b68 100644
--- a/src/power/power.h
+++ b/src/power/power.h
@@ -34,7 +34,7 @@ typedef struct _PowerStateChangeJob PowerStateChangeJob;
* Get reference to global power object
* \note Don't forget to call power_unref
*/
-Power *power_ref(const CMPIBroker *_cb);
+Power *power_ref(const CMPIBroker *_cb, const CMPIContext *ctx);
/**
* Decrement reference counter for power struct