diff options
author | Radek Novacek <rnovacek@redhat.com> | 2012-07-23 13:41:47 +0200 |
---|---|---|
committer | Radek Novacek <rnovacek@redhat.com> | 2012-07-23 14:35:13 +0200 |
commit | ce3f2520c5046c7b7703742dd5c7481b5f98c52e (patch) | |
tree | 4e6ac6dbcb4b06f6d0ad02630a086ab263c1071b /src/power/Linux_HostedServiceProvider.c | |
parent | 3f906be3f651313c1b8709732ea0bdebba296784 (diff) | |
download | openlmi-providers-ce3f2520c5046c7b7703742dd5c7481b5f98c52e.tar.gz openlmi-providers-ce3f2520c5046c7b7703742dd5c7481b5f98c52e.tar.xz openlmi-providers-ce3f2520c5046c7b7703742dd5c7481b5f98c52e.zip |
Restructure Power provider
* get rid of src/ subdirectory in power/
* cleanup CMake
* use konkretcmpi_generate macro
Diffstat (limited to 'src/power/Linux_HostedServiceProvider.c')
-rw-r--r-- | src/power/Linux_HostedServiceProvider.c | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/src/power/Linux_HostedServiceProvider.c b/src/power/Linux_HostedServiceProvider.c new file mode 100644 index 0000000..4f6c7ac --- /dev/null +++ b/src/power/Linux_HostedServiceProvider.c @@ -0,0 +1,258 @@ + +#include <cmpimacs.h> +#include <konkret/konkret.h> +#include "Linux_HostedService.h" +#include "Linux_ComputerSystem.h" + +#include "globals.h" +#include "trace.h" + +static const CMPIBroker* _cb; + +static void Linux_HostedServiceInitialize() +{ +} + +static CMPIStatus Linux_HostedServiceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus Linux_HostedServiceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus Linux_HostedServiceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *ns = KNameSpace(cop); + + Linux_HostedService w; + Linux_HostedService_Init(&w, _cb, ns); + + /* + * TODO: Find instance dynamically based on Name property + */ + /* + CMPIObjectPath *computerSystemOP = CMNewObjectPath(_cb, ns, "CIM_ComputerSystem", &rc); + CMPIEnumeration *en = CBEnumInstanceNames(_cb, cc, computerSystemOP, &rc); + while (CMHasNext(en, &rc)) { + data = CMGetNext(en, &rc); + if (data.type != CMPI_ref) { + TRACE(1, "Not a reference\n"); + continue; + } + fprintf(stderr, "object: %s\n", CMGetCharsPtr(CMObjectPathToString(data.value.ref, &rc), &rc)); + + name = data.value.ref->ft->getKey(data.value.ref, "Name", &rc); + if (name.type != CMPI_string) { + fprintf(stderr, "Non-string name %d\n", name.type); + continue; + } + if (rc.rc != CMPI_RC_OK) return rc; + + fprintf(stderr, "Name: %s\n", CMGetCharsPtr(name.value.string, &rc)); + if (strcmp(CMGetCharsPtr(name.value.string, &rc), get_system_name()) == 0) { + TRACE(1, "Found\n"); + CIM_ComputerSystemRef_InitFromObjectPath(&computerSystemRef, _cb, data.value.ref); + break; + } + } + */ + + Linux_ComputerSystemRef computerSystemRef; + Linux_ComputerSystemRef_Init(&computerSystemRef, _cb, ns); + Linux_ComputerSystemRef_Set_Name(&computerSystemRef, get_system_name()); + Linux_ComputerSystemRef_Set_CreationClassName(&computerSystemRef, "Linux_ComputerSystem"); + Linux_HostedService_Set_Antecedent(&w, &computerSystemRef); + + Linux_PowerManagementServiceRef powerManagementServiceRef; + Linux_PowerManagementServiceRef_Init(&powerManagementServiceRef, _cb, ns); + Linux_PowerManagementServiceRef_Set_Name(&powerManagementServiceRef, get_system_name()); + Linux_PowerManagementServiceRef_Set_SystemName(&powerManagementServiceRef, get_system_name()); + Linux_PowerManagementServiceRef_Set_CreationClassName(&powerManagementServiceRef, "Linux_PowerManagementService"); + Linux_PowerManagementServiceRef_Set_SystemCreationClassName(&powerManagementServiceRef, "Linux_ComputerSystem"); + Linux_HostedService_Set_Dependent(&w, &powerManagementServiceRef); + + KReturnInstance(cr, w); + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus Linux_HostedServiceGetInstance( + 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_HostedServiceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus Linux_HostedServiceModifyInstance( + 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_HostedServiceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus Linux_HostedServiceExecQuery( + 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_HostedServiceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus Linux_HostedServiceAssociators( + 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_HostedService_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus Linux_HostedServiceAssociatorNames( + 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_HostedService_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus Linux_HostedServiceReferences( + 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_HostedService_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus Linux_HostedServiceReferenceNames( + 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_HostedService_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + Linux_HostedService, + Linux_HostedService, + _cb, + Linux_HostedServiceInitialize()) + +CMAssociationMIStub( + Linux_HostedService, + Linux_HostedService, + _cb, + Linux_HostedServiceInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "Linux_HostedService", + "Linux_HostedService", + "instance association") |