Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
systemsmanagement:wbem
openhpi-cim
0001-Adapt-to-CMPI-2.00.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Adapt-to-CMPI-2.00.patch of Package openhpi-cim
From 1ce6164270f70d0f689743f0b7e2caf776ad0faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de> Date: Tue, 18 Oct 2011 16:22:16 +0200 Subject: [PATCH 1/4] Adapt to CMPI 2.00 --- src/Hpi.c | 248 +++++++++++++++++++++++++++--------------------------- 1 file changed, 125 insertions(+), 123 deletions(-) diff --git a/src/Hpi.c b/src/Hpi.c index 322d45e..46f8e72 100644 --- a/src/Hpi.c +++ b/src/Hpi.c @@ -19,15 +19,16 @@ /* Name of this provider */ static char _CLASSNAME[] = "HPI_LogicalDevice"; -#define CMPI_VERSION 90 - +#define CMPI_VERSION 200 + +#include <string.h> + /* Include the required CMPI macros, data types, and API function headers */ #include "cmpidt.h" #include "cmpift.h" #include "cmpimacs.h" #include <SaHpi.h> #include <oh_utils.h> -#include <hpi_utils.h> /* NULL terminated list of key property names for this class */ static char * _KEYNAMES[] = {"RID", NULL}; @@ -53,7 +54,7 @@ static struct hpi_handle { /* Handle to the CIM broker. This is initialized by the CIMOM when the provider is loaded */ -static CMPIBroker * _BROKER; +static const CMPIBroker * _BROKER; /* --------------------------------------------------------------------------- @@ -62,10 +63,10 @@ static CMPIBroker * _BROKER; /* EnumInstanceNames() - return a list of all the instances names (i.e. return their object paths only) */ static CMPIStatus EnumInstanceNames( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference) /* [in] Contains the CIM namespace and classname */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference) /* [in] Contains the CIM namespace and classname */ { /* HPI vars */ SaErrorT error; @@ -101,9 +102,9 @@ static CMPIStatus EnumInstanceNames( rdr_id = SAHPI_FIRST_ENTRY; do { memset(&rdr, 0, sizeof(rdr)); - error = saHpiRdrGet(hpi_hnd.sid, - entry.ResourceId, - rdr_id, + error = saHpiRdrGet(hpi_hnd.sid, + entry.ResourceId, + rdr_id, &rdr_id, &rdr); if (error != SA_OK) { @@ -116,14 +117,14 @@ static CMPIStatus EnumInstanceNames( rval = management_instrument_id(&rdr); - if (rval == -1) + if (rval == -1) CMReturnWithChars(_BROKER, CMPI_RC_ERR_FAILED, "Invalid Rdr Type"); - + memset(buf, 0, sizeof(buf)); - sprintf(buf, "{Domain ID=%d}{Resource ID=%d}{Management Instrument Type=%s}{Management Instrument ID=%d}", + sprintf(buf, "{Domain ID=%d}{Resource ID=%d}{Management Instrument Type=%s}{Management Instrument ID=%d}", domain_info.DomainId, entry.ResourceId, - oh_lookup_rdrtype(rdr.RdrType), + oh_lookup_rdrtype(rdr.RdrType), (SaHpiInstrumentIdT)rval); /* Create a new template object path for returning results */ @@ -144,10 +145,9 @@ static CMPIStatus EnumInstanceNames( /* Add the object path for this resource to the list of results */ CMReturnObjectPath(results, objectpath); - + } while (rdr_id != SAHPI_LAST_ENTRY); - } while (entry_id != SAHPI_LAST_ENTRY); /* Finished EnumInstanceNames */ @@ -159,13 +159,13 @@ static CMPIStatus EnumInstanceNames( /* EnumInstances() - return a list of all the instances (i.e. return all their instance data) */ static CMPIStatus EnumInstances( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ - char ** properties) /* [in] List of desired properties (NULL=all) */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ -{ +{ /* HPI vars */ SaErrorT error; SaHpiRptEntryT entry; @@ -190,7 +190,7 @@ static CMPIStatus EnumInstances( error = saHpiRptEntryGet(hpi_hnd.sid, entry_id, &entry_id, &entry); - + if (error != SA_OK) { _OSBASE_TRACE(1,("%s:EnumInstanceNames() : Failed to get HPI data", _CLASSNAME)); CMReturnWithChars(_BROKER, CMPI_RC_ERR_FAILED, "Failed to get HPI data"); @@ -199,9 +199,9 @@ static CMPIStatus EnumInstances( rdr_id = SAHPI_FIRST_ENTRY; do { memset(&rdr, 0, sizeof(rdr)); - error = saHpiRdrGet(hpi_hnd.sid, - entry.ResourceId, - rdr_id, + error = saHpiRdrGet(hpi_hnd.sid, + entry.ResourceId, + rdr_id, &rdr_id, &rdr); /* Create a new template instance for returning results */ @@ -224,14 +224,14 @@ static CMPIStatus EnumInstances( saHpiDomainInfoGet(hpi_hnd.sid, &domain_info); memset(buf, 0, sizeof(buf)); - sprintf(buf, "{Domain ID=%d}{Resource ID=%d}{Management Instrument Type=%s}{Management Instrument ID=%d}", + sprintf(buf, "{Domain ID=%d}{Resource ID=%d}{Management Instrument Type=%s}{Management Instrument ID=%d}", domain_info.DomainId, entry.ResourceId, - oh_lookup_rdrtype(rdr.RdrType), + oh_lookup_rdrtype(rdr.RdrType), rdr.RecordId); - + printf("*** DeviceID [%s] ***\n", buf); - CMSetProperty(instance, "DeviceID", + CMSetProperty(instance, "DeviceID", (CMPIValue *)buf, CMPI_chars); CMSetProperty(instance, "SystemCreationClassName", (CMPIValue *)"Linux_ComputerSystem", CMPI_chars); @@ -248,69 +248,69 @@ static CMPIStatus EnumInstances( /* ResourceId */ printf("*** RId [%d] ***\n", entry.ResourceId); - CMSetProperty(instance, "RID", + CMSetProperty(instance, "RID", (CMPIValue *)&entry.ResourceId, CMPI_uint32); /* ResourceRev */ - printf("*** ResourceRev [%d] ***\n", + printf("*** ResourceRev [%d] ***\n", entry.ResourceInfo.ResourceRev); - CMSetProperty(instance, "ResourceRev", - (CMPIValue *)&entry.ResourceInfo.ResourceRev, + CMSetProperty(instance, "ResourceRev", + (CMPIValue *)&entry.ResourceInfo.ResourceRev, CMPI_uint8); /* SpecificVer */ - printf("*** SpecificVer [%d] ***\n", + printf("*** SpecificVer [%d] ***\n", entry.ResourceInfo.SpecificVer); - CMSetProperty(instance, "SpecificVer", - (CMPIValue *)&entry.ResourceInfo.SpecificVer, + CMSetProperty(instance, "SpecificVer", + (CMPIValue *)&entry.ResourceInfo.SpecificVer, CMPI_uint8); /* DeviceSupport */ - printf("*** DeviceSupport [%d] ***\n", + printf("*** DeviceSupport [%d] ***\n", entry.ResourceInfo.DeviceSupport); - CMSetProperty(instance, "DeviceSupport", - (CMPIValue *)&entry.ResourceInfo.DeviceSupport, + CMSetProperty(instance, "DeviceSupport", + (CMPIValue *)&entry.ResourceInfo.DeviceSupport, CMPI_uint8); /* ManufacturerId */ - printf("*** ManufacturerId [%d] ***\n", + printf("*** ManufacturerId [%d] ***\n", entry.ResourceInfo.ManufacturerId); - CMSetProperty(instance, "ManufacturerId", - (CMPIValue *)&entry.ResourceInfo.ManufacturerId, + CMSetProperty(instance, "ManufacturerId", + (CMPIValue *)&entry.ResourceInfo.ManufacturerId, CMPI_uint32); - + /* ProductId */ - printf("*** ProductId [%d] ***\n", + printf("*** ProductId [%d] ***\n", entry.ResourceInfo.ProductId); - CMSetProperty(instance, "ProductId", - (CMPIValue *)&entry.ResourceInfo.ProductId, + CMSetProperty(instance, "ProductId", + (CMPIValue *)&entry.ResourceInfo.ProductId, CMPI_uint16); /* FirmwareMajorRev */ - printf("*** FirmwareMajorRev [%d] ***\n", + printf("*** FirmwareMajorRev [%d] ***\n", entry.ResourceInfo.FirmwareMajorRev); - CMSetProperty(instance, "FirmwareMajorRev", - (CMPIValue *)&entry.ResourceInfo.FirmwareMajorRev, + CMSetProperty(instance, "FirmwareMajorRev", + (CMPIValue *)&entry.ResourceInfo.FirmwareMajorRev, CMPI_uint8); /* FirmwareMinorRev */ - printf("*** FirmwareMinorRev [%d] ***\n", + printf("*** FirmwareMinorRev [%d] ***\n", entry.ResourceInfo.FirmwareMinorRev); - CMSetProperty(instance, "FirmwareMinorRev", - (CMPIValue *)&entry.ResourceInfo.FirmwareMinorRev, + CMSetProperty(instance, "FirmwareMinorRev", + (CMPIValue *)&entry.ResourceInfo.FirmwareMinorRev, CMPI_uint8); /* AuxFirmwareRev */ - printf("*** AuxFirmwareRev [%d] ***\n", + printf("*** AuxFirmwareRev [%d] ***\n", entry.ResourceInfo.AuxFirmwareRev); - CMSetProperty(instance, "AuxFirmwareRev", - (CMPIValue *)&entry.ResourceInfo.AuxFirmwareRev, + CMSetProperty(instance, "AuxFirmwareRev", + (CMPIValue *)&entry.ResourceInfo.AuxFirmwareRev, CMPI_uint8); /* Guid */ - printf("*** Guid [%d] ***\n", + printf("*** Guid [%d] ***\n", entry.ResourceInfo.Guid); - CMSetProperty(instance, "Guid", + CMSetProperty(instance, "Guid", (CMPIValue *)&entry.ResourceInfo.Guid, CMPI_chars); @@ -319,18 +319,18 @@ static CMPIStatus EnumInstances( // memset(&bigbuf, 0, sizeof(bigbuf)); // error = oh_decode_entitypath(&entry.ResourceEntity, &bigbuf); memset(&bigbuf, 0, sizeof(bigbuf)); - error = oh_decode_entitypath(&entry.ResourceEntity, &bigbuf); + error = oh_decode_entitypath(&entry.ResourceEntity, &bigbuf); printf("*** EntityPath [%s] ***\n", bigbuf.Data); - CMSetProperty(instance, "EntityPath", + CMSetProperty(instance, "EntityPath", (CMPIValue *)bigbuf.Data, CMPI_chars); /* Resource Capabilities */ SaHpiTextBufferT buffer; memset(&buffer, 0, sizeof(buffer)); printf("*** Capabilities [%s] ***\n", buffer.Data); - error = oh_decode_capabilities(entry.ResourceCapabilities, + error = oh_decode_capabilities(entry.ResourceCapabilities, &buffer); - CMSetProperty(instance, "Capabilities", + CMSetProperty(instance, "Capabilities", (CMPIValue *)buffer.Data, CMPI_chars); /* SaHpiHsCapabilitiesT */ @@ -338,26 +338,26 @@ static CMPIStatus EnumInstances( error = oh_decode_hscapabilities(entry.HotSwapCapabilities, &buffer); printf("*** HotSwapCapabilities [%s] ***\n", buffer.Data); - CMSetProperty(instance, "HotSwapCapabilities", + CMSetProperty(instance, "HotSwapCapabilities", (CMPIValue *)buffer.Data, CMPI_chars); /* SaHpiSeverityT */ - printf("*** ResourceSeverity [%s] ***\n", + printf("*** ResourceSeverity [%s] ***\n", oh_lookup_severity(entry.ResourceSeverity)); - CMSetProperty(instance, "ResourceSeverity", - (CMPIValue *)oh_lookup_severity(entry.ResourceSeverity), + CMSetProperty(instance, "ResourceSeverity", + (CMPIValue *)oh_lookup_severity(entry.ResourceSeverity), CMPI_chars); /* ResourceFailed */ - printf("*** ResourceSeverity [%s] ***\n", + printf("*** ResourceSeverity [%s] ***\n", (entry.ResourceFailed == SAHPI_TRUE) ? "TRUE" : "FALSE"); - CMSetProperty(instance, "ResourceFailed", - (CMPIValue *)(entry.ResourceFailed == SAHPI_TRUE) - ? "TRUE" : "FALSE", + CMSetProperty(instance, "ResourceFailed", + (CMPIValue *)(unsigned long)(entry.ResourceFailed == SAHPI_TRUE) + ? "TRUE" : "FALSE", CMPI_chars); - + /* ResourceTag */ - CMSetProperty(instance, "ResourceTag", + CMSetProperty(instance, "ResourceTag", (CMPIValue *)entry.ResourceTag.Data, CMPI_chars); /* Add the instance for this process to the list of results */ @@ -376,11 +376,11 @@ static CMPIStatus EnumInstances( /* GetInstance() - return the instance data for the specified instance only */ static CMPIStatus GetInstance( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ - char ** properties) /* [in] List of desired properties (NULL=all) */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ { /* Commonly needed vars */ CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ @@ -414,7 +414,7 @@ static CMPIStatus GetInstance( _CLASSNAME, CMGetCharPtr(status.msg))); CMReturnWithChars(_BROKER, CMPI_RC_ERR_FAILED, "Failed to create new instance"); } - + error = saHpiRptEntryGet(hpi_hnd.sid, rid, &next_rid, &resource); if (error) { _OSBASE_TRACE(1,("%s:GetInstance() : Failed to get HPI data", _CLASSNAME)); @@ -425,7 +425,7 @@ static CMPIStatus GetInstance( CMSetProperty(instance, "ElementName", resource.ResourceTag.Data, CMPI_chars); /* Add the instance for this resource to the list of results */ CMReturnInstance(results, instance); - + /* Finished */ CMReturnDone(results); _OSBASE_TRACE(1,("%s:GetInstance() %s", _CLASSNAME, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); @@ -433,22 +433,23 @@ static CMPIStatus GetInstance( } -/* SetInstance() - save modified instance data for the specified instance */ -static CMPIStatus SetInstance( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ - CMPIInstance * newinstance) /* [in] Contains all the new instance data */ +/* ModifyInstance() - save modified instance data for the specified instance */ +static CMPIStatus ModifyInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ + const CMPIInstance * newinstance, /* [in] Contains all the new instance data */ + const char **properties) { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations */ - - _OSBASE_TRACE(1,("%s:SetInstance() called", self->ft->miName)); - + + _OSBASE_TRACE(1,("%s:ModifyInstance() called", self->ft->miName)); + /* Modifying existing instances is not supported for this class */ - + /* Finished */ - _OSBASE_TRACE(1,("%s:SetInstance() %s", + _OSBASE_TRACE(1,("%s:ModifyInstance() %s", self->ft->miName, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -456,18 +457,18 @@ static CMPIStatus SetInstance( /* CreateInstance() - create a new instance from the specified instance data */ static CMPIStatus CreateInstance( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ - CMPIInstance * newinstance) /* [in] Contains all the new instance data */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ + const CMPIInstance * newinstance) /* [in] Contains all the new instance data */ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations */ - + _OSBASE_TRACE(1,("%s:CreateInstance() called", self->ft->miName)); /* Creating new instances is not supported for this class */ - + /* Finished */ CMReturnDone(results); @@ -479,17 +480,17 @@ static CMPIStatus CreateInstance( /* DeleteInstance() - delete/remove the specified instance */ static CMPIStatus DeleteInstance( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference) /* [in] Contains the CIM namespace, classname and desired object path */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference) /* [in] Contains the CIM namespace, classname and desired object path */ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations */ - + _OSBASE_TRACE(1,("%s:CreateInstance() called", self->ft->miName)); /* Creating new instances is not supported for this class */ - + /* Finished */ // CMReturnDone(results); @@ -501,18 +502,18 @@ static CMPIStatus DeleteInstance( /* ExecQuery() - return a list of all the instances that 'satisfy' the desired query filter */ static CMPIStatus ExecQuery( - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context, /* [in] Additional context info, if any */ - CMPIResult * results, /* [out] Results of this operation */ - CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ - char * language, /* [in] Name of the query language (e.g. "WQL") */ - char * query) /* [in] Text of the query, written in the query language */ + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ + const char * language, /* [in] Name of the query language (e.g. "WQL") */ + const char * query) /* [in] Text of the query, written in the query language */ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations */ - + _OSBASE_TRACE(1,("%s:ExecQuery() called", self->ft->miName)); - - /* Query filtering is not supported for this class */ + + /* Query filtering is not supported for this class */ /* Finished */ CMReturnDone(results); @@ -526,14 +527,15 @@ static CMPIStatus ExecQuery( /* Cleanup() - perform any necessary cleanup immediately before this provider is unloaded */ static CMPIStatus Cleanup( CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ - CMPIContext * context) /* [in] Additional context info, if any */ + const CMPIContext * context, /* [in] Additional context info, if any */ + CMPIBoolean terminating) { CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ - + _OSBASE_TRACE(1,("%s:Cleanup() called", self->ft->miName)); - + /* Nothing needs to be done for cleanup */ - + /* Finished */ _OSBASE_TRACE(1,("%s:Cleanup() %s", self->ft->miName, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); @@ -543,11 +545,11 @@ static CMPIStatus Cleanup( /* OPTIONAL: Initialize() is *NOT* a predefined CMPI method. See CMInstanceMIStub() below */ static void Initialize( - CMPIBroker *broker) /* [in] Handle to the CIMOM */ + const CMPIBroker *broker) /* [in] Handle to the CIMOM */ { SaErrorT error = SA_OK; - - _OSBASE_TRACE(1,("%s:Initialize() called", _CLASSNAME)); + + _OSBASE_TRACE(1,("%s:Initialize() called", _CLASSNAME)); error = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &(hpi_hnd.sid), 0); if (error) { @@ -568,7 +570,7 @@ static void Initialize( _OSBASE_TRACE(1,("%s:saHpiDiscover() failed", _CLASSNAME)); return; } - + /* Nothing needs to be done */ _OSBASE_TRACE(1,("%s:Initialize() succeeded", _CLASSNAME)); } @@ -584,7 +586,7 @@ static void Initialize( - 2nd param is the name to call this provider in the CIMOM. It is recommended to call your provider "<_CLASSNAME>" or "<_CLASSNAME>Provider" - the name must be unique among all providers. - 3rd param is the local variable acting as a handle to the CIMOM. It will be initialized by the CIMOM - when the provider is loaded. + when the provider is loaded. - 4th param specified the the provider's initialization function to be called immediately after loading the provider. Specify "CMNoHook" if not required. */ CMInstanceMIStub( , HPI_LogicalDeviceProvider, _BROKER, Initialize(_BROKER)); -- 2.38.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor