From: <np...@us...> - 2007-02-14 17:16:48
|
Revision: 438 http://svn.sourceforge.net/omc/?rev=438&view=rev Author: npaxton Date: 2007-02-14 09:16:47 -0800 (Wed, 14 Feb 2007) Log Message: ----------- time-service update Modified Paths: -------------- cmpibase/trunk/src/Makefile.am cmpibase/trunk/src/providers/time-service/Makefile.am cmpibase/trunk/src/providers/time-service/hostedTimeService.c cmpibase/trunk/src/providers/time-service/mof/TimeServiceProviderReg.mof cmpibase/trunk/src/providers/time-service/remoteTimeServicePort.c cmpibase/trunk/src/providers/time-service/timeServiceAccessBySAP.c cmpibase/trunk/src/providers/time-service/timeServiceAvailableToElement.c cmpibase/trunk/src/providers/time-service/timeZoneSettingData.c Modified: cmpibase/trunk/src/Makefile.am =================================================================== --- cmpibase/trunk/src/Makefile.am 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/Makefile.am 2007-02-14 17:16:47 UTC (rev 438) @@ -1,7 +1,5 @@ AUTOMAKE_OPTIONS = gnu SUBDIRS = \ - lib \ - include \ providers Modified: cmpibase/trunk/src/providers/time-service/Makefile.am =================================================================== --- cmpibase/trunk/src/providers/time-service/Makefile.am 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/Makefile.am 2007-02-14 17:16:47 UTC (rev 438) @@ -4,9 +4,9 @@ libomccmpi_remoteTimeServicePort.la \ libomccmpi_timeZoneSettingData.la \ libomccmpi_hostedTimeService.la \ - libomccmpi_timeServiceTimeZoneSettingData.la -# libomccmpi_timeServiceAccessBySAP.la -# libomccmpi_timeServiceAvailableToElement.la + libomccmpi_timeServiceTimeZoneSettingData.la \ + libomccmpi_timeServiceAccessBySAP.la \ + libomccmpi_timeServiceAvailableToElement.la INCLUDES = -I$(top_srcdir)/src/include @@ -71,28 +71,26 @@ -version-info 1 -#libomccmpi_timeServiceAccessBySAP_la_LIBADD = \ +libomccmpi_timeServiceAccessBySAP_la_LIBADD = \ $(top_builddir)/src/lib/omc/libomc_cmpi.la \ $(top_builddir)/src/lib/omc/libomc_cbase.la -#libomccmpi_timeServiceAccessBySAP_la_SOURCES = \ +libomccmpi_timeServiceAccessBySAP_la_SOURCES = \ timeServiceAccessBySAP.c -#libomccmpi_timeServiceAccessBySAP_la_LDFLAGS = \ +libomccmpi_timeServiceAccessBySAP_la_LDFLAGS = \ -lpthread \ -version-info 1 -#libomccmpi_timeServiceAvailableToElement_la_LIBADD = \ +libomccmpi_timeServiceAvailableToElement_la_LIBADD = \ $(top_builddir)/src/lib/omc/libomc_cmpi.la \ $(top_builddir)/src/lib/omc/libomc_cbase.la -#libomccmpi_timeServiceAvailableToElement_la_SOURCES = \ +libomccmpi_timeServiceAvailableToElement_la_SOURCES = \ timeServiceAvailableToElement.c -#libomccmpi_timeServiceAvailableToElement_la_LDFLAGS = \ +libomccmpi_timeServiceAvailableToElement_la_LDFLAGS = \ -lpthread \ -version-info 1 - - Modified: cmpibase/trunk/src/providers/time-service/hostedTimeService.c =================================================================== --- cmpibase/trunk/src/providers/time-service/hostedTimeService.c 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/hostedTimeService.c 2007-02-14 17:16:47 UTC (rev 438) @@ -42,7 +42,7 @@ #include <stdlib.h> #include <string.h> -#define LOCAL_DEBUG +//#define LOCAL_DEBUG #ifdef LOCAL_DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) Modified: cmpibase/trunk/src/providers/time-service/mof/TimeServiceProviderReg.mof =================================================================== --- cmpibase/trunk/src/providers/time-service/mof/TimeServiceProviderReg.mof 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/mof/TimeServiceProviderReg.mof 2007-02-14 17:16:47 UTC (rev 438) @@ -151,3 +151,65 @@ CapabilityID = "OMC_TimeServiceTimeZoneSettingData-1"; }; + + + +instance of PG_ProviderModule +{ + Name = "OMC_TimeServiceAccessBySAP_Module"; + Location = "omccmpi_timeServiceAccessBySAP"; + Vendor = "OMC"; + Version = "2.0.0"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; +}; + +instance of PG_Provider +{ + Name = "OMC_TimeServiceAccessBySAP_Provider"; + ProviderModuleName = "OMC_TimeServiceAccessBySAP_Module"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "OMC_TimeServiceAccessBySAP_Module"; + ProviderName = "OMC_TimeServiceAccessBySAP_Provider"; + ClassName = "OMC_TimeServiceAccessBySAP"; + ProviderType = { 2, 3 }; + Namespaces = {"smash"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "OMC_TimeServiceAccessBySAP-1"; +}; + + + + +instance of PG_ProviderModule +{ + Name = "OMC_TimeServiceAvailableToElement_Module"; + Location = "omccmpi_timeServiceAvailableToElement"; + Vendor = "OMC"; + Version = "2.0.0"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; +}; + +instance of PG_Provider +{ + Name = "OMC_TimeServiceAvailableToElement_Provider"; + ProviderModuleName = "OMC_TimeServiceAvailableToElement_Module"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "OMC_TimeServiceAvailableToElement_Module"; + ProviderName = "OMC_TimeServiceAvailableToElement_Provider"; + ClassName = "OMC_TimeServiceAvailableToElement"; + ProviderType = { 2, 3 }; + Namespaces = {"smash"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "OMC_TimeServiceAvailableToElement-1"; +}; + Modified: cmpibase/trunk/src/providers/time-service/remoteTimeServicePort.c =================================================================== --- cmpibase/trunk/src/providers/time-service/remoteTimeServicePort.c 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/remoteTimeServicePort.c 2007-02-14 17:16:47 UTC (rev 438) @@ -251,28 +251,30 @@ char *inServerName = CMGetCharPtr(key.value.string); DEBUGOUT(" got servername: %s\n", inServerName); - NTPServer *ntpServer = getNTPServer(inServerName); - if (ntpServer) + //NTPServer *ntpServer = getNTPServer(inServerName); + //if (ntpServer) { - DEBUGOUT(" got NTPServer: %s\n", ntpServer->serverName); + //DEBUGOUT(" got NTPServer: %s\n", ntpServer->serverName); CMPIInstance *inst = makeRemoteTimeServicePortInstance( _broker, ns, - ntpServer->serverName, + inServerName, &status, properties); if (!CMIsNullObject(cop)) { CMReturnInstance(results, inst); } - free(ntpServer); + //free(ntpServer); } + /* else { OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_FAILED, "Didn't find ntpServer in file"); DEBUGOUT("RemoteTimeServerPort: getNTPServer() failed - %s\n", CMGetCharPtr(status.msg)); return status; } + */ } CMReturnDone(results); @@ -303,66 +305,90 @@ const CMPIInstance * newinstance, const char ** properties) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("RemoteTimeServicePort: ModifyInstance() called - Not Supported\n"); + DEBUGOUT("RemoteTimeServicePort: ModifyInstance() called\n"); //TODO: this should support ModifyInstance - edit an entry in the file -/* - if (::geteuid() != 0) - { - OW_THROWCIM(CIMException::ACCESS_DENIED); - } + if (geteuid() != 0) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_ACCESS_DENIED, + "You don't have rights to modify the RemoteTimeServicePort"); + return status; + } - if(!serverSupportsNTP()) - { - OW_THROWCIMMSG(CIMException::NOT_SUPPORTED, - "NTP Support is not available"); - } + if(!serverSupportsNTP()) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_NOT_SUPPORTED, + "NTP Support is not available on this server"); + return status; + } - CIMInstance mci = modifiedInstance.createModifiedInstance( - previousInstance, includeQualifiers, propertyList, theClass); + NTPServer modServer = {{0},0,0,0,0}; + DEBUGOUT(" modServer initialized: %s\n key: %d\n version: %d\n minpoll: %d\n maxpoll: %d\n", modServer.serverName, modServer.key, modServer.ntpVersion, modServer.minPoll, modServer.maxPoll); - CIMValue cv = mci.getPropertyValue("Name"); - if(!cv) - { - OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, - "Name property must be specified"); - } + CMPIData nameVal, preferVal, keyVal, verVal, minVal, maxVal; - NTPServer server; - cv.get(server.serverName); - if(server.serverName.empty()) - { - OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, - "Name property must be specified"); - } + nameVal = CMGetProperty(newinstance, "Name", &status); + if (!CMIsNullValue(nameVal)) + { + strncpy(modServer.serverName, CMGetCharPtr(nameVal.value.string), NTP_SERVER_NAME_LEN); + } - cv = mci.getPropertyValue("Prefer"); - if(cv) - { - Bool prefer; - cv.get(prefer); - server.prefer = prefer; - } + if (!*(modServer.serverName)) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_INVALID_PARAMETER, + "Name property must be specified"); + return status; + } - server.key = getUIntFromCIMValue("key", mci); - server.ntpVersion = getUIntFromCIMValue("ntpversion", mci); - server.minPoll = getUIntFromCIMValue("minpoll", mci); - server.maxPoll = getUIntFromCIMValue("maxpoll", mci); + preferVal = CMGetProperty(newinstance, "Prefer", &status); + if (!CMIsNullValue(preferVal)) + { + modServer.prefer = preferVal.value.uint32; + DEBUGOUT(" Retrieved Value: Prefer: %d\n", modServer.prefer); + } - if(NTPConf::setServer(server) != 0) - { - OW_THROWCIM(CIMException::FAILED); - } + keyVal = CMGetProperty(newinstance, "Key", &status); + if (!CMIsNullValue(keyVal)) + { + modServer.key = keyVal.value.uint32; + DEBUGOUT(" Retrieved Value: Key: %d\n", modServer.key); + } - String errMsg; - if(restartNTP(errMsg) != 0) - { - OW_THROWCIMMSG(CIMException::FAILED, errMsg.c_str()); - } + verVal = CMGetProperty(newinstance, "NTPversion", &status); + if (!CMIsNullValue(verVal)) + { + modServer.ntpVersion = verVal.value.uint32; + DEBUGOUT(" Retrieved Value: ntpVersion: %d\n", modServer.ntpVersion); + } -*/ + minVal = CMGetProperty(newinstance, "MinPoll", &status); + if (!CMIsNullValue(minVal)) + { + modServer.minPoll = minVal.value.uint32; + DEBUGOUT(" Retrieved Value: minPoll: %d\n", modServer.minPoll); + } + + maxVal = CMGetProperty(newinstance, "MaxPoll", &status); + if (!CMIsNullValue(maxVal)) + { + modServer.maxPoll = maxVal.value.uint32; + DEBUGOUT(" Retrieved Value: maxPoll: %d\n", modServer.maxPoll); + } + + DEBUGOUT(" about to call setNTPServer: %s\n key: %d\n version: %d\n minpoll: %d\n maxpoll: %d\n", modServer.serverName, modServer.key, modServer.ntpVersion, modServer.minPoll, modServer.maxPoll); + if (setNTPServer(modServer.serverName, &modServer) != 0) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_FAILED, + "Failed to delete the server from /etc/ntp.conf"); + return status; + } + + + // TODO: + // restartNTP + DEBUGOUT("RemoteTimeServicePort: Leaving ModifyInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -388,7 +414,7 @@ //TODO: this should support CreateInstance - add an entry to the file /* - if (::geteuid() != 0) + if (geteuid() != 0) { OW_THROWCIM(CIMException::ACCESS_DENIED); } @@ -462,38 +488,36 @@ DEBUGOUT("RemoteTimeServicePort: DeleteInstance() called\n"); //TODO: this should support DeleteInstance - remove an entry from the file -/* - if (::geteuid() != 0) - { - OW_THROWCIM(CIMException::ACCESS_DENIED); - } + if (geteuid() != 0) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_ACCESS_DENIED, + "You don't have rights to modify the RemoteTimeServicePort"); + return status; + } - if(!serverSupportsNTP()) - { - OW_THROWCIMMSG(CIMException::NOT_SUPPORTED, - "NTP Support is not available"); - } + if(!serverSupportsNTP()) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_NOT_SUPPORTED, + "NTP Support is not available on this server"); + return status; + } - CIMValue cv = cop.getKeyValue("Name"); - if(!cv) - { - OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, - "Name is missing from given object path"); - } + CMPIData nameVal; - String serverName; - cv.get(serverName); - if(serverName.length() == 0) - { - OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, - "Name is missing from given object path"); - } + nameVal = CMGetKey(cop, "Name", &status); + if (!CMIsNullValue(nameVal)) + { + char *serverName = CMGetCharPtr(nameVal.value.string); + if (deleteNTPServer(serverName) != 0) + { + OMC_SETSTATUS(_broker, &status, CMPI_RC_ERR_FAILED, + "Failed to delete the server from /etc/ntp.conf"); + return status; + } + } - if(NTPConf::deleteServer(serverName) != 0) - { - OW_THROWCIM(CIMException::FAILED); - } - + // TODO: restart NTP Server +/* String errMsg; if(restartNTP(errMsg) != 0) { Modified: cmpibase/trunk/src/providers/time-service/timeServiceAccessBySAP.c =================================================================== --- cmpibase/trunk/src/providers/time-service/timeServiceAccessBySAP.c 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/timeServiceAccessBySAP.c 2007-02-14 17:16:47 UTC (rev 438) @@ -37,6 +37,8 @@ #include <omc/base.h> #include <omc/cmpiUtils.h> #include <omc/cmpiSimpleAssoc.h> +#include <omc/cmpiTimeServiceUtils.h> +#include <omc/ntpServer.h> #include <stdlib.h> #include <string.h> @@ -49,18 +51,18 @@ #define DEBUGOUT(fmt, args...) #endif -static const char* classKeys[] = { "ManagedElement", "SettingData", NULL }; +static const char* classKeys[] = { "Antecedent", "Dependent", NULL }; // Global handle to the CIM broker // This is initialized by the CIMOM when the provider is loaded static const CMPIBroker * _broker; -static char * ASSOC_CLASSNAME = "OMC_ComputerSystemHostNameSettingData"; -static char * LEFT_CLASSNAME = "OMC_UnitaryComputerSystem"; -static char * RIGHT_CLASSNAME = "OMC_HostNameSettingData"; -static char * LEFT_PROPERTYNAME = "ManagedElement"; -static char * RIGHT_PROPERTYNAME = "SettingData"; +static char * ASSOC_CLASSNAME = "OMC_TimeServiceAccessBySAP"; +static char * LEFT_CLASSNAME = "OMC_SystemTimeService"; +static char * RIGHT_CLASSNAME = "OMC_RemoteTimeServicePort"; +static char * LEFT_PROPERTYNAME = "Antecedent"; +static char * RIGHT_PROPERTYNAME = "Dependent"; // **************************************************************************** // CMPI INSTANCE PROVIDER FUNCTIONS @@ -83,126 +85,61 @@ const CMPIResult * results, const CMPIObjectPath * cop) { - DEBUGOUT("%s", "EnumInstanceNames() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::EnumInstanceNames() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); - // Create and populate cs object path - CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, ns, &status); - if (CMIsNullObject(cscop)) + if(serverSupportsNTP()) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create computerSystem cop"); - return status; - } + // Create and populate systemTimeService object path (LEFT) + CMPIObjectPath *tscop = makeTimeServiceObjectPath( _broker, ns, &status); + if (CMIsNullObject(tscop)) + { + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create systemTimeService cop"); + return status; + } - // Create and populate hostname object path - CMPIObjectPath * hnsdcop = CMNewObjectPath(_broker, + int numServers = 0; + NTPServer *sra = getNTPServers(&numServers); + if (sra && numServers) + { + int i=0; + for (i=0; i<numServers; i++) + { + CMPIObjectPath *rpcop = makeRemoteTimeServicePortObjectPath( + _broker, ns, - RIGHT_CLASSNAME, + sra[i].serverName, &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(hnsdcop)) - { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create host name setting data ObjectPath"); - return status; + if (!CMIsNullObject(cop)) + { + CMPIObjectPath *assocCop = omccmpiCreateAssociationPath(_broker, + ns, + ASSOC_CLASSNAME, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + tscop, + rpcop, + &status); + CMReturnObjectPath(results, assocCop); + } + } + free(sra); + } } - else - { - // Add key to new object path - char instanceID[] = "omc:computername"; - CMAddKey(hnsdcop, "InstanceID", (CMPIValue *)instanceID, CMPI_chars); - } - CMPIObjectPath *assocCop = omccmpiCreateAssociationPath(_broker, - ns, - ASSOC_CLASSNAME, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cscop, - hnsdcop, - &status); - - if (!CMIsNullObject(assocCop)) - { - //return (handle) object path - CMReturnObjectPath(results, assocCop); - } - //close return handler CMReturnDone(results); - DEBUGOUT("Leaving EnumInstanceNames(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving EnumInstanceNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } // **************************************************************************** -// CreateAssocInstance() -// params: CMPIObjectPath* cop: [in] target namespace and classname, -// and desired objectpath -// char **properties: [in] propertylist filter, null=all -// **************************************************************************** -static CMPIInstance * -CreateAssocInstance( - const CMPIObjectPath * cop, - const char ** properties, - CMPIStatus *pStatus) -{ - DEBUGOUT("%s", "CreateAssocInst() called\n"); - - char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); - - //DEBUGOUT("%s", "About to create cs cop\n"); - // Create and populate cs object path - CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, ns, pStatus); - if (CMIsNullObject(cscop)) - { - CMSetStatusWithChars(_broker, pStatus, CMPI_RC_ERR_FAILED, - "Could not create computerSystem cop"); - return NULL; - } - - //DEBUGOUT("%s", "About to create host name setting data cop\n"); - // Create and populate hostname object path - CMPIObjectPath * hnsdcop = CMNewObjectPath(_broker, - ns, - RIGHT_CLASSNAME, - pStatus); - if ((pStatus->rc != CMPI_RC_OK) || CMIsNullObject(hnsdcop)) - { - CMSetStatusWithChars(_broker, pStatus, CMPI_RC_ERR_FAILED, - "Could not create host name setting data ObjectPath"); - return NULL; - } - else - { - // Add key to new object path - char instanceID[] = "omc:computername"; - CMAddKey(hnsdcop, "InstanceID", (CMPIValue *)instanceID, CMPI_chars); - } - - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - classKeys, - properties, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cscop, - hnsdcop, - pStatus); - - DEBUGOUT("Leaving EnumInstanceNames(): %s\n", - (pStatus->rc == CMPI_RC_OK)? "succeeded":"failed"); - return assocInst; -} - - - -// **************************************************************************** // EnumInstances() // params: CMPIInstanceMI* self: [in] Handle to this provider // CMPIContext* context: [in] any additional context info @@ -219,24 +156,57 @@ const CMPIObjectPath * cop, const char ** properties) { - DEBUGOUT("%s", "EnumInstances() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::EnumInstances() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; + char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); - // Create and check new instance - CMPIInstance * instance = CreateAssocInstance(cop, properties, &status); - if ((instance == NULL) || (CMIsNullObject(instance))) + if(serverSupportsNTP()) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create computerSystemHostNameSettingData instance"); - return status; + // Create and populate systemTimeService object path (LEFT) + CMPIObjectPath *tscop = makeTimeServiceObjectPath( _broker, ns, &status); + if (CMIsNullObject(tscop)) + { + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create systemTimeService cop"); + return status; + } + + int numServers = 0; + NTPServer *sra = getNTPServers(&numServers); + if (sra && numServers) + { + int i=0; + for (i=0; i<numServers; i++) + { + CMPIObjectPath *rpcop = makeRemoteTimeServicePortObjectPath( + _broker, + ns, + sra[i].serverName, + &status); + if (!CMIsNullObject(cop)) + { + CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + ns, + ASSOC_CLASSNAME, + classKeys, + properties, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + tscop, + rpcop, + &status); + CMReturnInstance(results, assocInst); + } + } + free(sra); + } } - CMReturnInstance(results, instance); //close return handler CMReturnDone(results); - DEBUGOUT("Leaving EnumInstances(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving EnumInstances(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -259,15 +229,15 @@ const CMPIObjectPath * cop, const char ** properties) { - DEBUGOUT("%s", "GetInstance() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::GetInstance() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); // do work here - CMPIData mekey = CMGetKey(cop, LEFT_PROPERTYNAME, &status); - CMPIData sdkey = CMGetKey(cop, RIGHT_PROPERTYNAME, &status); - if (!CMIsNullValue(mekey) && !CMIsNullValue(sdkey)) + CMPIData leftkey = CMGetKey(cop, LEFT_PROPERTYNAME, &status); + CMPIData rightkey = CMGetKey(cop, RIGHT_PROPERTYNAME, &status); + if (!CMIsNullValue(leftkey) && !CMIsNullValue(rightkey)) { CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, ns, @@ -276,8 +246,8 @@ properties, LEFT_PROPERTYNAME, RIGHT_PROPERTYNAME, - mekey.value.ref, - sdkey.value.ref, + leftkey.value.ref, + rightkey.value.ref, &status); CMReturnInstance(results, assocInst); @@ -285,7 +255,7 @@ CMReturnDone(results); } - DEBUGOUT("Leaving GetInstance(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving GetInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -311,11 +281,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "ModifyInstance() called - Not Supported\n"); + DEBUGOUT("TimeServiceAccessBySAP::ModifyInstance() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving ModifyInstance(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving ModifyInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -339,11 +309,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "CreateInstance() called - Not Supported\n"); + DEBUGOUT("TimeServiceAccessBySAP::CreateInstance() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving CreateInstance(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving CreateInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -365,11 +335,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "DeleteInstance() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::DeleteInstance() called\n"); // do work here if supported - DEBUGOUT("Leaving DeleteInstance(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving DeleteInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -395,11 +365,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "ExecQuery() called - Not Supported\n"); + DEBUGOUT("TimeServiceAccessBySAP::ExecQuery() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving ExecQuery(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving ExecQuery(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -418,11 +388,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("%s", "Cleanup() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::Cleanup() called\n"); // do work here if necessary - DEBUGOUT("Leaving Cleanup(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving Cleanup(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -437,11 +407,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("%s", "Initialize() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::Initialize() called\n"); // do work here if necessary - DEBUGOUT("Leaving Initialize(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving Initialize(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); } @@ -463,11 +433,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("AssocInit() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::AssocInit() called\n"); // do work here if necessary - DEBUGOUT("Leaving AssocInit(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving AssocInit(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); } @@ -487,11 +457,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("AssociationCleanup() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::AssociationCleanup() called\n"); // do work here if necessary - DEBUGOUT("Leaving AssociationCleanup(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving AssociationCleanup(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -504,7 +474,7 @@ // to be filtered by the SimpleAssociatior helper functions to return // the correct object (instance or object path) // **************************************************************************** -CMPIStatus +static CMPIStatus doReferences( omccmpiSimpleAssocCtx ctx, CMPIAssociationMI* self, @@ -518,7 +488,7 @@ const char *resultRole, const char** properties) { - DEBUGOUT("TimeServiceAccessBySAP::doReferences called\n"); + DEBUGOUT("TimeServiceAccessBySAP::TimeServiceAccessBySAP::doReferences called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); @@ -529,8 +499,8 @@ if(strcasecmp(objClassName, LEFT_CLASSNAME) == 0) { - // this is a UnitaryComputerSystem - // need to get approprate HostNameSettingData for assoc inst + // this is a SystemTimeService + // need to get all approprate remoteTimeServicePort for assoc inst // but if resultClass is set, it must match int bHaveMatch = 1; // TRUE @@ -556,58 +526,52 @@ if (bHaveMatch) { - char name[128] = {0}; - omcGetComputerSystemName(name, 128); - + // get the name from the SystemTimeService cop sent in + // should be 'omc:timeservice' CMPIData data = CMGetKey(cop, "Name", &status); char *inName = CMGetCharPtr(data.value.string); - //DEBUGOUT("Comparing inName: %s with name: %s\n", inName, name); - if (strcasecmp(inName, name) == 0) + if (strcasecmp(inName, "omc:timeservice") == 0) { - // create the host name cop that I'll use below - CMPIObjectPath *hncop = CMNewObjectPath(_broker, - ns, - RIGHT_CLASSNAME, - &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(hncop)) + if(serverSupportsNTP()) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create host name setting data cop"); - return status; - } - else - { - char instanceID[] = "omc:computername"; - CMAddKey(hncop, - "InstanceID", - (CMPIValue *)instanceID, - CMPI_chars); - } - // create an association instance - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + int numServers = 0; + NTPServer *sra = getNTPServers(&numServers); + if (sra && numServers) + { + int i=0; + for (i=0; i<numServers; i++) + { + CMPIObjectPath *rpcop = makeRemoteTimeServicePortObjectPath( + _broker, ns, - ASSOC_CLASSNAME, - classKeys, - properties, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cop, - hncop, + sra[i].serverName, &status); - omccmpiSimpleAssocResults(ctx, assocInst, &status); + if (!CMIsNullObject(rpcop)) + { + CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + ns, + ASSOC_CLASSNAME, + classKeys, + properties, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + cop, + rpcop, + &status); + omccmpiSimpleAssocResults(ctx, assocInst, &status); + } + } + free(sra); + } + } } } } else if(strcmp(objClassName, RIGHT_CLASSNAME) == 0) { - // this is a hostNameSettingData - // need to get apppropriate UnitaryComputerSystem for assocInst + // this is a remoteTimeServicePort + // need to get (one and only) apppropriate SystemTimeService for assocInst - CMPIData data = CMGetKey(cop, "InstanceID", &status); - char *inName = CMGetCharPtr(data.value.string); - //DEBUGOUT("comparing inName (%s) with name (%s)\n", - // inName, - // "omc:computername"); int bHaveMatch = 1; // TRUE if ((resultClass != NULL) && (*resultClass != 0)) { @@ -631,31 +595,29 @@ if (bHaveMatch) { - if (strcasecmp(inName, "omc:computername") == 0) + // the tscop that I'll use below + CMPIObjectPath *tscop = makeTimeServiceObjectPath( + _broker, + ns, + &status); + if ((status.rc != CMPI_RC_OK) || CMIsNullObject(tscop)) { - // the cscop that I'll use below - CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, - ns, - &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(cscop)) - { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create computerSystem cop"); - return status; - } - // create an association instance - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - classKeys, - properties, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cscop, - cop, - &status); - omccmpiSimpleAssocResults(ctx, assocInst, &status); + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create computerSystem cop"); + return status; } + // create an association instance + CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + ns, + ASSOC_CLASSNAME, + classKeys, + properties, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + tscop, + cop, + &status); + omccmpiSimpleAssocResults(ctx, assocInst, &status); } } else @@ -666,7 +628,7 @@ //close return handler CMReturnDone(results); - DEBUGOUT("Leaving doReferences\n"); + DEBUGOUT("TimeServiceAccessBySAP::Leaving doReferences\n"); return status; } @@ -697,13 +659,13 @@ const char *resultRole, const char** properties) { - DEBUGOUT("Associators() called. assocClass: %s\n", assocClass); + DEBUGOUT("TimeServiceAccessBySAP::Associators() called. assocClass: %s\n", assocClass); CMPIStatus status = omccmpiSimpleAssociators( doReferences, self, _broker, context, results, cop, assocClass, resultClass, role, resultRole, properties); - DEBUGOUT("Leaving Associatiors(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving Associatiors(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -732,13 +694,13 @@ const char *role, const char *resultRole) { - DEBUGOUT("AssociatorNames() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::AssociatorNames() called\n"); CMPIStatus status = omccmpiSimpleAssociatorNames( doReferences, self, _broker, context, results, cop, assocClass, resultClass, role, resultRole); - DEBUGOUT("Leaving AssociatiorNames(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving AssociatiorNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -765,12 +727,12 @@ const char *role , const char** properties) { - DEBUGOUT("References() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::References() called\n"); CMPIStatus status = omccmpiSimpleReferences( doReferences, self, _broker, context, results, cop, resultClass, role, properties); - DEBUGOUT("Leaving References(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving References(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -795,12 +757,12 @@ const char* resultClass, const char* role) { - DEBUGOUT("ReferenceNames() called\n"); + DEBUGOUT("TimeServiceAccessBySAP::ReferenceNames() called\n"); CMPIStatus status = omccmpiSimpleReferenceNames( doReferences, self, _broker, context, results, cop, resultClass, role); - DEBUGOUT("Leaving ReferenceNames(): %s\n", + DEBUGOUT("TimeServiceAccessBySAP::Leaving ReferenceNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -825,10 +787,10 @@ If no additional init is required, specify "CMNoHook" */ -CMInstanceMIStub( , OMC_CS_HostNameSettingData_Provider, +CMInstanceMIStub( , OMC_TimeServiceAccessBySAP_Provider, _broker, Init(&mi)); -CMAssociationMIStub( , OMC_CS_HostNameSettingData_Provider, +CMAssociationMIStub( , OMC_TimeServiceAccessBySAP_Provider, _broker, AssocInit(&mi)); Modified: cmpibase/trunk/src/providers/time-service/timeServiceAvailableToElement.c =================================================================== --- cmpibase/trunk/src/providers/time-service/timeServiceAvailableToElement.c 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/timeServiceAvailableToElement.c 2007-02-14 17:16:47 UTC (rev 438) @@ -37,6 +37,7 @@ #include <omc/base.h> #include <omc/cmpiUtils.h> #include <omc/cmpiSimpleAssoc.h> +#include <omc/cmpiTimeServiceUtils.h> #include <stdlib.h> #include <string.h> @@ -49,18 +50,18 @@ #define DEBUGOUT(fmt, args...) #endif -static const char* classKeys[] = { "ManagedElement", "SettingData", NULL }; +static const char* classKeys[] = { "UserOfService", "ServiceProvided", NULL }; // Global handle to the CIM broker // This is initialized by the CIMOM when the provider is loaded static const CMPIBroker * _broker; -static char * ASSOC_CLASSNAME = "OMC_ComputerSystemHostNameSettingData"; +static char * ASSOC_CLASSNAME = "OMC_TimeServiceAvailableToElement"; static char * LEFT_CLASSNAME = "OMC_UnitaryComputerSystem"; -static char * RIGHT_CLASSNAME = "OMC_HostNameSettingData"; -static char * LEFT_PROPERTYNAME = "ManagedElement"; -static char * RIGHT_PROPERTYNAME = "SettingData"; +static char * RIGHT_CLASSNAME = "OMC_SystemTimeService"; +static char * LEFT_PROPERTYNAME = "UserOfService"; +static char * RIGHT_PROPERTYNAME = "ServiceProvided"; // **************************************************************************** // CMPI INSTANCE PROVIDER FUNCTIONS @@ -83,12 +84,12 @@ const CMPIResult * results, const CMPIObjectPath * cop) { - DEBUGOUT("%s", "EnumInstanceNames() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::EnumInstanceNames() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); - // Create and populate cs object path + // Create and populate cs object path (LEFT) CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, ns, &status); if (CMIsNullObject(cscop)) { @@ -97,23 +98,14 @@ return status; } - // Create and populate hostname object path - CMPIObjectPath * hnsdcop = CMNewObjectPath(_broker, - ns, - RIGHT_CLASSNAME, - &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(hnsdcop)) + // Create and populate systemTimeService object path (RIGHT) + CMPIObjectPath *tscop = makeTimeServiceObjectPath( _broker, ns, &status); + if (CMIsNullObject(tscop)) { CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create host name setting data ObjectPath"); + "Could not create systemTimeService cop"); return status; } - else - { - // Add key to new object path - char instanceID[] = "omc:computername"; - CMAddKey(hnsdcop, "InstanceID", (CMPIValue *)instanceID, CMPI_chars); - } CMPIObjectPath *assocCop = omccmpiCreateAssociationPath(_broker, ns, @@ -121,7 +113,7 @@ LEFT_PROPERTYNAME, RIGHT_PROPERTYNAME, cscop, - hnsdcop, + tscop, &status); if (!CMIsNullObject(assocCop)) @@ -133,7 +125,7 @@ //close return handler CMReturnDone(results); - DEBUGOUT("Leaving EnumInstanceNames(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving EnumInstanceNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -151,11 +143,12 @@ const char ** properties, CMPIStatus *pStatus) { - DEBUGOUT("%s", "CreateAssocInst() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::CreateAssocInst() called\n"); + CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); - //DEBUGOUT("%s", "About to create cs cop\n"); + //DEBUGOUT("About to create cs cop\n"); // Create and populate cs object path CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, ns, pStatus); if (CMIsNullObject(cscop)) @@ -165,24 +158,15 @@ return NULL; } - //DEBUGOUT("%s", "About to create host name setting data cop\n"); - // Create and populate hostname object path - CMPIObjectPath * hnsdcop = CMNewObjectPath(_broker, - ns, - RIGHT_CLASSNAME, - pStatus); - if ((pStatus->rc != CMPI_RC_OK) || CMIsNullObject(hnsdcop)) + //DEBUGOUT("About to create systemTimeService data cop\n"); + // Create and populate systemTimeService object path (RIGHT) + CMPIObjectPath *tscop = makeTimeServiceObjectPath( _broker, ns, &status); + if (CMIsNullObject(tscop)) { - CMSetStatusWithChars(_broker, pStatus, CMPI_RC_ERR_FAILED, - "Could not create host name setting data ObjectPath"); + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create systemTimeService cop"); return NULL; } - else - { - // Add key to new object path - char instanceID[] = "omc:computername"; - CMAddKey(hnsdcop, "InstanceID", (CMPIValue *)instanceID, CMPI_chars); - } CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, ns, @@ -192,10 +176,10 @@ LEFT_PROPERTYNAME, RIGHT_PROPERTYNAME, cscop, - hnsdcop, + tscop, pStatus); - DEBUGOUT("Leaving EnumInstanceNames(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving EnumInstanceNames(): %s\n", (pStatus->rc == CMPI_RC_OK)? "succeeded":"failed"); return assocInst; } @@ -219,7 +203,7 @@ const CMPIObjectPath * cop, const char ** properties) { - DEBUGOUT("%s", "EnumInstances() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::EnumInstances() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; @@ -236,7 +220,7 @@ //close return handler CMReturnDone(results); - DEBUGOUT("Leaving EnumInstances(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving EnumInstances(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -259,15 +243,15 @@ const CMPIObjectPath * cop, const char ** properties) { - DEBUGOUT("%s", "GetInstance() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::GetInstance() called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); // do work here - CMPIData mekey = CMGetKey(cop, LEFT_PROPERTYNAME, &status); - CMPIData sdkey = CMGetKey(cop, RIGHT_PROPERTYNAME, &status); - if (!CMIsNullValue(mekey) && !CMIsNullValue(sdkey)) + CMPIData leftkey = CMGetKey(cop, LEFT_PROPERTYNAME, &status); + CMPIData rightkey = CMGetKey(cop, RIGHT_PROPERTYNAME, &status); + if (!CMIsNullValue(leftkey) && !CMIsNullValue(rightkey)) { CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, ns, @@ -276,8 +260,8 @@ properties, LEFT_PROPERTYNAME, RIGHT_PROPERTYNAME, - mekey.value.ref, - sdkey.value.ref, + leftkey.value.ref, + rightkey.value.ref, &status); CMReturnInstance(results, assocInst); @@ -285,7 +269,7 @@ CMReturnDone(results); } - DEBUGOUT("Leaving GetInstance(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving GetInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -311,11 +295,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "ModifyInstance() called - Not Supported\n"); + DEBUGOUT("TimeServiceAvailableToElement::ModifyInstance() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving ModifyInstance(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving ModifyInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -339,11 +323,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "CreateInstance() called - Not Supported\n"); + DEBUGOUT("TimeServiceAvailableToElement::CreateInstance() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving CreateInstance(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving CreateInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -365,11 +349,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "DeleteInstance() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::DeleteInstance() called\n"); // do work here if supported - DEBUGOUT("Leaving DeleteInstance(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving DeleteInstance(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -395,11 +379,11 @@ { CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; - DEBUGOUT("%s", "ExecQuery() called - Not Supported\n"); + DEBUGOUT("TimeServiceAvailableToElement::ExecQuery() called - Not Supported\n"); // do work here if supported - DEBUGOUT("Leaving ExecQuery(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving ExecQuery(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -418,11 +402,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("%s", "Cleanup() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::Cleanup() called\n"); // do work here if necessary - DEBUGOUT("Leaving Cleanup(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving Cleanup(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -437,11 +421,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("%s", "Initialize() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::Initialize() called\n"); // do work here if necessary - DEBUGOUT("Leaving Initialize(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving Initialize(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); } @@ -463,11 +447,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("AssocInit() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::AssocInit() called\n"); // do work here if necessary - DEBUGOUT("Leaving AssocInit(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving AssocInit(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); } @@ -487,11 +471,11 @@ { CMPIStatus status = {CMPI_RC_OK, NULL}; - DEBUGOUT("AssociationCleanup() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::AssociationCleanup() called\n"); // do work here if necessary - DEBUGOUT("Leaving AssociationCleanup(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving AssociationCleanup(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -504,7 +488,7 @@ // to be filtered by the SimpleAssociatior helper functions to return // the correct object (instance or object path) // **************************************************************************** -CMPIStatus +static CMPIStatus doReferences( omccmpiSimpleAssocCtx ctx, CMPIAssociationMI* self, @@ -518,7 +502,7 @@ const char *resultRole, const char** properties) { - DEBUGOUT("TimeServiceAvailableToElement::doReferences called\n"); + DEBUGOUT("TimeServiceAvailableToElement: doReferences called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); @@ -526,147 +510,135 @@ if (strcasecmp(assocClass, ASSOC_CLASSNAME) == 0) { char *objClassName = CMGetCharPtr(CMGetClassName(cop, NULL)); - - if(strcasecmp(objClassName, LEFT_CLASSNAME) == 0) + if (objClassName) { - // this is a UnitaryComputerSystem - // need to get approprate HostNameSettingData for assoc inst - // but if resultClass is set, it must match + DEBUGOUT(" Incoming className: %s\n", objClassName); - int bHaveMatch = 1; // TRUE - if ((resultClass != NULL) && (*resultClass != 0)) + if(strcasecmp(objClassName, LEFT_CLASSNAME) == 0) { - // check - if (!omccmpiClassIsDerivedFrom(RIGHT_CLASSNAME, - resultClass, - _broker,ns,&status)) + // this is a UnitaryComputerSystem + // need to get approprate SystemTimeService for assoc inst + // but if resultClass is set, it must match + + int bHaveMatch = 1; // TRUE + if ((resultClass != NULL) && (*resultClass != 0)) { - bHaveMatch = 0; // FALSE + // check + if (!omccmpiClassIsDerivedFrom(RIGHT_CLASSNAME, + resultClass, + _broker,ns,&status)) + { + bHaveMatch = 0; // FALSE + } } - } - if ((resultRole != NULL) && (*resultRole != 0)) - { - // check - if (strcasecmp(resultRole, RIGHT_PROPERTYNAME) != 0) + if ((resultRole != NULL) && (*resultRole != 0)) { - bHaveMatch = 0; // FALSE + // check + if (strcasecmp(resultRole, RIGHT_PROPERTYNAME) != 0) + { + bHaveMatch = 0; // FALSE + } } - } - if (bHaveMatch) - { - char name[128] = {0}; - omcGetComputerSystemName(name, 128); - - CMPIData data = CMGetKey(cop, "Name", &status); - char *inName = CMGetCharPtr(data.value.string); - //DEBUGOUT("Comparing inName: %s with name: %s\n", inName, name); - if (strcasecmp(inName, name) == 0) + if (bHaveMatch) { - // create the host name cop that I'll use below - CMPIObjectPath *hncop = CMNewObjectPath(_broker, - ns, - RIGHT_CLASSNAME, - &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(hncop)) + char name[128] = {0}; + omcGetComputerSystemName(name, 128); + + CMPIData data = CMGetKey(cop, "Name", &status); + if (!CMIsNullValue(data)) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create host name setting data cop"); - return status; + char *inName = CMGetCharPtr(data.value.string); + if (inName) + { + DEBUGOUT("Comparing inName: %s with name: %s\n", inName, name); + if (strcasecmp(inName, name) == 0) + { + // it matches, return the one and only instance we have: + CMPIInstance * instance = CreateAssocInstance(cop, properties, &status); + if ((instance == NULL) || (CMIsNullObject(instance))) + { + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create TimeServiceAvailableToElement instance"); + return status; + } + omccmpiSimpleAssocResults(ctx, instance, &status); + } + } + else + { + DEBUGOUT("Got empty value for key Name\n"); + } } else { - char instanceID[] = "omc:computername"; - CMAddKey(hncop, - "InstanceID", - (CMPIValue *)instanceID, - CMPI_chars); + DEBUGOUT("Got null value for key Name\n"); } - // create an association instance - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - classKeys, - properties, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cop, - hncop, - &status); - omccmpiSimpleAssocResults(ctx, assocInst, &status); } } - } - else if(strcmp(objClassName, RIGHT_CLASSNAME) == 0) - { - // this is a hostNameSettingData - // need to get apppropriate UnitaryComputerSystem for assocInst - - CMPIData data = CMGetKey(cop, "InstanceID", &status); - char *inName = CMGetCharPtr(data.value.string); - //DEBUGOUT("comparing inName (%s) with name (%s)\n", - // inName, - // "omc:computername"); - int bHaveMatch = 1; // TRUE - if ((resultClass != NULL) && (*resultClass != 0)) + else if(strcmp(objClassName, RIGHT_CLASSNAME) == 0) { - // check - if (!omccmpiClassIsDerivedFrom(LEFT_CLASSNAME, - resultClass, - _broker,ns,&status)) + // this is a SystemTimeService + // need to get apppropriate UnitaryComputerSystem for assocInst + + CMPIData data = CMGetKey(cop, "Name", &status); + char *inName = CMGetCharPtr(data.value.string); + //DEBUGOUT("comparing inName (%s) with name (%s)\n", + // inName, + // "omc:computername"); + int bHaveMatch = 1; // TRUE + if ((resultClass != NULL) && (*resultClass != 0)) { - bHaveMatch = 0; // FALSE + // check + if (!omccmpiClassIsDerivedFrom(LEFT_CLASSNAME, + resultClass, + _broker,ns,&status)) + { + bHaveMatch = 0; // FALSE + } } - } - if ((resultRole != NULL) && (*resultRole != 0)) - { - // check - if (strcasecmp(resultRole, LEFT_PROPERTYNAME) != 0) + if ((resultRole != NULL) && (*resultRole != 0)) { - bHaveMatch = 0; // FALSE + // check + if (strcasecmp(resultRole, LEFT_PROPERTYNAME) != 0) + { + bHaveMatch = 0; // FALSE + } } - } - if (bHaveMatch) - { - if (strcasecmp(inName, "omc:computername") == 0) + if (bHaveMatch) { - // the cscop that I'll use below - CMPIObjectPath *cscop = omccmpiCreateCSObjectPath( _broker, - ns, - &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(cscop)) + if (strcasecmp(inName, "omc:timeservice") == 0) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create computerSystem cop"); - return status; + // it matches, return the one and only instance we have: + CMPIInstance * instance = CreateAssocInstance(cop, properties, &status); + if ((instance == NULL) || (CMIsNullObject(instance))) + { + CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, + "Could not create TimeServiceAvailableToElement instance"); + return status; + } + omccmpiSimpleAssocResults(ctx, instance, &status); } - // create an association instance - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - classKeys, - properties, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cscop, - cop, - &status); - omccmpiSimpleAssocResults(ctx, assocInst, &status); } } + else + { + DEBUGOUT("!!! Object type unknown: %s\n", objClassName); + } } else { - DEBUGOUT("!!! Object type unknown: %s\n", objClassName); + // not an error - this gets called for ALL CIM_ManagedElement objects + // we don't want to handle them all. } } //close return handler CMReturnDone(results); - DEBUGOUT("Leaving doReferences\n"); + DEBUGOUT("TimeServiceAvailableToElement::Leaving doReferences\n"); return status; } @@ -697,13 +669,13 @@ const char *resultRole, const char** properties) { - DEBUGOUT("Associators() called. assocClass: %s\n", assocClass); + DEBUGOUT("TimeServiceAvailableToElement::Associators() called. assocClass: %s\n", assocClass); CMPIStatus status = omccmpiSimpleAssociators( doReferences, self, _broker, context, results, cop, assocClass, resultClass, role, resultRole, properties); - DEBUGOUT("Leaving Associatiors(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving Associatiors(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -732,13 +704,13 @@ const char *role, const char *resultRole) { - DEBUGOUT("AssociatorNames() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::AssociatorNames() called\n"); CMPIStatus status = omccmpiSimpleAssociatorNames( doReferences, self, _broker, context, results, cop, assocClass, resultClass, role, resultRole); - DEBUGOUT("Leaving AssociatiorNames(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving AssociatiorNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -765,12 +737,12 @@ const char *role , const char** properties) { - DEBUGOUT("References() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::References() called\n"); CMPIStatus status = omccmpiSimpleReferences( doReferences, self, _broker, context, results, cop, resultClass, role, properties); - DEBUGOUT("Leaving References(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving References(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -795,12 +767,12 @@ const char* resultClass, const char* role) { - DEBUGOUT("ReferenceNames() called\n"); + DEBUGOUT("TimeServiceAvailableToElement::ReferenceNames() called\n"); CMPIStatus status = omccmpiSimpleReferenceNames( doReferences, self, _broker, context, results, cop, resultClass, role); - DEBUGOUT("Leaving ReferenceNames(): %s\n", + DEBUGOUT("TimeServiceAvailableToElement::Leaving ReferenceNames(): %s\n", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -825,10 +797,10 @@ If no additional init is required, specify "CMNoHook" */ -CMInstanceMIStub( , OMC_CS_HostNameSettingData_Provider, +CMInstanceMIStub( , OMC_TimeServiceAvailableToElement_Provider, _broker, Init(&mi)); -CMAssociationMIStub( , OMC_CS_HostNameSettingData_Provider, +CMAssociationMIStub( , OMC_TimeServiceAvailableToElement_Provider, _broker, AssocInit(&mi)); Modified: cmpibase/trunk/src/providers/time-service/timeZoneSettingData.c =================================================================== --- cmpibase/trunk/src/providers/time-service/timeZoneSettingData.c 2007-02-14 17:05:52 UTC (rev 437) +++ cmpibase/trunk/src/providers/time-service/timeZoneSettingData.c 2007-02-14 17:16:47 UTC (rev 438) @@ -48,7 +48,7 @@ //static char * classKeys[] = {"InstanceID", NULL}; //static char instanceID[] = "omc:timezone"; -#define LOCAL_DEBUG +//#define LOCAL_DEBUG #ifdef LOCAL_DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |