summaryrefslogtreecommitdiffstats
path: root/src/fan
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2012-07-30 09:47:34 +0200
committerRadek Novacek <rnovacek@redhat.com>2012-07-30 09:47:34 +0200
commit4c44beca56b4334a50518a91a7ce2835e00bc00e (patch)
treea62d32707f9ff39585f2f3f27a80dc1ac5a553c8 /src/fan
parent91821cba81c92e9a204fb3d9637d3fe5dbfd73c0 (diff)
downloadopenlmi-providers-4c44beca56b4334a50518a91a7ce2835e00bc00e.tar.gz
openlmi-providers-4c44beca56b4334a50518a91a7ce2835e00bc00e.tar.xz
openlmi-providers-4c44beca56b4334a50518a91a7ce2835e00bc00e.zip
fan: port Fan provider to KonkretCMPI
Diffstat (limited to 'src/fan')
-rw-r--r--src/fan/CMakeLists.txt33
-rw-r--r--src/fan/Linux_FanAssociatedSensorProvider.c240
-rw-r--r--src/fan/Linux_FanProvider.c393
-rw-r--r--src/fan/Linux_FanSensorProvider.c383
-rw-r--r--src/fan/Makefile35
-rw-r--r--src/fan/cmpiLinux_Fan.c128
-rw-r--r--src/fan/cmpiLinux_Fan.h40
-rw-r--r--src/fan/cmpiLinux_FanAssociatedSensorProvider.c561
-rw-r--r--src/fan/cmpiLinux_FanCommon.c252
-rw-r--r--src/fan/cmpiLinux_FanCommon.h41
-rw-r--r--src/fan/cmpiLinux_FanProvider.c498
-rw-r--r--src/fan/cmpiLinux_FanSensor.c141
-rw-r--r--src/fan/cmpiLinux_FanSensor.h40
-rw-r--r--src/fan/cmpiLinux_FanSensorProvider.c327
-rw-r--r--src/fan/fan.c (renamed from src/fan/Linux_Fan.c)15
-rw-r--r--src/fan/fan.h (renamed from src/fan/Linux_Fan.h)2
-rw-r--r--src/fan/mof/Linux_Fan.mof112
-rw-r--r--src/fan/mof/Linux_Fan.reg18
18 files changed, 1052 insertions, 2207 deletions
diff --git a/src/fan/CMakeLists.txt b/src/fan/CMakeLists.txt
index c35ad02..405c6ef 100644
--- a/src/fan/CMakeLists.txt
+++ b/src/fan/CMakeLists.txt
@@ -1,21 +1,30 @@
set(PROVIDER_NAME Fan)
set(LIBRARY_NAME cmpi${PROVIDER_NAME})
+set(MOF Linux_Fan.mof)
set(provider_SRCS
- cmpiLinux_Fan.c
- cmpiLinux_FanAssociatedSensorProvider.c
- cmpiLinux_FanCommon.c
- cmpiLinux_FanProvider.c
- cmpiLinux_FanSensor.c
- cmpiLinux_FanSensorProvider.c
- Linux_Fan.c
+ fan.c
+ Linux_FanProvider.c
)
-#add_library(${LIBRARY_NAME} SHARED
-# ${provider_SRCS}
-#)
+konkretcmpi_generate(${MOF}
+ CIM_PROVIDERS
+ CIM_HEADERS
+)
+
+add_library(${LIBRARY_NAME} SHARED
+ ${provider_SRCS}
+ ${CIM_PROVIDERS}
+ ${CIM_HEADERS}
+)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMPI_INCLUDE_DIR})
+
+target_link_libraries(${LIBRARY_NAME} curacommon ${KONKRETCMPI_LIBRARIES} sensors)
+
+# Create registration file
+cim_registration(${PROVIDER_NAME} ${LIBRARY_NAME} ${MOF})
-include_directories(${CMPI_INCLUDE_DIR})
+install(TARGETS ${LIBRARY_NAME} DESTINATION lib${LIB_SUFFIX}/cmpi/)
-#install(TARGETS ${LIBRARY_NAME} DESTINATION lib${LIB_SUFFIX}/cmpi)
diff --git a/src/fan/Linux_FanAssociatedSensorProvider.c b/src/fan/Linux_FanAssociatedSensorProvider.c
new file mode 100644
index 0000000..ddb55c1
--- /dev/null
+++ b/src/fan/Linux_FanAssociatedSensorProvider.c
@@ -0,0 +1,240 @@
+#include <konkret/konkret.h>
+#include "Linux_FanAssociatedSensor.h"
+#include "fan.h"
+#include <globals.h>
+
+static const CMPIBroker* _cb;
+
+static void Linux_FanAssociatedSensorInitialize()
+{
+ init_linux_fan_module();
+}
+
+static CMPIStatus Linux_FanAssociatedSensorCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ const char *ns = KNameSpace(cop);
+
+ struct cim_fan *sptr = NULL;
+ struct fanlist *lptr = NULL, *fans = NULL;
+ if (enum_all_fans(&fans) != 0 ) {
+ KReturn2(_cb, ERR_FAILED, "Could not list get fan list.");
+ }
+
+ lptr = fans;
+ // iterate fan list
+ while (lptr) {
+ sptr = lptr->f;
+ Linux_FanAssociatedSensor w;
+ Linux_FanAssociatedSensor_Init(&w, _cb, ns);
+
+ Linux_FanRef fan;
+ Linux_FanRef_Init(&fan, _cb, ns);
+ Linux_FanRef_Set_CreationClassName(&fan, "Linux_Fan");
+ Linux_FanRef_Set_DeviceID(&fan, sptr->device_id);
+ Linux_FanRef_Set_SystemCreationClassName(&fan, get_system_creation_class_name());
+ Linux_FanRef_Set_SystemName(&fan, get_system_name());
+
+ Linux_FanSensorRef fanSensor;
+ Linux_FanSensorRef_Init(&fanSensor, _cb, ns);
+ Linux_FanSensorRef_Set_CreationClassName(&fanSensor, "Linux_FanSensor");
+ Linux_FanSensorRef_Set_DeviceID(&fanSensor, sptr->device_id);
+ Linux_FanSensorRef_Set_SystemCreationClassName(&fanSensor, get_system_creation_class_name());
+ Linux_FanSensorRef_Set_SystemName(&fanSensor, get_system_name());
+
+ Linux_FanAssociatedSensor_Set_Antecedent(&w, &fanSensor);
+ Linux_FanAssociatedSensor_Set_Dependent(&w, &fan);
+
+ KReturnInstance(cr, w);
+ lptr = lptr->next;
+ }
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorModifyInstance(
+ 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 Linux_FanAssociatedSensorDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorExecQuery(
+ 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 Linux_FanAssociatedSensorAssociationCleanup(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorAssociators(
+ 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,
+ Linux_FanAssociatedSensor_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole,
+ properties);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorAssociatorNames(
+ 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,
+ Linux_FanAssociatedSensor_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorReferences(
+ 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,
+ Linux_FanAssociatedSensor_ClassName,
+ assocClass,
+ role,
+ properties);
+}
+
+static CMPIStatus Linux_FanAssociatedSensorReferenceNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role)
+{
+ return KDefaultReferenceNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ Linux_FanAssociatedSensor_ClassName,
+ assocClass,
+ role);
+}
+
+CMInstanceMIStub(
+ Linux_FanAssociatedSensor,
+ Linux_FanAssociatedSensor,
+ _cb,
+ Linux_FanAssociatedSensorInitialize())
+
+CMAssociationMIStub(
+ Linux_FanAssociatedSensor,
+ Linux_FanAssociatedSensor,
+ _cb,
+ Linux_FanAssociatedSensorInitialize())
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "Linux_FanAssociatedSensor",
+ "Linux_FanAssociatedSensor",
+ "instance association")
diff --git a/src/fan/Linux_FanProvider.c b/src/fan/Linux_FanProvider.c
new file mode 100644
index 0000000..fe7a0fa
--- /dev/null
+++ b/src/fan/Linux_FanProvider.c
@@ -0,0 +1,393 @@
+#include <konkret/konkret.h>
+#include <stdint.h>
+#include "Linux_Fan.h"
+#include "globals.h"
+#include "fan.h"
+static const CMPIBroker* _cb = NULL;
+
+#include <signal.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+void print_backtrace(int signal)
+{
+ fprintf(stderr, "BackTrace\n");
+ int ppid = getpid();
+ int pid = fork();
+ if (pid == 0) {
+ // Child process
+ char *strpid;
+ asprintf(&strpid, "%d", ppid);
+ execl("/usr/bin/gdb", "/usr/bin/gdb", "-p", strpid, NULL);
+ } else {
+ int status;
+ waitpid(pid, &status, 0);
+ system("/usr/bin/pkill -9 sfcbd");
+ }
+}
+
+static void Linux_FanInitialize()
+{
+ init_linux_fan_module();
+ signal(SIGSEGV, print_backtrace);
+}
+
+static CMPIStatus Linux_FanCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus Linux_FanEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ const char *ns = KNameSpace(cop);
+
+ char buf[200];
+ struct fanlist *lptr = NULL;
+ struct fanlist *fans = NULL;
+ struct cim_fan *sptr;
+
+ if (enum_all_fans(&fans)) {
+ KReturn2(_cb, ERR_FAILED, "Could not list fans.");
+ }
+
+ // iterate fan list
+ lptr = fans;
+ while (lptr != NULL) {
+ sptr = lptr->f;
+ Linux_Fan w;
+ Linux_Fan_Init(&w, _cb, ns);
+ Linux_Fan_Set_CreationClassName(&w, "Linux_Fan");
+ Linux_Fan_Set_SystemCreationClassName(&w, get_system_creation_class_name());
+ Linux_Fan_Set_SystemName(&w, get_system_name());
+ Linux_Fan_Set_DeviceID(&w, sptr->device_id);
+
+ Linux_Fan_Set_Caption(&w, "Computer's fan");
+ Linux_Fan_Set_Description(&w,"Computer's fan.");
+ snprintf(buf, 200, "Fan \"%s\" on chip \"%s\"", sptr->name, sptr->chip_name);
+ Linux_Fan_Set_ElementName(&w, buf);
+
+ // ManagedSystemElement
+ Linux_Fan_Set_Name(&w, sptr->name);
+ Linux_Fan_Init_OperationalStatus(&w, 2);
+ Linux_Fan_Set_OperationalStatus(&w, 0, sptr->fault ?
+ Linux_Fan_OperationalStatus_Error :
+ Linux_Fan_OperationalStatus_OK);
+ if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
+ Linux_Fan_Set_OperationalStatus(&w, 1, Linux_Fan_OperationalStatus_Stressed);
+ }
+
+ Linux_Fan_Init_StatusDescriptions(&w, 2);
+ Linux_Fan_Set_StatusDescriptions(&w, 0, sptr->fault ?
+ "Chip indicates, that fan is in fault state."
+ " Possible causes are open diodes, unconnected fan etc."
+ " Thus the measurement for this channel should not be trusted."
+ : "Fan seems to be functioning correctly.");
+ if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
+ snprintf(buf, 200, "These alarm flags are set by the fan's chip:"
+ " alarm=%s, min_alarm=%s, max_alarm=%s",
+ sptr->alarm ? "1":"0",
+ sptr->alarm_min ? "1":"0",
+ sptr->alarm_max ? "1":"0");
+ Linux_Fan_Set_StatusDescriptions(&w, 1, buf);
+ }
+
+
+ Linux_Fan_Set_HealthState(&w, sptr->fault ?
+ Linux_Fan_HealthState_Major_failure :
+ Linux_Fan_HealthState_OK);
+
+ Linux_Fan_Set_OperatingStatus(&w, sptr->fault ?
+ Linux_Fan_OperatingStatus_Stopped :
+ Linux_Fan_OperatingStatus_In_Service);
+
+ Linux_Fan_Set_PrimaryStatus(&w, sptr->fault ?
+ Linux_Fan_PrimaryStatus_Error :
+ Linux_Fan_PrimaryStatus_OK);
+
+ // EnabledLogicalElement
+ Linux_Fan_Init_OtherIdentifyingInfo(&w, 2);
+ Linux_Fan_Set_OtherIdentifyingInfo(&w, 0, sptr->chip_name);
+ Linux_Fan_Set_OtherIdentifyingInfo(&w, 1, sptr->sys_path);
+
+ Linux_Fan_Init_IdentifyingDescriptions(&w, 2);
+ Linux_Fan_Set_IdentifyingDescriptions(&w, 0, "ChipName - name of fan's chip.");
+ Linux_Fan_Set_IdentifyingDescriptions(&w, 1, "SysPath - system path of fan's chip.");
+
+ Linux_Fan_Set_ActiveCooling(&w, true);
+
+ uint32_t i = 1;
+ int index = 0;
+ debug("accessible_features: %d", sptr->accessible_features);
+ Linux_Fan_Init_AccessibleFeatures(&w, 8);
+ while (i <= CIM_FAN_AF_FEATURE_MAX) {
+ if (i & sptr->accessible_features) {
+ Linux_Fan_Set_AccessibleFeatures(&w, index++, i);
+ }
+ i = i << 1;
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
+ Linux_Fan_Set_MinSpeed(&w, (uint64_t) sptr->min_speed);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
+ Linux_Fan_Set_MaxSpeed(&w, (uint64_t) sptr->max_speed);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_DIV) {
+ Linux_Fan_Set_Divisor(&w, sptr->divisor);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_PULSES) {
+ Linux_Fan_Set_Pulses(&w, sptr->pulses);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_BEEP) {
+ Linux_Fan_Set_Beep(&w, sptr->beep);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_ALARM) {
+ Linux_Fan_Set_Alarm(&w, sptr->alarm);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_ALARM_MIN) {
+ Linux_Fan_Set_MinAlarm(&w, sptr->alarm_min);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_ALARM_MAX) {
+ Linux_Fan_Set_MaxAlarm(&w, sptr->alarm_max);
+ }
+
+ KReturnInstance(cr, w);
+ lptr = lptr->next;
+ }
+ free_fanlist(fans);
+ KReturn(OK);
+}
+
+static CMPIStatus Linux_FanGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus Linux_FanCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanModifyInstance(
+ 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 Linux_FanDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+CMInstanceMIStub(
+ Linux_Fan,
+ Linux_Fan,
+ _cb,
+ Linux_FanInitialize())
+
+static CMPIStatus Linux_FanMethodCleanup(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanInvokeMethod(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* meth,
+ const CMPIArgs* in,
+ CMPIArgs* out)
+{
+ return Linux_Fan_DispatchMethod(
+ _cb, mi, cc, cr, cop, meth, in, out);
+}
+
+CMMethodMIStub(
+ Linux_Fan,
+ Linux_Fan,
+ _cb,
+ Linux_FanInitialize())
+
+KUint32 Linux_Fan_RequestStateChange(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KUint16* RequestedState,
+ KRef* Job,
+ const KDateTime* TimeoutPeriod,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_SetPowerState(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KUint16* PowerState,
+ const KDateTime* Time,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_Reset(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_EnableDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KBoolean* Enabled,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_OnlineDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KBoolean* Online,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_QuiesceDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KBoolean* Quiesce,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_SaveProperties(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_RestoreProperties(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_Fan_SetSpeed(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanRef* self,
+ const KUint64* DesiredSpeed,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "Linux_Fan",
+ "Linux_Fan",
+ "instance method")
diff --git a/src/fan/Linux_FanSensorProvider.c b/src/fan/Linux_FanSensorProvider.c
new file mode 100644
index 0000000..390e5cf
--- /dev/null
+++ b/src/fan/Linux_FanSensorProvider.c
@@ -0,0 +1,383 @@
+#include <konkret/konkret.h>
+#include "Linux_FanSensor.h"
+#include "fan.h"
+#include <globals.h>
+
+static const CMPIBroker* _cb = NULL;
+
+static void Linux_FanSensorInitialize()
+{
+ init_linux_fan_module();
+}
+
+static CMPIStatus Linux_FanSensorCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanSensorEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus Linux_FanSensorEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ char buf[200];
+ struct cim_fan *sptr = NULL;
+ struct fanlist *lptr = NULL, *fans = NULL;
+ if (enum_all_fans(&fans) != 0 ) {
+ KReturn2(_cb, ERR_FAILED, "Could not list get fan list.");
+ }
+
+ lptr = fans;
+ // iterate fan list
+ while (lptr) {
+ sptr = lptr->f;
+ Linux_FanSensor w;
+ Linux_FanSensor_Init(&w, _cb, KNameSpace(cop));
+ Linux_FanSensor_Set_CreationClassName(&w, "Linux_FanSensor");
+ Linux_FanSensor_Set_SystemCreationClassName(&w, get_system_creation_class_name());
+ Linux_FanSensor_Set_SystemName(&w, get_system_name());
+ Linux_FanSensor_Set_DeviceID(&w, sptr->device_id);
+
+ Linux_FanSensor_Set_Caption(&w, "Computer's fan");
+ Linux_FanSensor_Set_Description(&w,"Computer's fan.");
+ snprintf(buf, 200, "Fan \"%s\" on chip \"%s\"", sptr->name, sptr->chip_name);
+ Linux_FanSensor_Set_ElementName(&w, buf);
+
+ // ManagedSystemElement
+ Linux_FanSensor_Set_Name(&w, sptr->name);
+
+ Linux_FanSensor_Init_OperationalStatus(&w, 2);
+ Linux_FanSensor_Set_OperationalStatus(&w, 0, sptr->fault ?
+ Linux_FanSensor_OperationalStatus_Error :
+ Linux_FanSensor_OperationalStatus_OK);
+ if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
+ Linux_FanSensor_Set_OperationalStatus(&w, 1, Linux_FanSensor_OperationalStatus_Stressed);
+ }
+
+ Linux_FanSensor_Init_StatusDescriptions(&w, 2);
+ Linux_FanSensor_Set_StatusDescriptions(&w, 0, sptr->fault ?
+ "Chip indicates, that fan is in fault state."
+ " Possible causes are open diodes, unconnected fan etc."
+ " Thus the measurement for this channel should not be trusted."
+ : "Fan seems to be functioning correctly.");
+ if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
+ snprintf(buf, 200, "These alarm flags are set by the fan's chip:"
+ " alarm=%s, min_alarm=%s, max_alarm=%s",
+ sptr->alarm ? "1":"0",
+ sptr->alarm_min ? "1":"0",
+ sptr->alarm_max ? "1":"0");
+ Linux_FanSensor_Set_StatusDescriptions(&w, 1, buf);
+ }
+
+ Linux_FanSensor_Set_HealthState(&w, sptr->fault ?
+ Linux_FanSensor_HealthState_Major_failure :
+ Linux_FanSensor_HealthState_OK);
+
+ Linux_FanSensor_Set_OperatingStatus(&w, sptr->fault ?
+ Linux_FanSensor_OperatingStatus_Stopped :
+ Linux_FanSensor_OperatingStatus_In_Service);
+
+ Linux_FanSensor_Set_PrimaryStatus(&w, sptr->fault ?
+ Linux_FanSensor_PrimaryStatus_Error :
+ Linux_FanSensor_PrimaryStatus_OK);
+
+ // EnabledLogicalElement
+ Linux_FanSensor_Init_OtherIdentifyingInfo(&w, 2);
+ Linux_FanSensor_Set_OtherIdentifyingInfo(&w, 0, sptr->chip_name);
+ Linux_FanSensor_Set_OtherIdentifyingInfo(&w, 1, sptr->sys_path);
+
+ Linux_FanSensor_Init_IdentifyingDescriptions(&w, 2);
+ Linux_FanSensor_Set_IdentifyingDescriptions(&w, 0, "ChipName - name of fan's chip.");
+ Linux_FanSensor_Set_IdentifyingDescriptions(&w, 1, "SysPath - system path of fan's chip.");
+
+ // ManagedElement
+ Linux_FanSensor_Set_Caption(&w, "Fan's tachometer");
+ Linux_FanSensor_Set_Description(&w,"Associated sensor of fan. Giving information about its speed.");
+
+ snprintf(buf, 200, "Tachometer of fan \"%s\" on chip \"%s\"", sptr->name, sptr->chip_name);
+ Linux_FanSensor_Set_ElementName(&w, buf);
+
+ // Sensor
+ Linux_FanSensor_Set_SensorType(&w, Linux_FanSensor_SensorType_Tachometer);
+ Linux_FanSensor_Set_CurrentState(&w, fan_get_current_state(sptr));
+
+ Linux_FanSensor_Init_PossibleStates(&w, 5);
+ int index = 0;
+ if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
+ Linux_FanSensor_Set_PossibleStates(&w, index++, "Below Minimum");
+ Linux_FanSensor_Set_PossibleStates(&w, index++, "At Minimum");
+ }
+ Linux_FanSensor_Set_PossibleStates(&w, index++, "Normal");
+ if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
+ Linux_FanSensor_Set_PossibleStates(&w, index++, "At Maximum");
+ Linux_FanSensor_Set_PossibleStates(&w, index++, "Above Maximum");
+ }
+
+ // NumericSensor
+ Linux_FanSensor_Set_BaseUnits(&w, Linux_FanSensor_BaseUnits_Revolutions);
+ Linux_FanSensor_Set_UnitModifier(&w, 0);
+ Linux_FanSensor_Set_RateUnits(&w, Linux_FanSensor_RateUnits_Per_Minute);
+ Linux_FanSensor_Set_CurrentReading(&w, sptr->speed);
+ if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
+ Linux_FanSensor_Set_NormalMax(&w, sptr->max_speed);
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
+ Linux_FanSensor_Set_NormalMin(&w, sptr->min_speed);
+ }
+ Linux_FanSensor_Set_MinReadable(&w, 0);
+ Linux_FanSensor_Set_IsLinear(&w, true);
+
+ KReturnInstance(cr, w);
+ lptr = lptr->next;
+ }
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanSensorGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus Linux_FanSensorCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanSensorModifyInstance(
+ 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 Linux_FanSensorDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_FanSensorExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+CMInstanceMIStub(
+ Linux_FanSensor,
+ Linux_FanSensor,
+ _cb,
+ Linux_FanSensorInitialize())
+
+static CMPIStatus Linux_FanSensorMethodCleanup(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_FanSensorInvokeMethod(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* meth,
+ const CMPIArgs* in,
+ CMPIArgs* out)
+{
+ return Linux_FanSensor_DispatchMethod(
+ _cb, mi, cc, cr, cop, meth, in, out);
+}
+
+CMMethodMIStub(
+ Linux_FanSensor,
+ Linux_FanSensor,
+ _cb,
+ Linux_FanSensorInitialize())
+
+KUint32 Linux_FanSensor_RequestStateChange(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KUint16* RequestedState,
+ KRef* Job,
+ const KDateTime* TimeoutPeriod,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_SetPowerState(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KUint16* PowerState,
+ const KDateTime* Time,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_Reset(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_EnableDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KBoolean* Enabled,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_OnlineDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KBoolean* Online,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_QuiesceDevice(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KBoolean* Quiesce,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_SaveProperties(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_RestoreProperties(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_RestoreDefaultThresholds(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KUint32 Linux_FanSensor_GetNonLinearFactors(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_FanSensorRef* self,
+ const KSint32* SensorReading,
+ KSint32* Accuracy,
+ KUint32* Resolution,
+ KSint32* Tolerance,
+ KUint32* Hysteresis,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "Linux_FanSensor",
+ "Linux_FanSensor",
+ "instance method")
diff --git a/src/fan/Makefile b/src/fan/Makefile
deleted file mode 100644
index 35a91c7..0000000
--- a/src/fan/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-CC=gcc
-CFLAGS=-Wall -Wextra -std=c99 -g
-LIBS=Linux_Fan Linux_FanSensor Linux_FanAssociatedSensor
-LIBRARIES=$(foreach l,$(LIBS),cmpi$(l)Provider)
-LIBRNS=$(foreach l,$(LIBRARIES),lib$(l).so)
-DESTLIBDIR=$(shell [ `uname -m` = "x86_64" ] && echo /usr/lib64/cmpi || echo /usr/lib/cmpi)
-LINKS=$(foreach l,$(LIBRNS),$(DESTLIBDIR)/$(l))
-
-providers: $(LIBRNS)
-
-libcmpiLinux_FanAssociatedSensorProvider.so: \
- cmpiLinux_FanAssociatedSensorProvider.o
- $(CC) -shared -Wl -o $@ $^ -lcmpiOSBase_Common
-
-libcmpi%Provider.so: cmpi%Provider.o cmpi%.o \
- cmpiLinux_FanCommon.o Linux_Fan.o
- $(CC) -shared -Wl -o $@ $^ -lcmpiOSBase_Common -lsensors
-
-%.o: %.c
- $(CC) $(CFLAGS) -I/usr/include/cmpi -c -fPIC -o $@ $^
-
-clean:
- -rm *.o *.so
-
-sfcb: $(LINKS)
- sfcbstage -r mof/Linux_Fan.reg mof/Linux_Fan.mof
- sfcbrepos -f
-
-$(DESTLIBDIR)/%.so: %.so
- ln -sf `pwd`/$? $(DESTLIBDIR)
-
-install: $(LIBRNS)
- cp $^ $(DESTLIBDIR)
- sfcbstage -r mof/Linux_Fan.reg mof/Linux_Fan.mof
- sfcbrepos -f
diff --git a/src/fan/cmpiLinux_Fan.c b/src/fan/cmpiLinux_Fan.c
deleted file mode 100644
index 8088a70..0000000
--- a/src/fan/cmpiLinux_Fan.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#ifndef _XOPEN_SOURCE
- //this is for strdup
- #define _XOPEN_SOURCE 500
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-#include "cmpiLinux_Fan.h"
-
-static CMPIArray * _get_AccessibleFeatures(
- CMPIBroker const *_broker,
- CMPIStatus *rc,
- struct cim_fan const *sptr)
-{
- int index = 0;
- uint16_t value = 1;
- unsigned int i = 1;
-
- CMPIArray *res = CMNewArray(_broker, 8, CMPI_uint16, rc);
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 8, CMPI_uint16, rc)");
- _OSBASE_TRACE(2, ("--- _get_AccessibleFeatures failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- while (i <= CIM_FAN_AF_FEATURE_MAX) {
- if (i & sptr->accessible_features) {
- CMSetArrayElementAt(res, index++, (CMPIValue*)(&value),
- CMPI_uint16);
- }
- ++value;
- i = i << 1;
- }
- }
- return res;
-}
-
-CMPIObjectPath * _makePath_Fan(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc)
-{
- return _makePath_FanCommon(_ClassName, _broker, ctx, cop, sptr, rc);
-}
-
-CMPIInstance * _makeInst_Fan(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc)
-{
- CMPIObjectPath *op;
- CMPIInstance *ci;
- CMPIValue val;
-
- _OSBASE_TRACE(2, ("--- _makeInst_Fan() called"));
- if (!(ci = _makeInst_FanCommon(_ClassName, _broker, ctx, cop, properties,
- sptr, rc, &op))) {
- return NULL;
- }
-
- // CoolingDevice
- val.boolean = true;
- CMSetProperty(ci, "ActiveCooling", &val, CMPI_boolean);
-
- // CIM_Fan
- // Linux_Fan
- val.array = _get_AccessibleFeatures(_broker, rc, sptr);
- if (!rc->rc) {
- CMSetProperty(ci, "AccessibleFeatures", &val, CMPI_uint16A);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
- val.uint64 = (uint64_t) sptr->min_speed;
- CMSetProperty(ci, "MinSpeed", &val, CMPI_uint64);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
- val.uint64 = (uint64_t) sptr->max_speed;
- CMSetProperty(ci, "MaxSpeed", &val, CMPI_uint64);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_DIV) {
- CMSetProperty(ci, "Divisor", &sptr->divisor, CMPI_uint32);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_PULSES) {
- CMSetProperty(ci, "Pulses", &sptr->pulses, CMPI_uint32);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_BEEP) {
- val.boolean = sptr->beep;
- CMSetProperty(ci, "Beep", &val, CMPI_boolean);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_ALARM) {
- CMSetProperty(ci, "Alarm", &sptr->alarm, CMPI_boolean);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_ALARM_MIN) {
- CMSetProperty(ci, "MinAlarm", &sptr->alarm_min, CMPI_boolean);
- }
- if (!rc->rc && sptr->accessible_features & CIM_FAN_AF_ALARM_MAX) {
- CMSetProperty(ci, "MaxAlarm", &sptr->alarm_max, CMPI_boolean);
- }
-
- _OSBASE_TRACE(2, ("--- _makeInst_Fan() exited"));
- return ci;
-}
-
diff --git a/src/fan/cmpiLinux_Fan.h b/src/fan/cmpiLinux_Fan.h
deleted file mode 100644
index 5fc7227..0000000
--- a/src/fan/cmpiLinux_Fan.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#ifndef CMPILINUX_FAN_H_
-#define CMPILINUX_FAN_H_
-
-#include "cmpiLinux_FanCommon.h"
-
-static char const *_ClassName = "Linux_Fan";
-
-CMPIObjectPath * _makePath_Fan(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc);
-
-CMPIInstance * _makeInst_Fan(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc);
-
-#endif /* ----- CMPILINUX_FAN_H_ ----- */
-
diff --git a/src/fan/cmpiLinux_FanAssociatedSensorProvider.c b/src/fan/cmpiLinux_FanAssociatedSensorProvider.c
deleted file mode 100644
index 61e7dfb..0000000
--- a/src/fan/cmpiLinux_FanAssociatedSensorProvider.c
+++ /dev/null
@@ -1,561 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <strings.h>
-
-#include <cmpi/cmpidt.h>
-#include <cmpi/cmpift.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-static char const * _ClassName = "Linux_FanAssociatedSensor";
-static char const * _RefLeft = "Antecedent";
-static char const * _RefRight = "Dependent";
-static char const * _RefLeftClass = "Linux_FanSensor";
-static char const * _RefRightClass = "Linux_Fan";
-
-#define UNUSED(x) ((void) (x))
-static const CMPIBroker * _broker;
-#ifdef CMPI_VER_100
- #define Linux_FanAssociatedSensorProviderSetInstance \
- Linux_FanAssociatedSensorProviderModifyInstance
-#endif
-
-/* ---------------------------------------------------------------------------*/
-/* Instance Provider Interface */
-/* ---------------------------------------------------------------------------*/
-
-CMPIStatus Linux_FanAssociatedSensorProviderCleanup(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- CMPIBoolean terminate)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(terminate);
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() called",_ClassName));
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderEnumInstanceNames(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref)
-{
- UNUSED(mi);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName));
-
- refrc = _assoc_create_inst_1toN( _broker,ctx,rslt,ref,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 1,0,&rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstanceNames() failed",_ClassName));
- }
- return rc;
- }
-
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstanceNames() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderEnumInstances(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char ** properties)
-{
- UNUSED(mi); UNUSED(properties);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName));
-
- refrc = _assoc_create_inst_1toN( _broker,ctx,rslt,ref,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 1,1,&rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstances() failed",_ClassName));
- }
- return rc;
- }
-
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstances() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderGetInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char ** properties)
-{
- UNUSED(mi); UNUSED(properties);
- const CMPIInstance * ci = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName));
-
- ci = _assoc_get_inst( _broker,ctx,cop,_ClassName,_RefLeft,_RefRight,&rc);
-
- if( ci == NULL ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI GetInstance() failed",_ClassName));
- }
- return rc;
- }
-
- CMReturnInstance( rslt, ci );
- CMReturnDone(rslt);
- _OSBASE_TRACE(1,("--- %s CMPI GetInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderCreateInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop); UNUSED(ci);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI CreateInstance() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI CreateInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderSetInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci,
- const char ** properties)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop); UNUSED(ci);
- UNUSED(properties);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI SetInstance() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI SetInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderDeleteInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderExecQuery(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char * lang,
- const char * query)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(ref); UNUSED(lang);
- UNUSED(query);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() exited",_ClassName));
- return rc;
-}
-
-
-/* ---------------------------------------------------------------------------*/
-/* Associator Provider Interface */
-/* ---------------------------------------------------------------------------*/
-
-
-CMPIStatus Linux_FanAssociatedSensorProviderAssociationCleanup(
- CMPIAssociationMI * mi,
- const CMPIContext * ctx,
- CMPIBoolean terminate)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(terminate);
- _OSBASE_TRACE(1,("--- %s CMPI AssociationCleanup() called",_ClassName));
- _OSBASE_TRACE(1,("--- %s CMPI AssociationCleanup() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-/*
- * The intention of associations is to show the relations between different
- * classes and their instances. Therefore an association has two properties.
- * Each one representing a reference to a certain instance of the specified
- * class. We can say, that an association has a left and the right "end".
- *
- * Linux_RunningOS :
- * < role > -> < class >
- * Antecedent -> Linux_Fan
- * Dependent -> Linux_FanSensor
- *
- */
-
-/*
- * general API information
- *
- * cop :
- * Specifies the CMPIObjectPath to the CMPIInstance of the known end of
- * the association. Its absolutelly necessary to define this anchor point,
- * from where the evaluation of the association starts.
- * assocPath :
- * If not NULL, it contains the name of the association the caller is
- * looking for. The provider should only return values, when the assocPath
- * contains the name(s) of the association(s) he is responsible for !
- * role :
- * The caller can specify that the source instance ( cop ) has to play
- * a certain <role> in the association. The <role> is specified by the
- * association definition (see above). That means, role has to contain
- * the same value as the <role> the source instance plays in this assoc.
- * If this requirement is not true, the provider returns nothing.
- */
-
-/*
- * specification of associators() and associatorNames()
- *
- * These methods return CMPIInstance ( in the case of associators() ) or
- * CMPIObjectPath ( in the case of associatorNames() ) object(s) of the
- * opposite end of the association.
- *
- * resultRole :
- * The caller can specify that the target instance(s) has/have to play
- * a certain <role> in the association. The <role> is specified by the
- * association definition (see above). That means, resultRole has to
- * contain the same value as the <role> the target instance(s) plays
- * in this assoc. If this requirement is not true, the provider returns
- * nothing.
- * resultClass :
- * The caller can specify that the target instance(s) has/have to be
- * instances of a certain <class>. The <class> is specified by the
- * association definition (see above). That means, resultClass has to
- * contain the same value as the <class> of the target instance(s).
- * If this requirement is not true, the provider returns nothing.
- */
-
-CMPIStatus Linux_FanAssociatedSensorProviderAssociators(
- CMPIAssociationMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char * assocClass,
- const char * resultClass,
- const char * role,
- const char * resultRole,
- const char ** propertyList)
-{
- UNUSED(mi); UNUSED(propertyList);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- CMPIObjectPath * op = NULL;
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI Associators() called",_ClassName));
-
- if( assocClass ) {
- op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)),
- _ClassName, &rc );
- if( op==NULL ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." );
- _OSBASE_TRACE(2,
- ("--- %s CMPI Associators() failed : %s",CMGetCharPtr(rc.msg)));
- return rc;
- }
- }
-
- if ( (assocClass == NULL)
- || (CMClassPathIsA(_broker,op,assocClass,&rc) == 1))
- {
-
- if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight,
- _RefLeftClass,_RefRightClass,
- resultClass,role,resultRole,
- &rc ) == 0 ) { goto exit; }
-
- refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 1, 1, &rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI Associators() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI Associators() failed",_ClassName));
- }
- return rc;
- }
- }
-
- exit:
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI Associators() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderAssociatorNames(
- CMPIAssociationMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char * assocClass,
- const char * resultClass,
- const char * role,
- const char * resultRole)
-{
- UNUSED(mi);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- CMPIObjectPath * op = NULL;
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI AssociatorNames() called",_ClassName));
-
- if( assocClass ) {
- op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)),
- _ClassName, &rc );
- if( op==NULL ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." );
- _OSBASE_TRACE(2, ("--- %s CMPI AssociatorNames() failed : %s",
- CMGetCharPtr(rc.msg)));
- return rc;
- }
- }
-
- if( ( assocClass==NULL ) || ( CMClassPathIsA(_broker,op,assocClass,&rc) == 1 ) ) {
-
- if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight,
- _RefLeftClass,_RefRightClass,
- resultClass,role,resultRole,
- &rc ) == 0 ) { goto exit; }
-
- refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 0, 1, &rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI AssociatorNames() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI AssociatorNames() failed",_ClassName));
- }
- return rc;
- }
- }
-
- exit:
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI AssociatorNames() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-
-/*
- * specification of references() and referenceNames()
- *
- * These methods return CMPIInstance ( in the case of references() ) or
- * CMPIObjectPath ( in the case of referenceNames() ) object(s) of th
- * association itself.
- */
-
-CMPIStatus Linux_FanAssociatedSensorProviderReferences(
- CMPIAssociationMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char * assocClass,
- const char * role,
- const char ** propertyList)
-{
- UNUSED(mi); UNUSED(propertyList);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- CMPIObjectPath * op = NULL;
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI References() called",_ClassName));
-
- if( assocClass ) {
- op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)),
- _ClassName, &rc );
- if( op==NULL ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." );
- _OSBASE_TRACE(2,("--- %s CMPI References() failed : %s",CMGetCharPtr(rc.msg)));
- return rc;
- }
- }
-
- if( ( assocClass==NULL ) || ( CMClassPathIsA(_broker,op,assocClass,&rc) == 1 ) ) {
-
- if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight,
- _RefLeftClass,_RefRightClass,
- NULL,role,NULL,
- &rc ) == 0 ) { goto exit; }
-
- refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 1, 0, &rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI References() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI References() failed",_ClassName));
- }
- return rc;
- }
- }
-
- exit:
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI References() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanAssociatedSensorProviderReferenceNames(
- CMPIAssociationMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char * assocClass,
- const char * role)
-{
- UNUSED(mi);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- CMPIObjectPath * op = NULL;
- int refrc = 0;
-
- _OSBASE_TRACE(1,("--- %s CMPI ReferenceNames() called",_ClassName));
-
- if( assocClass ) {
- op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)),
- _ClassName, &rc );
- if( op==NULL ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." );
- _OSBASE_TRACE(2,("--- %s CMPI ReferenceNames() failed : %s",CMGetCharPtr(rc.msg)));
- return rc;
- }
- }
-
- if( ( assocClass==NULL ) || ( CMClassPathIsA(_broker,op,assocClass,&rc) == 1 ) ) {
-
- if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight,
- _RefLeftClass,_RefRightClass,
- NULL,role,NULL,
- &rc ) == 0 ) { goto exit; }
-
- refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop,
- _ClassName,_RefLeftClass,_RefRightClass,
- _RefLeft,_RefRight,
- 0, 0, &rc);
- if( refrc != 0 ) {
- if( rc.msg != NULL ) {
- _OSBASE_TRACE(1,("--- %s CMPI ReferenceNames() failed : %s",_ClassName,CMGetCharPtr(rc.msg)));
- }
- else {
- _OSBASE_TRACE(1,("--- %s CMPI ReferenceNames() failed",_ClassName));
- }
- return rc;
- }
- }
-
- exit:
- CMReturnDone( rslt );
- _OSBASE_TRACE(1,("--- %s CMPI ReferenceNames() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Provider Factory */
-/* ---------------------------------------------------------------------------*/
-CMInstanceMIStub( Linux_FanAssociatedSensorProvider,
- Linux_FanAssociatedSensorProvider,
- _broker,
- CMNoHook);
-
-CMAssociationMIStub( Linux_FanAssociatedSensorProvider,
- Linux_FanAssociatedSensorProvider,
- _broker,
- CMNoHook);
-
-/* ---------------------------------------------------------------------------*/
-/* end of cmpiLinux_FanAssociatedSensorProvider */
-/* ---------------------------------------------------------------------------*/
-
diff --git a/src/fan/cmpiLinux_FanCommon.c b/src/fan/cmpiLinux_FanCommon.c
deleted file mode 100644
index 68aca46..0000000
--- a/src/fan/cmpiLinux_FanCommon.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-#include "cmpiLinux_FanCommon.h"
-
-#define UNUSED(x) ((void) (x))
-
-static CMPIArray * _get_OperationalStatus(
- CMPIBroker const *_broker,
- CMPIStatus *rc,
- struct cim_fan const *sptr)
-{
- CMPIArray *res = CMNewArray(_broker, 2, CMPI_uint16, rc);
- unsigned short val;
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 2, CMPI_uint16, rc)");
- _OSBASE_TRACE(2, ("--- _get_OperationalStatus failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- val = sptr->fault ? 3:1; // Error : OK
- *rc = CMSetArrayElementAt(res, 0, (CMPIValue*)(&val), CMPI_uint16);
- if (sptr->alarm || sptr->alarm_min || sptr->alarm_max) {
- val = 4; // Stressed
- *rc = CMSetArrayElementAt(res, 1, (CMPIValue*)(&val), CMPI_uint16);
- }
- }
- return res;
-}
-
-static CMPIArray * _get_StatusDescriptions(
- CMPIBroker const *_broker,
- CMPIStatus *rc,
- struct cim_fan const *sptr)
-{
- CMPIArray *res = CMNewArray(_broker, 2, CMPI_string, rc);
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 2, CMPI_string, rc)");
- _OSBASE_TRACE(2, ("--- _get_StatusDescriptions failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- *rc = CMSetArrayElementAt(res, 0, sptr->fault ?
- "Chip indicates, that fan is in fault state."
- " Possible causes are open diodes, unconnected fan etc."
- " Thus the measurement for this channel should not be trusted."
- : "Fan seems to be functioning correctly.", CMPI_chars);
- if (!rc->rc && (sptr->alarm || sptr->alarm_min || sptr->alarm_max)) {
- char buf[100];
- snprintf(buf, 100, "These alarm flags are set by the fan's chip:"
- " alarm=%s, min_alarm=%s, max_alarm=%s",
- sptr->alarm ? "1":"0",
- sptr->alarm_min ? "1":"0",
- sptr->alarm_max ? "1":"0");
- CMSetArrayElementAt(res, 1, buf, CMPI_chars);
- }
- }
- return res;
-}
-
-static CMPIArray * _get_OtherIdentifyingInfo(
- CMPIBroker const *_broker,
- CMPIStatus *rc,
- struct cim_fan const *sptr)
-{
- CMPIArray *res = CMNewArray(_broker, 2, CMPI_string, rc);
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 2, CMPI_string, rc)");
- _OSBASE_TRACE(2, ("--- _get_OtherIdentifyingInfo failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- CMSetArrayElementAt(res, 0, sptr->chip_name, CMPI_chars);
- CMSetArrayElementAt(res, 1, sptr->sys_path, CMPI_chars);
- }
- return res;
-}
-
-static CMPIArray * _get_IdentifyingDescriptions(
- CMPIBroker const *_broker,
- CMPIStatus *rc)
-{
- CMPIArray *res = CMNewArray(_broker, 2, CMPI_string, rc);
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 2, CMPI_string, rc)");
- _OSBASE_TRACE(2, ("--- _get_IdentifyingDescriptions failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- CMSetArrayElementAt(res, 0,
- "ChipName - name of fan's chip.", CMPI_chars);
- CMSetArrayElementAt(res, 1,
- "SysPath - system path of fan's chip.", CMPI_chars);
- }
- return res;
-}
-
-CMPIObjectPath * _makePath_FanCommon(
- char const *class_name,
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc)
-{
- UNUSED(ctx);
-
- CMPIObjectPath * op = NULL;
-
- _OSBASE_TRACE(2,("--- _makePath_FanCommon() called"));
-
- op = CMNewObjectPath(_broker, CMGetCharPtr(CMGetNameSpace(cop, rc)),
- class_name, rc);
- if (CMIsNullObject(op)) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "Create CMPIObjectPath failed");
- _OSBASE_TRACE(2, ("--- _makePath_FanCommon() failed : %s",
- CMGetCharPtr(rc->msg)));
- }else {
- CMAddKey(op, "CreationClassName", class_name, CMPI_chars);
- CMAddKey(op, "SystemCreationClassName", CSCreationClassName,
- CMPI_chars);
- CMAddKey(op, "SystemName", get_system_name(), CMPI_chars);
- CMAddKey(op, "DeviceID", sptr->device_id, CMPI_chars);
- }
- _OSBASE_TRACE(2, ("--- _makePath_FanCommon() exited"));
- return op;
-}
-
-CMPIInstance * _makeInst_FanCommon(
- char const *class_name,
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc,
- CMPIObjectPath **op)
-{
- UNUSED(ctx);
-
- CMPIInstance *ci = NULL;
- CMPIValue val;
- uint16_t uint16;
- char const *keys[] = {
- "CreationClassName",
- "SystemCreationClassName",
- "SystemName",
- "DeviceID",
- NULL
- };
- char buf[200];
-
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() called"));
-
- /* the sblim-cmpi-base package offers some tool methods to get common
- * system data
- */
- if( !get_system_name() ) {
- CMSetStatusWithChars( _broker, rc,
- CMPI_RC_ERR_FAILED, "no host name found" );
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() failed : %s",
- CMGetCharPtr(rc->msg)));
- return NULL;
- }
-
- if( !get_os_name() ) {
- CMSetStatusWithChars( _broker, rc,
- CMPI_RC_ERR_FAILED, "no OS name found" );
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() failed : %s",
- CMGetCharPtr(rc->msg)));
- return NULL;
- }
-
- *op = CMNewObjectPath(_broker, CMGetCharPtr(CMGetNameSpace(cop, rc)),
- class_name, rc);
- if (CMIsNullObject(*op)) {
- CMSetStatusWithChars(_broker, rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed.");
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() failed : %s",
- CMGetCharPtr(rc->msg)));
- return NULL;
- }
- ci = CMNewInstance(_broker, *op, rc);
- if (CMIsNullObject(ci)) {
- CMSetStatusWithChars(_broker, rc,
- CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed.");
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() failed : %s",
- CMGetCharPtr(rc->msg)));
- return NULL;
- }
- CMSetPropertyFilter(ci, properties, keys);
-
- //* keys ******************************************************************
- CMSetProperty(ci, "CreationClassName", class_name, CMPI_chars);
- CMSetProperty(ci, "SystemCreationClassName", CSCreationClassName,
- CMPI_chars);
- CMSetProperty(ci, "SystemName", get_system_name(), CMPI_chars);
- CMSetProperty(ci, "DeviceID", sptr->device_id, CMPI_chars);
-
- // other properties *******************************************************
- // ManagedElement
- CMSetProperty(ci, "Caption", "Computer's fan", CMPI_chars);
- CMSetProperty(ci, "Description", "Computer's fan.", CMPI_chars);
- snprintf(buf, 200, "Fan \"%s\" on chip \"%s\"", sptr->name,
- sptr->chip_name);
- CMSetProperty(ci, "ElementName", buf, CMPI_chars);
-
- // ManagedSystemElement
- CMSetProperty(ci, "Name", sptr->name, CMPI_chars);
- val.array = _get_OperationalStatus(_broker, rc, sptr);
- CMSetProperty(ci, "OperationalStatus", &val, CMPI_uint16A);
- val.array = _get_StatusDescriptions(_broker, rc, sptr);
- CMSetProperty(ci, "StatusDescriptions", &val, CMPI_stringA);
- uint16 = sptr->fault ? 20:5; // Major failure : OK
- CMSetProperty(ci, "HealthState", &uint16, CMPI_uint16);
- uint16 = sptr->fault ? 5:16; // Stopped : In Service
- CMSetProperty(ci, "OperatingStatus", &uint16, CMPI_uint16);
- uint16 = sptr->fault ? 3:1; // Error : OK
- CMSetProperty(ci, "PrimaryStatus", &uint16, CMPI_uint16);
-
- // EnabledLogicalElement
- val.array = _get_OtherIdentifyingInfo(_broker, rc, sptr);
- CMSetProperty(ci, "OtherIdentifyingInfo", &val, CMPI_stringA);
- val.array = _get_IdentifyingDescriptions(_broker, rc);
- CMSetProperty(ci, "IdentifyingDescriptions", &val, CMPI_stringA);
-
- _OSBASE_TRACE(2, ("--- _makeInst_FanCommon() exited"));
- return ci;
-}
-
diff --git a/src/fan/cmpiLinux_FanCommon.h b/src/fan/cmpiLinux_FanCommon.h
deleted file mode 100644
index 8134b3b..0000000
--- a/src/fan/cmpiLinux_FanCommon.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#ifndef CMPILINUX_FANCOMMON_H_
-#define CMPILINUX_FANCOMMON_H_
-
-#include <cmpi/cmpidt.h>
-#include "Linux_Fan.h"
-
-CMPIObjectPath * _makePath_FanCommon(
- char const *class_name,
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc);
-
-CMPIInstance * _makeInst_FanCommon(
- char const *class_name,
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc,
- CMPIObjectPath **op);
-
-#endif /* ----- CMPILINUX_FANCOMMON_H_ ----- */
diff --git a/src/fan/cmpiLinux_FanProvider.c b/src/fan/cmpiLinux_FanProvider.c
deleted file mode 100644
index 67a1a82..0000000
--- a/src/fan/cmpiLinux_FanProvider.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <strings.h>
-#include <errno.h>
-
-#include <cmpi/cmpidt.h>
-#include <cmpi/cmpift.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-#include "cmpiLinux_Fan.h"
-
-#define UNUSED(x) ((void) (x))
-static const CMPIBroker * _broker;
-
-#ifdef CMPI_VER_100
- #define Linux_FanProviderSetInstance Linux_FanProviderModifyInstance
-#endif
-
-// utilities ******************************************************************
-static bool data_2_uint64_t(CMPIData const * data, uint64_t *res) {
- if (data->state != CMPI_goodValue) return false;
- switch (data->type) {
- case CMPI_string:
- errno = 0;
- *res = strtoull(CMGetCharPtr(data->value.string), NULL, 10);
- if (errno) return false;
- break;
- case CMPI_sint32: *res = (uint64_t) data->value.sint32; break;
- case CMPI_uint32: *res = (uint64_t) data->value.uint32; break;
- case CMPI_sint64: *res = (uint64_t) data->value.sint64; break;
- default: return false;
- }
- return true;
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Instance Provider Interface */
-/* ---------------------------------------------------------------------------*/
-
-
-CMPIStatus Linux_FanProviderCleanup( CMPIInstanceMI * mi,
- const CMPIContext * ctx, CMPIBoolean terminate) {
- UNUSED(mi); UNUSED(ctx); UNUSED(terminate);
-
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() called",_ClassName));
- cleanup_linux_fan_module();
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanProviderEnumInstanceNames( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref) {
- UNUSED(mi);
-
- CMPIObjectPath * op = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct fanlist * lptr = NULL;
- struct fanlist * rm = NULL;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName));
-
- if (enum_all_fans(&lptr) != 0 ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not list get fan list." );
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- // iterate fan list
- for (rm = lptr; lptr && rc.rc == CMPI_RC_OK ; lptr = lptr->next) {
- // method call to create the CMPIInstance object
- op = _makePath_Fan(_broker, ctx, ref, lptr->f, &rc);
- if (op == NULL || rc.rc != CMPI_RC_OK) {
- if (rc.msg != NULL) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed"
- ": %s", _ClassName, CMGetCharPtr(rc.msg)));
- }
- CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
- "Transformation from internal structure to CIM"
- " ObjectPath failed.");
- if (rm) free_fanlist(rm);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed"
- ": %s", _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }else {
- CMReturnObjectPath(rslt, op);
- }
- }
- if (rm) free_fanlist(rm);
-
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanProviderEnumInstances( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char ** properties) {
- UNUSED(mi);
-
- CMPIInstance * ci = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct fanlist * lptr = NULL;
- struct fanlist * rm = NULL;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName));
-
- if (enum_all_fans(&lptr)) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not list fans.");
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- // iterate fan list
- for (rm=lptr; lptr && rc.rc == CMPI_RC_OK; lptr = lptr->next) {
- // method call to create the CMPIInstance object
- ci = _makeInst_Fan(_broker, ctx, ref, properties, lptr->f, &rc);
- if (ci == NULL || rc.rc != CMPI_RC_OK ) {
- if (rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
- " %s",_ClassName,CMGetCharPtr(rc.msg)));
- }
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Transformation from internal"
- " structure to CIM Instance failed.");
- if (rm) free_fanlist(rm);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
- " %s", _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }else {
- CMReturnInstance(rslt, ci);
- }
- }
- if (rm) free_fanlist(rm);
-
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanProviderGetInstance( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char **properties) {
- UNUSED(mi);
-
- CMPIInstance * ci = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct cim_fan * sptr = NULL;
- CMPIData data;
- CMPIArray * other_identifying_info = NULL;
- CMPIString * sys_path = NULL;
- CMPIString * fan_name = NULL;
- CMPIString * device_id = NULL;
- cim_fan_error_t cmdrc;
-
- _OSBASE_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName));
-
- _check_system_key_value_pairs(_broker, cop, "SystemCreationClassName",
- "SystemName", &rc);
- if (rc.rc != CMPI_RC_OK) {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- data = CMGetKey(cop, "OtherIdentifyingInfo", &rc);
- if ( !rc.rc
- && data.type == CMPI_stringA
- && (other_identifying_info = data.value.array)
- && !rc.rc
- && (CMGetArrayCount(other_identifying_info, &rc) > 1)
- && !rc.rc)
- {
- data = CMGetArrayElementAt(other_identifying_info, 0, &rc);
- if (!rc.rc) sys_path = data.value.string;
- data = CMGetArrayElementAt(other_identifying_info, 1, &rc);
- if (!rc.rc) fan_name = data.value.string;
- }
- device_id = CMGetKey(cop, "DeviceID", &rc).value.string;
- if ((sys_path == NULL || fan_name == NULL) && (device_id == NULL)) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not get fan ID." );
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- if (sys_path && fan_name) {
- cmdrc = get_fan_data(CMGetCharPtr(sys_path), CMGetCharPtr(fan_name),
- &sptr);
- }
- if ((cmdrc || !sptr) && device_id) {
- cmdrc = get_fan_data_by_id(CMGetCharPtr(device_id), &sptr);
- }
- if (cmdrc || !sptr) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_FOUND, cim_fan_strerror(cmdrc));
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() exited : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- ci = _makeInst_Fan(_broker, ctx, cop, properties, sptr, &rc);
- if (sptr) free_fan(sptr);
-
- if (ci == NULL) {
- if (rc.msg != NULL) {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }else {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed", _ClassName));
- }
- return rc;
- }
-
- CMReturnInstance(rslt, ci);
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanProviderCreateInstance( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci) {
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop); UNUSED(ci);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() called", _ClassName));
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
- _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanProviderSetInstance( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci,
- const char ** properties) {
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(properties);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- CMPIData data;
- char const * device_id = NULL;
- struct cim_fan * sptr;
- cim_fan_prop_value_t cfpv;
- cim_fan_error_t cmdrc;
- char const * tmp = NULL;
- char buf[200];
-
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() called", _ClassName));
-
- _check_system_key_value_pairs(_broker, cop, "SystemCreationClassName",
- "SystemName", &rc);
- if (rc.rc != CMPI_RC_OK) {
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- data = CMGetKey(cop, "DeviceID", &rc);
- if (data.value.string == NULL) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not get fan ID." );
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }
- device_id = CMGetCharPtr(data.value.string);
- if (device_id) {
- cmdrc = get_fan_data_by_id(device_id, &sptr);
- }
- if (cmdrc || !sptr) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_FOUND, cim_fan_strerror(cmdrc));
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() exited : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- data = CMGetProperty(ci, "MinSpeed", &rc);
- if (!rc.rc && data.value.uint64 != (uint64_t) sptr->min_speed) {
- tmp = "MinSpeed";
- cfpv.min_speed = data.value.uint64;
- cmdrc = set_fan_prop_by_id(device_id, CIM_FAN_MIN_SPEED, &cfpv);
- }
- data = CMGetProperty(ci , "MaxSpeed", &rc);
- if (!cmdrc && !rc.rc && data.value.uint64 != (uint64_t) sptr->max_speed) {
- tmp = "MaxSpeed";
- cfpv.max_speed = data.value.uint64;
- set_fan_prop_by_id(device_id, CIM_FAN_MAX_SPEED, &cfpv);
- }
- data = CMGetProperty(ci, "Divisor", &rc);
- if (!cmdrc && !rc.rc && data.value.uint32 != sptr->divisor) {
- tmp = "Divisor";
- cfpv.divisor = data.value.uint32;
- set_fan_prop_by_id(device_id, CIM_FAN_DIV, &cfpv);
- }
- data = CMGetProperty(ci, "Pulses", &rc);
- if (!cmdrc && !rc.rc && data.value.uint32 != sptr->pulses) {
- tmp = "Pulses";
- cfpv.pulses = data.value.uint32;
- set_fan_prop_by_id(device_id, CIM_FAN_PULSES, &cfpv);
- }
- data = CMGetProperty(ci, "Beep", &rc);
- if (!cmdrc && !rc.rc && data.value.boolean != sptr->beep) {
- tmp = "Beep";
- cfpv.beep = data.value.uint32;
- set_fan_prop_by_id(device_id, CIM_FAN_BEEP, &cfpv);
- }
-
- if (cmdrc) {
- if (tmp && cmdrc == CIM_FAN_SEN_NO_ENTRY) {
- snprintf(buf, 200,
- "System interface for fan(name=\"%s\", chip=\"%s\") does not"
- " provide a way to set \"%s\".", sptr->name, sptr->chip_name,
- tmp);
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, buf);
- }else {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, cim_fan_strerror(cmdrc))
- }
- _OSBASE_TRACE(2, ("--- %s CMPI SetInstance() exited : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }else {
- rc.rc = CMPI_RC_OK;
- rc.msg = NULL;
- }
-
- return rc;
-}
-
-CMPIStatus Linux_FanProviderDeleteInstance( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop) {
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() called",_ClassName));
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanProviderExecQuery( CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char * lang,
- const char * query) {
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(ref); UNUSED(lang);
- UNUSED(query);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() exited",_ClassName));
- return rc;
-}
-
-
-/* ---------------------------------------------------------------------------*/
-/* Method Provider Interface */
-/* ---------------------------------------------------------------------------*/
-
-
-CMPIStatus Linux_FanProviderMethodCleanup( CMPIMethodMI * mi,
- const CMPIContext * ctx, CMPIBoolean terminate) {
- UNUSED(mi); UNUSED(ctx), UNUSED(terminate);
- _OSBASE_TRACE(1,("--- %s CMPI MethodCleanup() called",_ClassName));
- _OSBASE_TRACE(1,("--- %s CMPI MethodCleanup() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanProviderInvokeMethod( CMPIMethodMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char * methodName,
- const CMPIArgs * in,
- CMPIArgs * out) {
- UNUSED(mi); UNUSED(ctx); UNUSED(in); UNUSED(out);
-
- struct cim_fan * sptr = NULL;
- CMPIString * device_id = NULL;
- CMPIValue valrc;
- CMPIData data;
- CMPIString * class = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- uint64_t desired_speed;
-
- _OSBASE_TRACE(1, ("--- %s CMPI InvokeMethod() called", _ClassName));
-
- class = CMGetClassName(ref, &rc);
-
- if ( strcasecmp(CMGetCharPtr(class), _ClassName) == 0
- && strcasecmp(methodName, "setspeed") == 0 ) {
- if (!(device_id = CMGetKey(ref, "DeviceID", &rc).value.string)) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not get fan ID." );
- _OSBASE_TRACE(1, ("--- %s CMPI InvokeMethod() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }else if (get_fan_data_by_id(CMGetCharPtr(device_id), &sptr) || !sptr) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_FOUND, "No such Fan found.");
- _OSBASE_TRACE(1, ("--- %s CMPI InvokeMethod() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }else {
- char errbuf[100];
- char const * errdscr;
- data = CMGetArg(in, "DesiredSpeed", &rc);
- if (data.state != CMPI_goodValue) {
- switch (data.state) {
- case CMPI_nullValue: errdscr = "null value"; break;
- case CMPI_badValue: errdscr = "bad value"; break;
- case CMPI_notFound: errdscr = "not found"; break;
- default: errdscr = "unknown error";
- }
- snprintf(errbuf, 100, "Argument error: DesiredSpeed - %s", errdscr);
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, errbuf);
- }else if (!data_2_uint64_t(&data, &desired_speed)) {
- CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
- "Argument error: DesiredSpeed must be of type uint64");
- }else {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
- }
- }
- }else {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_METHOD_NOT_AVAILABLE, methodName);
- }
-
- _OSBASE_TRACE(1, ("--- %s CMPI InvokeMethod() exited", _ClassName));
- return rc;
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Provider Factory */
-/* ---------------------------------------------------------------------------*/
-
-CMInstanceMIStub( Linux_FanProvider,
- Linux_FanProvider,
- _broker,
- init_linux_fan_module());
-
-CMMethodMIStub( Linux_FanProvider,
- Linux_FanProvider,
- _broker,
- init_linux_fan_module());
-
-/* ---------------------------------------------------------------------------*/
-/* end of cmpiLinux_FanProvider */
-/* ---------------------------------------------------------------------------*/
-
diff --git a/src/fan/cmpiLinux_FanSensor.c b/src/fan/cmpiLinux_FanSensor.c
deleted file mode 100644
index bbe8b22..0000000
--- a/src/fan/cmpiLinux_FanSensor.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-#include "cmpiLinux_FanSensor.h"
-
-static CMPIArray * _get_PossibleStates(
- CMPIBroker const *_broker,
- CMPIStatus *rc,
- struct cim_fan const *sptr)
-{
- int index = 0;
-
- CMPIArray *res = CMNewArray(_broker, 5, CMPI_string, rc);
- if (!res) {
- CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
- "CMNewArray(_broker, 5, CMPI_string, rc)");
- _OSBASE_TRACE(2, ("--- _get_AccessibleFeatures failed: %s",
- CMGetCharPtr(rc->msg)));
- }else {
- if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
- CMSetArrayElementAt(res, index++, "Below Minimum", CMPI_chars);
- CMSetArrayElementAt(res, index++, "At Minumum", CMPI_chars);
- }
- CMSetArrayElementAt(res, index++, "Normal", CMPI_chars);
- if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
- CMSetArrayElementAt(res, index++, "At Maximum", CMPI_chars);
- CMSetArrayElementAt(res, index++, "Above Maximum", CMPI_chars);
- }
- }
- return res;
-}
-
-static char const * _get_CurrentState(
- struct cim_fan const *sptr)
-{
- if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
- if (sptr->speed < sptr->min_speed) return "Below Minimum";
- if (sptr->speed == sptr->min_speed) return "At Minimum";
- }
- if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
- if (sptr->speed > sptr->max_speed) return "Above Maximum";
- if (sptr->speed == sptr->max_speed) return "At Maximum";
- }
- return "Normal";
-}
-
-
-CMPIObjectPath * _makePath_FanSensor(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc)
-{
- return _makePath_FanCommon(_ClassName, _broker, ctx, cop, sptr, rc);
-}
-
-CMPIInstance * _makeInst_FanSensor(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc)
-{
- CMPIObjectPath *op;
- CMPIInstance *ci;
- CMPIValue val;
-
- char buf[200];
-
- _OSBASE_TRACE(2, ("--- _makeInst_FanSensor() called"));
- if (!(ci = _makeInst_FanCommon(_ClassName, _broker, ctx, cop, properties,
- sptr, rc, &op))) {
- return NULL;
- }
-
- // ManagedElement
- CMSetProperty(ci, "Caption", "Fan's tachometer", CMPI_chars);
- CMSetProperty(ci, "Description", "Associated sensor of fan."
- " Giving information about its speed.", CMPI_chars);
- snprintf(buf, 200, "Tachometer of fan \"%s\" on chip \"%s\"", sptr->name,
- sptr->chip_name);
- CMSetProperty(ci, "ElementName", buf, CMPI_chars);
-
- // Sensor
- val.uint16 = 5; // Tachometer
- CMSetProperty(ci, "SensorType", &val, CMPI_uint16);
- val.array = _get_PossibleStates(_broker, rc, sptr);
- CMSetProperty(ci, "PossibleStates", &val, CMPI_stringA);
- CMSetProperty(ci, "CurrentState", _get_CurrentState(sptr), CMPI_chars);
-
- // NumericSensor
- val.uint16 = 38; // Revolutions
- CMSetProperty(ci, "BaseUnits", &val, CMPI_uint16);
- val.sint32 = 0;
- CMSetProperty(ci, "UnitModifier", &val, CMPI_sint32);
- val.uint16 = 4; // Per Minute
- CMSetProperty(ci, "RateUnits", &val, CMPI_uint16);
- val.sint32 = (int32_t) sptr->speed;
- CMSetProperty(ci, "CurrentReading", &val, CMPI_sint32);
- if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
- val.sint32 = (int32_t) sptr->min_speed;
- CMSetProperty(ci, "NormalMax", &val, CMPI_sint32);
- }
- if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
- val.sint32 = (int32_t) sptr->min_speed;
- CMSetProperty(ci, "NormalMin", &val, CMPI_sint32);
- }
- val.sint32 = 0;
- CMSetProperty(ci, "MinReadable", &val, CMPI_sint32);
- val.boolean = true;
- CMSetProperty(ci, "IsLinear", &val, CMPI_boolean);
-
- // Linux_FanSensor
-
- _OSBASE_TRACE(2, ("--- _makeInst_FanSensor() exited"));
- return ci;
-}
-
diff --git a/src/fan/cmpiLinux_FanSensor.h b/src/fan/cmpiLinux_FanSensor.h
deleted file mode 100644
index 3d224b5..0000000
--- a/src/fan/cmpiLinux_FanSensor.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#ifndef CMPILINUX_FANSENSOR_H_
-#define CMPILINUX_FANSENSOR_H_
-
-#include "cmpiLinux_FanCommon.h"
-
-static char const *_ClassName = "Linux_FanSensor";
-
-CMPIObjectPath * _makePath_FanSensor(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- struct cim_fan *sptr,
- CMPIStatus *rc);
-
-CMPIInstance * _makeInst_FanSensor(
- CMPIBroker const *_broker,
- CMPIContext const *ctx,
- CMPIObjectPath const *cop,
- char const **properties,
- struct cim_fan *sptr,
- CMPIStatus *rc);
-
-#endif /* ----- CMPILINUX_FANSENSOR_H_ ----- */
-
diff --git a/src/fan/cmpiLinux_FanSensorProvider.c b/src/fan/cmpiLinux_FanSensorProvider.c
deleted file mode 100644
index e3e1092..0000000
--- a/src/fan/cmpiLinux_FanSensorProvider.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/* This file is part of cmpiLinux_FanProvider.
- *
- * cmpiLinux_FanProvider is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * cmpiLinux_FanProvider 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with cmpiLinux_FanProvider. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <strings.h>
-
-#include <cmpi/cmpidt.h>
-#include <cmpi/cmpift.h>
-#include <cmpi/cmpimacs.h>
-#include <sblim/OSBase_Common.h>
-#include <sblim/cmpiOSBase_Common.h>
-
-#include "cmpiLinux_FanSensor.h"
-
-#define UNUSED(x) ((void) (x))
-static const CMPIBroker * _broker;
-
-#ifdef CMPI_VER_100
- #define Linux_FanSensorProviderSetInstance \
- Linux_FanSensorProviderModifyInstance
-#endif
-
-/* ---------------------------------------------------------------------------*/
-/* Instance Provider Interface */
-/* ---------------------------------------------------------------------------*/
-
-CMPIStatus Linux_FanSensorProviderCleanup(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- CMPIBoolean terminate)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(terminate);
-
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() called",_ClassName));
- cleanup_linux_fan_module();
- _OSBASE_TRACE(1,("--- %s CMPI Cleanup() exited",_ClassName));
- CMReturn(CMPI_RC_OK);
-}
-
-CMPIStatus Linux_FanSensorProviderEnumInstanceNames(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref)
-{
- UNUSED(mi);
-
- CMPIObjectPath * op = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct fanlist * lptr = NULL;
- struct fanlist * rm = NULL;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName));
-
- if (enum_all_fans(&lptr) != 0 ) {
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not list get fan list." );
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- // iterate fan list
- for (rm = lptr; lptr && rc.rc == CMPI_RC_OK ; lptr = lptr->next) {
- // method call to create the CMPIInstance object
- op = _makePath_FanSensor(_broker, ctx, ref, lptr->f, &rc);
- if (op == NULL || rc.rc != CMPI_RC_OK) {
- if (rc.msg != NULL) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed"
- ": %s", _ClassName, CMGetCharPtr(rc.msg)));
- }
- CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
- "Transformation from internal structure to CIM"
- " ObjectPath failed.");
- if (rm) free_fanlist(rm);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() failed"
- ": %s", _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }else {
- CMReturnObjectPath(rslt, op);
- }
- }
- if (rm) free_fanlist(rm);
-
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstanceNames() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderEnumInstances(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char ** properties)
-{
- UNUSED(mi);
-
- CMPIInstance * ci = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct fanlist * lptr = NULL;
- struct fanlist * rm = NULL;
-
- _OSBASE_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName));
-
- if (enum_all_fans(&lptr)) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not list fans.");
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- // iterate fan list
- for (rm=lptr; lptr && rc.rc == CMPI_RC_OK; lptr = lptr->next) {
- // method call to create the CMPIInstance object
- ci = _makeInst_FanSensor(_broker, ctx, ref, properties, lptr->f, &rc);
- if (ci == NULL || rc.rc != CMPI_RC_OK ) {
- if (rc.msg != NULL ) {
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
- " %s",_ClassName,CMGetCharPtr(rc.msg)));
- }
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_FAILED, "Transformation from internal"
- " structure to CIM Instance failed.");
- if (rm) free_fanlist(rm);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
- " %s", _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }else {
- CMReturnInstance(rslt, ci);
- }
- }
- if (rm) free_fanlist(rm);
-
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderGetInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const char **properties)
-{
- UNUSED(mi);
-
- CMPIInstance * ci = NULL;
- CMPIStatus rc = {CMPI_RC_OK, NULL};
- struct cim_fan * sptr = NULL;
- CMPIData data;
- CMPIArray * other_identifying_info = NULL;
- CMPIString * sys_path = NULL;
- CMPIString * fan_name = NULL;
- CMPIString * device_id = NULL;
- cim_fan_error_t cmdrc;
-
- _OSBASE_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName));
-
- data = CMGetKey(cop, "OtherIdentifyingInfo", &rc);
- if ( !rc.rc
- && data.type == CMPI_stringA
- && (other_identifying_info = data.value.array)
- && !rc.rc
- && (CMGetArrayCount(other_identifying_info, &rc) > 1)
- && !rc.rc)
- {
- data = CMGetArrayElementAt(other_identifying_info, 0, &rc);
- if (!rc.rc) sys_path = data.value.string;
- data = CMGetArrayElementAt(other_identifying_info, 1, &rc);
- if (!rc.rc) fan_name = data.value.string;
- }
- device_id = CMGetKey(cop, "DeviceID", &rc).value.string;
- if ((sys_path == NULL || fan_name == NULL) && (device_id == NULL)) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_FAILED, "Could not get fan ID." );
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- if (sys_path && fan_name) {
- cmdrc = get_fan_data(CMGetCharPtr(sys_path), CMGetCharPtr(fan_name),
- &sptr);
- }
- if ((cmdrc || !sptr) && device_id) {
- cmdrc = get_fan_data_by_id(CMGetCharPtr(device_id), &sptr);
- }
- if (cmdrc || !sptr) {
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_FOUND, cim_fan_strerror(cmdrc));
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() exited : %s",
- _ClassName,CMGetCharPtr(rc.msg)));
- return rc;
- }
-
- ci = _makeInst_FanSensor(_broker, ctx, cop, properties, sptr, &rc);
- if (sptr) free_fan(sptr);
-
- if (ci == NULL) {
- if (rc.msg != NULL) {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed : %s",
- _ClassName, CMGetCharPtr(rc.msg)));
- }else {
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() failed", _ClassName));
- }
- return rc;
- }
-
- CMReturnInstance(rslt, ci);
- CMReturnDone(rslt);
- _OSBASE_TRACE(1, ("--- %s CMPI GetInstance() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderCreateInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop); UNUSED(ci);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() called", _ClassName));
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
- _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderSetInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop,
- const CMPIInstance * ci,
- const char ** properties)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop);
- UNUSED(ci); UNUSED(properties);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() called", _ClassName));
- CMSetStatusWithChars(_broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
- _OSBASE_TRACE(1, ("--- %s CMPI SetInstance() exited", _ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderDeleteInstance(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * cop)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop);
-
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() called",_ClassName));
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
- _OSBASE_TRACE(1,("--- %s CMPI DeleteInstance() exited",_ClassName));
- return rc;
-}
-
-CMPIStatus Linux_FanSensorProviderExecQuery(
- CMPIInstanceMI * mi,
- const CMPIContext * ctx,
- const CMPIResult * rslt,
- const CMPIObjectPath * ref,
- const char * lang,
- const char * query)
-{
- UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(ref); UNUSED(lang);
- UNUSED(query);
- CMPIStatus rc = {CMPI_RC_OK, NULL};
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() called",_ClassName));
-
- CMSetStatusWithChars( _broker, &rc,
- CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" );
-
- _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() exited",_ClassName));
- return rc;
-}
-
-
-/* ---------------------------------------------------------------------------*/
-/* Provider Factory */
-/* ---------------------------------------------------------------------------*/
-
-CMInstanceMIStub( Linux_FanSensorProvider,
- Linux_FanSensorProvider,
- _broker,
- init_linux_fan_module());
-
-/* ---------------------------------------------------------------------------*/
-/* end of cmpiLinux_FanSensorProvider */
-/* ---------------------------------------------------------------------------*/
-
diff --git a/src/fan/Linux_Fan.c b/src/fan/fan.c
index 9826ba2..e8e9559 100644
--- a/src/fan/Linux_Fan.c
+++ b/src/fan/fan.c
@@ -23,7 +23,7 @@
#include <sensors/sensors.h>
#include <sensors/error.h>
-#include "Linux_Fan.h"
+#include "fan.h"
#include "globals.h"
#define MAX_CHIP_NAME_LENGTH 200
@@ -172,7 +172,6 @@ static unsigned int _load_accessible_features(
unsigned int res = 0;
unsigned int i = 1;
int sf_type;
-
while(i <= CIM_FAN_AF_FEATURE_MAX) {
switch (i) {
case CIM_FAN_AF_MIN_SPEED:
@@ -531,3 +530,15 @@ void cleanup_linux_fan_module() {
}
}
+char const *fan_get_current_state(struct cim_fan const *sptr)
+{
+ if (sptr->accessible_features & CIM_FAN_AF_MIN_SPEED) {
+ if (sptr->speed < sptr->min_speed) return "Below Minimum";
+ if (sptr->speed == sptr->min_speed) return "At Minimum";
+ }
+ if (sptr->accessible_features & CIM_FAN_AF_MAX_SPEED) {
+ if (sptr->speed > sptr->max_speed) return "Above Maximum";
+ if (sptr->speed == sptr->max_speed) return "At Maximum";
+ }
+ return "Normal";
+}
diff --git a/src/fan/Linux_Fan.h b/src/fan/fan.h
index 6eacd49..f376ea6 100644
--- a/src/fan/Linux_Fan.h
+++ b/src/fan/fan.h
@@ -194,5 +194,7 @@ void free_fan(struct cim_fan *sptr);
cim_fan_error_t init_linux_fan_module();
void cleanup_linux_fan_module();
+char const *fan_get_current_state(struct cim_fan const *sptr);
+
#endif /* ----- LINUX_FAN_H_ ----- */
diff --git a/src/fan/mof/Linux_Fan.mof b/src/fan/mof/Linux_Fan.mof
deleted file mode 100644
index 02766e6..0000000
--- a/src/fan/mof/Linux_Fan.mof
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-// Linux_Fan.mof
-//
-
-#pragma locale ("en_US")
-//#pragma namespace ("root/cimv2")
-
-// ===================================================================
-// Linux_Fan
-// ===================================================================
-
-[ Provider("cmpi:cmpiLinux_FanProvider") ]
-class Linux_Fan : CIM_Fan {
-
- [ Key, Override("DeviceID"),
- Description("Uniquely identifies fan. It is a composition of
- SysPath and Name glued with slash ('/').") ]
- string DeviceId;
-
- [ Override("Name"),
- Description("Name of fan provided by system.") ]
- string Name;
-
- [ Description("Array of fan features, that are exposed through system
- interface. In other words: those that are readible/writable."),
- ValueMap { "1", "2", "3", "4", "5", "6", "7", "8" },
- Values { "MinSpeed", "MaxSpeed", "Divisor", "Pulses", "Beep",
- "Alarm", "MinAlarm", "MaxAlarm" }
- ]
- uint16 AccessibleFeatures[];
-
- [ Description("Minimum speed value."),
- Write,
- Units("Revolutions per Minute") ]
- uint64 MinSpeed;
-
- [ Description("Maximum speed value."),
- Write,
- Units("Revolutions per Minute") ]
- uint64 MaxSpeed;
-
- [ Description("Fan divisisor. It affects Minimum and Maximum speed value
- and accuracy of readings.
- The drivers account for the 'fan divisor' in their calculation
- of RPM. So changing the fan divisor will NOT change the
- nominal RPM reading, it will only affect the minimum and maximum
- readings and the accuracy of the readings.
- The actual formula is RPM = (60 * 22500) / (count * divisor)"),
- Write ]
- uint32 Divisor;
-
- [ Description("Number of tachometer pulses per fan revolution.
- Integer value, typically between 1 and 4.
- This value is a characteristic of the fan connected to the
- device's input, so it has to be set in accordance with the fan
- model."),
- Write ]
- uint32 Pulses;
-
- [ Description("This indicates, whether a PC's speaker should beep
- when an alarm occurs."),
- Write ]
- boolean Beep;
-
- [ Description("ALARM warning indicating, that current speed is out of
- range. This information is supplied by fan's chip driver.") ]
- boolean Alarm;
-
- [ Description("ALARM warning indicating, that current speed is below
- the critical level. This information is supplied by fan's chip driver.")
- ]
- boolean MinAlarm;
-
- [ Description("ALARM warning indicating, that current speed is above
- the critical level. This information is supplied by fan's chip driver.")
- ]
- boolean MaxAlarm;
-
-};
-
-// ===================================================================
-// Linux_FanSensor
-// ===================================================================
-[ Provider("cmpi:cmpiLinux_FanSensorProvider") ]
-class Linux_FanSensor : CIM_NumericSensor {
-
- [ Key, Override("DeviceID"),
- Description("Uniquely identifies fan. It is a composition of
- SysPath and Name glued with slash ('/').") ]
- string DeviceId;
-
- [ Key, Override("Name"),
- Description("Name of fan provided by system.") ]
- string Name;
-
-};
-
-
-// ===================================================================
-// Associations
-// ===================================================================
-[ Association,
- Provider("cmpi:cmpiLinux_FanAssociatedSensorProvider") ]
-class Linux_FanAssociatedSensor : CIM_AssociatedSensor {
-
- [ Override("Antecedent") ]
- Linux_FanSensor REF Antecedent;
-
- [ Override("Dependent") ]
- Linux_Fan REF Dependent;
-
-};
diff --git a/src/fan/mof/Linux_Fan.reg b/src/fan/mof/Linux_Fan.reg
deleted file mode 100644
index 9d21edb..0000000
--- a/src/fan/mof/Linux_Fan.reg
+++ /dev/null
@@ -1,18 +0,0 @@
-[Linux_Fan]
- provider: Linux_FanProvider
- location: cmpiLinux_FanProvider
- type: instance method
- namespace: root/cimv2
-
-[Linux_FanSensor]
- provider: Linux_FanSensorProvider
- location: cmpiLinux_FanSensorProvider
- type: instance
- namespace: root/cimv2
-
-[Linux_FanAssociatedSensor]
- provider: Linux_FanAssociatedSensorProvider
- location: cmpiLinux_FanAssociatedSensorProvider
- type: instance association
- namespace: root/cimv2
-