From: <np...@us...> - 2006-11-01 23:59:19
|
Revision: 12 http://svn.sourceforge.net/omc/?rev=12&view=rev Author: npaxton Date: 2006-11-01 15:59:10 -0800 (Wed, 01 Nov 2006) Log Message: ----------- Original merge of diffs from transition to sourceforge Modified Paths: -------------- cmpibase/trunk/configure.ac cmpibase/trunk/src/include/omc/Makefile.am cmpibase/trunk/src/include/omc/base.h cmpibase/trunk/src/lib/omc/Makefile.am cmpibase/trunk/src/lib/omc/base.c cmpibase/trunk/src/lib/omc/cmpiSimpleAssoc.c cmpibase/trunk/src/lib/omc/cmpiUtils.c cmpibase/trunk/src/providers/Makefile.am cmpibase/trunk/src/providers/computer-system/computerSystemHostNameSettingData.c cmpibase/trunk/src/providers/template/cmpi-providerTemplate.c Added Paths: ----------- cmpibase/trunk/src/include/omc/cmpiTimeServiceUtils.h cmpibase/trunk/src/include/omc/ntpServer.h cmpibase/trunk/src/lib/omc/cmpiTimeServiceUtils.c cmpibase/trunk/src/lib/omc/ntpServer.c cmpibase/trunk/src/providers/computer-system/mof/ComputerSystemProviderReg.mof cmpibase/trunk/src/providers/time-service/ cmpibase/trunk/src/providers/time-service/Makefile.am cmpibase/trunk/src/providers/time-service/Makefile.in cmpibase/trunk/src/providers/time-service/hostedTimeService.c cmpibase/trunk/src/providers/time-service/mof/ cmpibase/trunk/src/providers/time-service/mof/TimeServiceProviderReg.mof cmpibase/trunk/src/providers/time-service/mof/cleanmof.sh cmpibase/trunk/src/providers/time-service/mof/genmof.sh cmpibase/trunk/src/providers/time-service/mof/importmof.sh cmpibase/trunk/src/providers/time-service/mof/omc-computer-system.mof cmpibase/trunk/src/providers/time-service/mof/omc-computer-system.reg.mof cmpibase/trunk/src/providers/time-service/mof/provider-register.sh cmpibase/trunk/src/providers/time-service/remoteTimeServicePort.c cmpibase/trunk/src/providers/time-service/systemTimeService.c cmpibase/trunk/src/providers/time-service/timeServiceAccessBySAP.c cmpibase/trunk/src/providers/time-service/timeServiceAvailableToElement.c cmpibase/trunk/src/providers/time-service/timeServiceTimeZoneSettingData.c cmpibase/trunk/src/providers/time-service/timeZoneSettingData.c Modified: cmpibase/trunk/configure.ac =================================================================== --- cmpibase/trunk/configure.ac 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/configure.ac 2006-11-01 23:59:10 UTC (rev 12) @@ -29,7 +29,7 @@ OPT_FLAGS=" -DNDEBUG -O2" # Additional optimization flags. -##NOTE: whereever CXXFLAGS is used, we need to also use CPPFLAGS, for the AC_CHECK_HEADERS - +##NOTE: whereever CXXFLAGS is used, we need to also use CPPFLAGS, for the AC_CHECK_HEADERS - ## It now uses compile (primarily) but still uses pre-processor for interim transition / backward compatibility ## pre-processor needs the CPPFLAGS @@ -40,10 +40,10 @@ [ --with-search-dir=PATH Specify an additional directory to look for include/ and lib/ sub dirs ], [ if test "x$withval" != "xno" ; then - CXXFLAGS="$CXXFLAGS -I$withval/include" - CPPFLAGS="$CPPFLAGS -I$withval/include" - CFLAGS="$CFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" + CXXFLAGS="$CXXFLAGS -I$withval/include" + CPPFLAGS="$CPPFLAGS -I$withval/include" + CFLAGS="$CFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" fi ] ) @@ -55,10 +55,10 @@ [ --with-cmpi-include-dir=PATH Specify locaction of the CMPI header files ], [ if test "x$withval" != "xno" ; then - CXXFLAGS="$CXXFLAGS -I$withval" - CPPFLAGS="$CPPFLAGS -I$withval" - CFLAGS="$CFLAGS -I$withval" - cmpiIncDir="$withval" + CXXFLAGS="$CXXFLAGS -I$withval" + CPPFLAGS="$CPPFLAGS -I$withval" + CFLAGS="$CFLAGS -I$withval" + cmpiIncDir="$withval" fi ] ) @@ -190,5 +190,6 @@ src/providers/processes/Makefile src/providers/computer-system/Makefile src/providers/operating-system/Makefile + src/providers/time-service/Makefile ]) AC_OUTPUT Modified: cmpibase/trunk/src/include/omc/Makefile.am =================================================================== --- cmpibase/trunk/src/include/omc/Makefile.am 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/include/omc/Makefile.am 2006-11-01 23:59:10 UTC (rev 12) @@ -9,4 +9,6 @@ string.h \ linuxProcUtils.h \ cmpiUtils.h \ - cmpiSimpleAssoc.h + cmpiSimpleAssoc.h \ + cmpiTimeServiceUtils.h \ + ntpServer.h Modified: cmpibase/trunk/src/include/omc/base.h =================================================================== --- cmpibase/trunk/src/include/omc/base.h 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/include/omc/base.h 2006-11-01 23:59:10 UTC (rev 12) @@ -109,6 +109,16 @@ char* instanceIdOut, size_t instanceIdOutLen); + +/** + * Get the install date of an RPM (as a time_t?) + * @param rpmName The name of the rpm to get the install date for. + */ +unsigned long long +omcGetRPMInstallDate( + const char *rpmName); + + #ifdef __cplusplus } #endif Added: cmpibase/trunk/src/include/omc/cmpiTimeServiceUtils.h =================================================================== --- cmpibase/trunk/src/include/omc/cmpiTimeServiceUtils.h (rev 0) +++ cmpibase/trunk/src/include/omc/cmpiTimeServiceUtils.h 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,88 @@ +/******************************************************************************* +* Copyright (C) 2005, 2006 Novell, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell, Inc. nor the names of its +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* Author: Norm Paxton (np...@no...) +******************************************************************************/ +#ifndef TIME_SERVICE_UTILS_H_GUARD__ +#define TIME_SERVICE_UTILS_H_GUARD__ + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include <omc/base.h> +#include <omc/cmpiUtils.h> +#include <omc/cmpiSimpleAssoc.h> +#include <omc/string.h> + +#include <stdlib.h> +#include <unistd.h> + +#ifdef __cplusplus +extern "C" { +#endif + + + +CMPIObjectPath * +makeTimeServiceObjectPath( + const CMPIBroker *broker, + const char *ns, + CMPIStatus *pStatus); + + +CMPIInstance * +makeTimeServiceInstance( + const CMPIBroker *broker, + const char *ns, + CMPIStatus *pStatus, + const char **properties); + + + +CMPIObjectPath* +makeRemoteTimeServicePortObjectPath( + const CMPIBroker *broker, + const char *ns, + const char *serverName, + CMPIStatus *pStatus); + + +CMPIInstance * +makeRemoteTimeServicePortInstance( + const CMPIBroker *broker, + const char *ns, + const char *serverName, + CMPIStatus *pStatus, + const char **properties); + +int isIPV4Address(const char *arg); + + +#endif // TIME_SERVICE_UTILS_H_GUARD__ Added: cmpibase/trunk/src/include/omc/ntpServer.h =================================================================== --- cmpibase/trunk/src/include/omc/ntpServer.h (rev 0) +++ cmpibase/trunk/src/include/omc/ntpServer.h 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,58 @@ +/******************************************************************************* +* Copyright (C) 2005, 2006 Novell, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell, Inc. nor the names of its +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* Author: Norm Paxton (np...@no...) +******************************************************************************/ +#ifndef NTP_SERVER_UTILS_H_GUARD__ +#define NTP_SERVER_UTILS_H_GUARD__ + + +#define NTP_SERVER_NAME_LEN 256 + +typedef struct +{ + char serverName[NTP_SERVER_NAME_LEN]; + int prefer; + int key; + int ntpVersion; + int minPoll; + int maxPoll; +} NTPServer; + + +NTPServer *getNTPServers(int *pCount); +int getNTPServer(const char *serverName, NTPServer *out); +int deleteNTPServer(const char *serverName); +int setNTPServer(NTPServer *server); +void copyNTPServer(const NTPServer *in, NTPServer *out); +NTPServer *createAndCopyNTPServer(const NTPServer *in); + + +#endif // NTP_SERVER_UTILS_H_GUARD__ + Modified: cmpibase/trunk/src/lib/omc/Makefile.am =================================================================== --- cmpibase/trunk/src/lib/omc/Makefile.am 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/lib/omc/Makefile.am 2006-11-01 23:59:10 UTC (rev 12) @@ -16,12 +16,14 @@ ioUtils.c \ modifyFile.c \ string.c \ -linuxProcUtils.c +linuxProcUtils.c \ +ntpServer.c libomc_cmpi_la_LDFLAGS = -version-info 1 libomc_cmpi_la_SOURCES = \ cmpiUtils.c \ -cmpiSimpleAssoc.c +cmpiSimpleAssoc.c \ +cmpiTimeServiceUtils.c Modified: cmpibase/trunk/src/lib/omc/base.c =================================================================== --- cmpibase/trunk/src/lib/omc/base.c 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/lib/omc/base.c 2006-11-01 23:59:10 UTC (rev 12) @@ -41,6 +41,19 @@ #include <sys/param.h> #include <sys/utsname.h> +#include <omc/exec.h> +#include <stdlib.h> + +#define LOCAL_DEBUG + +#ifdef LOCAL_DEBUG +#define DEBUGOUT(fmt, args...) printf(fmt,## args) +#else +#define DEBUGOUT(fmt, args...) +#endif + + + #define OSCLASSNAME "OMC_OperatingSystem" #define CSCLASSNAME "OMC_UnitaryComputerSystem" #define OSNAME "Linux" @@ -152,3 +165,64 @@ omcStrNCpy(hostNameOut, namebuf, hostNameOutLen); return hostNameOut; } + + +/*****************************************************************************/ +unsigned long long +omcGetRPMInstallDate(const char *rpmName) +{ + DEBUGOUT("Entering omcGetRPMInstallDate for rpmName: %s\n", rpmName); + + unsigned long rv = 0; + int status; + char *endptr, *output; + unsigned int outputSize; + + const char *cmd[6]; + + if (!rpmName || (*rpmName==0)) + { + DEBUGOUT(" returning - empty rpmName\n"); + return 0; + } + + cmd[0] = "/bin/rpm"; + cmd[1] = "-q"; + cmd[2] = "--queryformat"; + cmd[3] = "%{INSTALLTIME}"; + cmd[4] = rpmName; + cmd[5] = NULL; /* NULL termination */ + + output = NULL; + + char *errOutput = NULL; + unsigned long ulErrOutputSize = 0; + + if (omcExecuteProcessAndGatherOutputAndError((char* const*) cmd, NULL, &output, + &outputSize, -1, &errOutput, &ulErrOutputSize, -1, NULL, &status, -1) == 0) + { + DEBUGOUT(" execute returned status: %d outputSize: %d\n output: %s\n", status, outputSize, output); + if (status == 0) + { + rv = strtoul(output, &endptr, 10); + if (endptr == output || *endptr) + { + rv = 0; + } + free(output); + return (1000000 * (unsigned long long)rv); + } + else + { + DEBUGOUT(" received error: %s\n", errOutput); + } + } + if (output) + { + free(output); + } + + return 0; +} + + Modified: cmpibase/trunk/src/lib/omc/cmpiSimpleAssoc.c =================================================================== --- cmpibase/trunk/src/lib/omc/cmpiSimpleAssoc.c 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/lib/omc/cmpiSimpleAssoc.c 2006-11-01 23:59:10 UTC (rev 12) @@ -40,7 +40,7 @@ #include <stdio.h> -#define LOCAL_DEBUG +//#define LOCAL_DEBUG #ifdef LOCAL_DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) Added: cmpibase/trunk/src/lib/omc/cmpiTimeServiceUtils.c =================================================================== --- cmpibase/trunk/src/lib/omc/cmpiTimeServiceUtils.c (rev 0) +++ cmpibase/trunk/src/lib/omc/cmpiTimeServiceUtils.c 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,344 @@ +/******************************************************************************* +* Copyright (C) 2005, 2006 Novell, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell, Inc. nor the names of its +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* Author: Norm Paxton (np...@no...) +******************************************************************************/ + +#include <omc/cmpiTimeServiceUtils.h> +#include <omc/ntpServer.h> +#include <fnmatch.h> +#include <ctype.h> + +#define LOCAL_DEBUG + +#ifdef LOCAL_DEBUG +#define DEBUGOUT(fmt, args...) printf(fmt,## args) +#else +#define DEBUGOUT(fmt, args...) +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +// NULL terminated list of key property names for this class +static const char * systemTimeServiceClassKeys[] = { + "SystemCreationClassName", + "SystemName", + "CreationClassName", + "Name", + NULL}; + + +static const char * remoteTimeServicePortClassKeys[] = { + "SystemCreationClassName", + "SystemName", + "CreationClassName", + "Name", + NULL}; + + +/*****************************************************************************/ +CMPIObjectPath * +makeTimeServiceObjectPath( + const CMPIBroker *broker, + const char *ns, + CMPIStatus *pStatus) +{ + DEBUGOUT("EnumInstanceNames() called\n"); + + CMPIObjectPath *op = CMNewObjectPath(broker, ns, "OMC_SystemTimeService", pStatus); + if (!CMIsNullObject(op) && (pStatus->rc == CMPI_RC_OK)) + { + char name[128] = {0}; + omcGetComputerSystemName(name, sizeof(name)); + + CMAddKey(op, + "SystemCreationClassName", + (CMPIValue *)(char *)omcGetComputerSystemClassName(), + CMPI_chars); + CMAddKey(op, + "SystemName", + (CMPIValue *)&name, + CMPI_chars); + CMAddKey(op, + "CreationClassName", + (CMPIValue *)"OMC_SystemTimeService", + CMPI_chars); + CMAddKey(op, + "Name", + (CMPIValue *)"timeservice", + CMPI_chars); + } + return op; +} + + +/*****************************************************************************/ +CMPIInstance * +makeTimeServiceInstance( + const CMPIBroker *broker, + const char *ns, + CMPIStatus *pStatus, + const char **properties) +{ + CMPIInstance *instance = NULL; + CMPIObjectPath *op = makeTimeServiceObjectPath(broker, ns, pStatus); + if (!CMIsNullObject(op) && (pStatus->rc == CMPI_RC_OK)) + { + instance = CMNewInstance(broker, op, pStatus); + if (!CMIsNullObject(instance) && (pStatus->rc == CMPI_RC_OK)) + { + CMSetPropertyFilter(instance, properties, systemTimeServiceClassKeys); + // keys + char name[128] = {0}; + omcGetComputerSystemName(name, sizeof(name)); + + CMSetProperty(instance, + "SystemCreationClassName", + (CMPIValue *)(char *)omcGetComputerSystemClassName(), + CMPI_chars); + CMSetProperty(instance, + "SystemName", + (CMPIValue *)&name, + CMPI_chars); + CMSetProperty(instance, + "CreationClassName", + (CMPIValue *)"OMC_SystemTimeService", + CMPI_chars); + CMSetProperty(instance, + "Name", + (CMPIValue *)"timeservice", + CMPI_chars); + + unsigned int enabledState = 2; + CMSetProperty(instance, "EnabledState", (CMPIValue*)&enabledState, CMPI_uint16); + unsigned int requestedState = 12; + CMSetProperty(instance, "RequestedState", (CMPIValue*)&requestedState, CMPI_uint16); + unsigned int enabledDefault = 2; + CMSetProperty(instance, "EnabledDefault", (CMPIValue*)&enabledDefault, CMPI_uint16); + unsigned int started = 1; + CMSetProperty(instance, "Started", (CMPIValue*)&started, CMPI_boolean); + unsigned int healthState = 5; + CMSetProperty(instance, "HealthState", (CMPIValue*)&healthState, CMPI_uint16); + + CMPIDateTime *lastStateChange = CMNewDateTime(broker, NULL); + CMSetProperty(instance, "TimeOfLastStateChange", (CMPIValue*)&lastStateChange, CMPI_dateTime); + + + // TODO: Get the real one, move LinuxOS_get*** into common library? + // get from the linux os instance? + //CMPIDateTime *installDate = CMNewDateTimeFromBinary(broker, omcLinuxOS_getInstallDate(), 0, NULL); + CMPIDateTime *installDate = CMNewDateTime(broker, NULL); + CMSetProperty(instance, "InstallDate", (CMPIValue*)&installDate, CMPI_dateTime); + + CMSetProperty(instance, "Status", (CMPIValue*)"OK", CMPI_chars); + CMSetProperty(instance, "StartMode", (CMPIValue*)"Automatic", CMPI_chars); + + CMPIArray *pra = CMNewArray(broker, 1, CMPI_uint16, NULL); + if (!CMIsNullObject(pra)) + { + unsigned int opStatus = 2; + CMSetArrayElementAt(pra, 0, (CMPIValue*)&opStatus, CMPI_uint16); + CMSetProperty(instance, "OperationalStatus", (CMPIValue*)&pra, CMPI_uint16A); + } + } + } + return instance; +} + + + +/*****************************************************************************/ +CMPIObjectPath* +makeRemoteTimeServicePortObjectPath( + const CMPIBroker *broker, + const char *ns, + const char *serverName, + CMPIStatus *pStatus) +{ + CMPIObjectPath *op = CMNewObjectPath(broker, ns, "OMC_RemoteTimeServicePort", pStatus); + if (!CMIsNullObject(op) && (pStatus->rc == CMPI_RC_OK)) + { + char name[128] = {0}; + omcGetComputerSystemName(name, sizeof(name)); + + CMAddKey(op, + "SystemCreationClassName", + (CMPIValue *)(char *)omcGetComputerSystemClassName(), + CMPI_chars); + CMAddKey(op, + "SystemName", + (CMPIValue *)&name, + CMPI_chars); + CMAddKey(op, + "CreationClassName", + (CMPIValue *)"OMC_RemoteTimeServicePort", + CMPI_chars); + CMAddKey(op, + "Name", + (CMPIValue *)serverName, + CMPI_chars); + } + return op; +} + + +/*****************************************************************************/ +CMPIInstance * +makeRemoteTimeServicePortInstance( + const CMPIBroker *broker, + const char *ns, + const char *serverName, + CMPIStatus *pStatus, + const char **properties) +{ + CMPIInstance *instance = NULL; + CMPIObjectPath *op = makeRemoteTimeServicePortObjectPath(broker, ns, serverName, pStatus); + if (!CMIsNullObject(op) && (pStatus->rc == CMPI_RC_OK)) + { + NTPServer *server = malloc(sizeof(NTPServer)); + if (server) + { + getNTPServer(serverName, server); + instance = CMNewInstance(broker, op, pStatus); + if (!CMIsNullObject(instance) && (pStatus->rc == CMPI_RC_OK)) + { + CMSetPropertyFilter(instance, properties, remoteTimeServicePortClassKeys); + // keys + char name[128] = {0}; + omcGetComputerSystemName(name, sizeof(name)); + + CMSetProperty(instance, + "SystemCreationClassName", + (CMPIValue *)(char *)omcGetComputerSystemClassName(), + CMPI_chars); + CMSetProperty(instance, + "SystemName", + (CMPIValue *)&name, + CMPI_chars); + CMSetProperty(instance, + "CreationClassName", + (CMPIValue *)"OMC_RemoteTimeServicePort", + CMPI_chars); + CMSetProperty(instance, + "Name", + (CMPIValue *)serverName, + CMPI_chars); + + CMSetProperty(instance, + "AccessInfo", + (CMPIValue *)serverName, + CMPI_chars); + + int infoFmt = (isIPV4Address(serverName)) ? 3 : 2; + CMSetProperty(instance, "InfoFormat", (CMPIValue*)&infoFmt, CMPI_uint16); + + unsigned int enabledState = 2; + CMSetProperty(instance, "EnabledState", (CMPIValue*)&enabledState, CMPI_uint16); + + unsigned int requestedState = 12; + CMSetProperty(instance, "RequestedState", (CMPIValue*)&requestedState, CMPI_uint16); + + unsigned int enabledDefault = 2; + CMSetProperty(instance, "EnabledDefault", (CMPIValue*)&enabledDefault, CMPI_uint16); + + unsigned int started = 1; + CMSetProperty(instance, "Started", (CMPIValue*)&started, CMPI_boolean); + + unsigned int healthState = 5; + CMSetProperty(instance, "HealthState", (CMPIValue*)&healthState, CMPI_uint16); + + CMPIDateTime *lastStateChange = CMNewDateTime(broker, NULL); + CMSetProperty(instance, "TimeOfLastStateChange", (CMPIValue*)&lastStateChange, CMPI_dateTime); + + + // TODO: Get the real one, move LinuxOS_get*** into common library? + // get from the linux os instance? + //CMPIDateTime *installDate = CMNewDateTimeFromBinary(broker, omcLinuxOS_getInstallDate(), 0, NULL); + CMPIDateTime *installDate = CMNewDateTime(broker, NULL); + CMSetProperty(instance, "InstallDate", (CMPIValue*)&installDate, CMPI_dateTime); + + CMSetProperty(instance, "Status", (CMPIValue*)"OK", CMPI_chars); + CMSetProperty(instance, "StartMode", (CMPIValue*)"Automatic", CMPI_chars); + + CMPIArray *pra = CMNewArray(broker, 1, CMPI_uint16, NULL); + if (!CMIsNullObject(pra)) + { + unsigned int opStatus = 2; + CMSetArrayElementAt(pra, 0, (CMPIValue*)&opStatus, CMPI_uint16); + CMSetProperty(instance, "OperationalStatus", (CMPIValue*)&pra, CMPI_uint16A); + } + + unsigned int portProtocol = 2; + CMSetProperty(instance, "PortProtocol", (CMPIValue*)&portProtocol, CMPI_uint16); + + CMPIBoolean prefer = 0; + prefer = (CMPIBoolean)(server->prefer); + CMSetProperty(instance, "Prefer", (CMPIValue*)&prefer, CMPI_boolean); + + if(server->key) + CMSetProperty(instance, "key", (CMPIValue*)&(server->key), CMPI_uint16); + if(server->ntpVersion) + CMSetProperty(instance, "ntpversion", (CMPIValue*)&(server->ntpVersion), CMPI_uint16); + if(server->minPoll) + CMSetProperty(instance, "minpoll", (CMPIValue*)&(server->minPoll), CMPI_uint16); + if(server->maxPoll) + CMSetProperty(instance, "maxpoll", (CMPIValue*)&(server->maxPoll), CMPI_uint16); + } + } + } + return instance; +} + + + +/*****************************************************************************/ +int +isIPV4Address(const char *arg) +{ + const char *p = arg; + if(fnmatch("*.*.*.*", p, 0) != 0) + { + return 0; + } + + for(; *p; p++) + { + if(*p != '.' && !isdigit(*p)) + { + return 0; + } + } + + return 1; +} + Modified: cmpibase/trunk/src/lib/omc/cmpiUtils.c =================================================================== --- cmpibase/trunk/src/lib/omc/cmpiUtils.c 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/lib/omc/cmpiUtils.c 2006-11-01 23:59:10 UTC (rev 12) @@ -40,7 +40,7 @@ #include <cmpift.h> #include <cmpimacs.h> -#define LOCAL_DEBUG +//#define LOCAL_DEBUG #ifdef LOCAL_DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) Added: cmpibase/trunk/src/lib/omc/ntpServer.c =================================================================== --- cmpibase/trunk/src/lib/omc/ntpServer.c (rev 0) +++ cmpibase/trunk/src/lib/omc/ntpServer.c 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,363 @@ +/******************************************************************************* +* Copyright (C) 2005, 2006 Novell, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell, Inc. nor the names of its +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* Author: Norm Paxton (np...@no...) +******************************************************************************/ + +#include <omc/ntpServer.h> +#include <omc/ioUtils.h> +#include <omc/string.h> + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> + +#define LOCAL_DEBUG + +#ifdef LOCAL_DEBUG +#define DEBUGOUT(fmt, args...) printf(fmt,## args) +#else +#define DEBUGOUT(fmt, args...) +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + + +char * +lineFromServer( + NTPServer *pServer) +{ + char *line = (char *)malloc(256); + char temp[16] = {0}; + + if (line) + { + omcStrAppend(line, "server ", 256); + omcStrAppend(line, pServer->serverName, 256); + + if(pServer->prefer) + { + omcStrAppend(line, " prefer", 256); + } + if(pServer->key) + { + omcStrAppend(line, " key ", 256); + sprintf(temp, "%ul", pServer->key); + omcStrAppend(line, temp, 256); + } + if(pServer->ntpVersion) + { + omcStrAppend(line, " version ", 256); + sprintf(temp, "%ul", pServer->ntpVersion); + omcStrAppend(line, temp, 256); + } + if(pServer->minPoll) + { + omcStrAppend(line, " minpoll ", 256); + sprintf(temp, "%ul", pServer->minPoll); + omcStrAppend(line, temp, 256); + } + if(pServer->maxPoll) + { + omcStrAppend(line, " maxpoll ", 256); + sprintf(temp, "%ul", pServer->maxPoll); + omcStrAppend(line, temp, 256); + } + } + + DEBUGOUT(" lineFromServer returning: %s\n", line); + return line; +} + + +static void +serverFromLine( + const char *line, + NTPServer *pServer) +{ + if (!pServer) + return; + + DEBUGOUT(" into serverFromLine with line: %s\n", line); + + unsigned int i = 0; + unsigned int iTokenCount = 0; + char** tokens = omcStrTokenize(line, " ,", &iTokenCount); + + for(i = 0; i < iTokenCount; i++) + { + DEBUGOUT(" token: %d: %s\n", i, tokens[i]); + } + + if(iTokenCount > 1) + { + // strip serverName... including # from end + strncpy(pServer->serverName, tokens[1], NTP_SERVER_NAME_LEN); + while(pServer->serverName[strlen(pServer->serverName)-1]=='#') + { + pServer->serverName[strlen(pServer->serverName)-1]='\0'; + } + omcStrRTrim(pServer->serverName); + if(iTokenCount > 2) + { + for(i = 2; i < iTokenCount; i++) + { + if(strcasecmp(tokens[i],"prefer") == 0) + { + pServer->prefer = 1; + continue; + } + if(i < iTokenCount-1) + { + if(strcasecmp(tokens[i],"key") == 0) + { + i++; + pServer->key = (unsigned long)atol(tokens[i]); + } + else if(strcasecmp(tokens[i],"version") == 0) + { + i++; + pServer->ntpVersion = (unsigned long)atol(tokens[i]); + } + else if(strcasecmp(tokens[i],"mode") == 0) + { + i++; + // Ignore + } + else if(strcasecmp(tokens[i],"minpoll") == 0) + { + i++; + pServer->minPoll = (unsigned long)atol(tokens[i]); + } + else if(strcasecmp(tokens[i],"maxpoll") == 0) + { + i++; + pServer->maxPoll = (unsigned long)atol(tokens[i]); + } + } + } + } + } +} + + +/****************************************************************************/ +static int +errCond( + char* errMsgBfr, + unsigned int errMsgBfrLen, + int cc, + const char* fmt, + ...) +{ + va_list ap; + + if (!errMsgBfr || !errMsgBfrLen) { + return cc; + } + + va_start(ap, fmt); + vsnprintf(errMsgBfr, errMsgBfrLen, fmt, ap); + va_end(ap); + return cc; +} + + + +/*****************************************************************************/ +NTPServer *getNTPServers(int *pCount) +{ + FILE *file; + unsigned int bfrLen = 0; + char *p = NULL, *bufPtr = NULL; + NTPServer server = {{0},0,0,0,0}; + char* errMsgBfr = NULL; + unsigned int errMsgBfrLen = 0; + int i=0; + int iCount = 0; + + DEBUGOUT("Entering getNTPServers\n"); + + if (!pCount) + { + return 0; + } + + file = fopen("/etc/ntp.conf", "r"); + if (!file) + { + errCond(errMsgBfr, errMsgBfrLen, -1, + "Failed to open file /etc/ntp.conf"); + return NULL; + } + + for(p = omcReadLine(file, &bufPtr, &bfrLen); p; + p = omcReadLine(file, &bufPtr, &bfrLen)) + { + DEBUGOUT(" got line: %s\n", bufPtr); + + if (omcStrStartsWith(p, "server")) + { + iCount++; + } + } + + *pCount = iCount; + DEBUGOUT(" malloc'ing for %d servers in ra\n", iCount); + NTPServer *ra = (NTPServer*)malloc(iCount * sizeof(NTPServer)); + + // reset file pointer + rewind(file); + + i = 0; + for(p = omcReadLine(file, &bufPtr, &bfrLen); p; + p = omcReadLine(file, &bufPtr, &bfrLen)) + { + DEBUGOUT(" got line: %s\n", bufPtr); + + if (omcStrStartsWith(p, "server")) + { + serverFromLine(p, &server); + DEBUGOUT(" Resulted in NTPServer in list: serverName: %s\n", server.serverName); + copyNTPServer(&server, &ra[i]); + + DEBUGOUT(" Adding NTPServer: %s\n", ra[i].serverName); + i++; + } + } + + fclose(file); + + if (bufPtr) + free(bufPtr); + + return ra; +} + + +/*****************************************************************************/ +int getNTPServer(const char *serverName, NTPServer *out) +{ + FILE *file; + unsigned int bfrLen = 0; + char *p, *bufPtr = NULL; + NTPServer server = {{0},0,0,0,0}; + char* errMsgBfr = NULL; + unsigned int errMsgBfrLen = 0; + + if (!serverName || !out) + { + return 0; + } + + file = fopen("/etc/ntp.conf", "r"); + if (!file) + { + return errCond(errMsgBfr, errMsgBfrLen, -1, + "Failed to open file /etc/ntp.conf"); + } + + for(p = omcReadLine(file, &bufPtr, &bfrLen); p; + p = omcReadLine(file, &bufPtr, &bfrLen)) + { + if (omcStrStartsWith(p, "server")) + { + serverFromLine(p, &server); + if(strcasecmp(server.serverName, serverName) == 0) + { + copyNTPServer(&server, out); + return 1; + } + } + } + + return 0; +} + + +/*****************************************************************************/ +int deleteNTPServer(const char *serverName) +{ + /* + DeleteServerListener dsl(serverName); + OMC::FileModifier fm("/etc/ntp.conf", &dsl); + String errMsg; + bool modified; + return fm.processFile(modified, errMsg); + */ + return 0; +} + + +/*****************************************************************************/ +int setNTPServer(NTPServer *server) +{ + /* + SetServerListener ssl(server); + OMC::FileModifier fm("/etc/ntp.conf", &ssl); + String errMsg; + bool modified; + return fm.processFile(modified, errMsg); + */ + return 0; +} + + +/*****************************************************************************/ +void copyNTPServer(const NTPServer *in, NTPServer *out) +{ + if (in && out) + { + strncpy(out->serverName, in->serverName, NTP_SERVER_NAME_LEN); + out->prefer = in->prefer; + out->key = in->key; + out->ntpVersion = in->ntpVersion; + out->minPoll = in->minPoll; + out->maxPoll = in->maxPoll; + } +} + + +/*****************************************************************************/ +NTPServer *createAndCopyNTPServer(const NTPServer* in) +{ + if (!in) + return NULL; + NTPServer *out = (NTPServer *)malloc(sizeof(NTPServer)); + if (out) + { + copyNTPServer(in, out); + } + return out; +} + Modified: cmpibase/trunk/src/providers/Makefile.am =================================================================== --- cmpibase/trunk/src/providers/Makefile.am 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/providers/Makefile.am 2006-11-01 23:59:10 UTC (rev 12) @@ -3,5 +3,6 @@ SUBDIRS = \ processes \ computer-system \ - operating-system + operating-system \ + time-service Modified: cmpibase/trunk/src/providers/computer-system/computerSystemHostNameSettingData.c =================================================================== --- cmpibase/trunk/src/providers/computer-system/computerSystemHostNameSettingData.c 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/providers/computer-system/computerSystemHostNameSettingData.c 2006-11-01 23:59:10 UTC (rev 12) @@ -41,7 +41,7 @@ #include <stdlib.h> #include <string.h> -#define LOCAL_DEBUG +//#define LOCAL_DEBUG #ifdef LOCAL_DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) Added: cmpibase/trunk/src/providers/computer-system/mof/ComputerSystemProviderReg.mof =================================================================== --- cmpibase/trunk/src/providers/computer-system/mof/ComputerSystemProviderReg.mof (rev 0) +++ cmpibase/trunk/src/providers/computer-system/mof/ComputerSystemProviderReg.mof 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,85 @@ + +instance of PG_ProviderModule +{ + Name = "OMC_CS_HostNameSettingData_Module"; + Location = "omccmpi_cshostnamesettingdata"; + Vendor = "SBLIM"; + Version = "2.0.0"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; +}; + +instance of PG_ProviderModule +{ + Name = "OMC_HostNameSettingData_Module"; + Location = "omccmpi_hostnamesettingdata"; + Vendor = "SBLIM"; + Version = "2.0.0"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; +}; + +instance of PG_ProviderModule +{ + Name = "OMC_UnitaryComputerSystem_Module"; + Location = "omccmpi_computer_system"; + Vendor = "SBLIM"; + Version = "2.0.0"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; +}; + +instance of PG_Provider +{ + Name = "OMC_CS_HostNameSettingData_Provider"; + ProviderModuleName = "OMC_CS_HostNameSettingData_Module"; +}; + +instance of PG_Provider +{ + Name = "OMC_HostNameSettingData_Provider"; + ProviderModuleName = "OMC_HostNameSettingData_Module"; +}; + +instance of PG_Provider +{ + Name = "OMC_UnitaryComputerSystem_Provider"; + ProviderModuleName = "OMC_UnitaryComputerSystem_Module"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "OMC_UnitaryComputerSystem_Module"; + ProviderName = "OMC_UnitaryComputerSystem_Provider"; + ClassName = "OMC_UnitaryComputerSystem"; + ProviderType = { 2 }; + Namespaces = {"smash"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "OMC_UnitaryComputerSystem-1"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "OMC_HostNameSettingData_Module"; + ProviderName = "OMC_HostNameSettingData_Provider"; + ClassName = "OMC_HostNameSettingData"; + ProviderType = { 2, 5 }; + Namespaces = {"smash"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "OMC_HostNameSettingData-2"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "OMC_CS_HostNameSettingData_Module"; + ProviderName = "OMC_CS_HostNameSettingData_Provider"; + ClassName = "OMC_ComputerSystemHostNameSettingData"; + ProviderType = { 2, 3 }; + Namespaces = {"smash"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "OMC_ComputerSystemHostNameSettingData-3"; +}; + Modified: cmpibase/trunk/src/providers/template/cmpi-providerTemplate.c =================================================================== --- cmpibase/trunk/src/providers/template/cmpi-providerTemplate.c 2006-11-01 20:01:25 UTC (rev 11) +++ cmpibase/trunk/src/providers/template/cmpi-providerTemplate.c 2006-11-01 23:59:10 UTC (rev 12) @@ -1,12 +1,46 @@ -// place copyright notice here +/******************************************************************************* +* Copyright (C) 2005, 2006 Novell, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell, Inc. nor the names of its +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* Author: Joe Smith (ab...@do...) +******************************************************************************/ -#include "cmpidt.h" -#include "cmpift.h" -#include "cmpimacs.h" +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> +#include <omc/base.h> +#include <omc/cmpiUtils.h> +#include <omc/cmpiSimpleAssoc.h> +#include <omc/string.h> // NULL terminated list of key property names for this class -static char * classKeys[] = {"FooKey", NULL}; +static char * classKeys[] = {"FooKey1", "FooKey2", NULL}; #ifdef DEBUG #define DEBUGOUT(fmt, args...) printf(fmt,## args) @@ -17,7 +51,7 @@ // Global handle to the CIM broker // This is initialized by the CIMOM when the provider is loaded -static CMPIBroker * _broker; +static const CMPIBroker * _broker; // **************************************************************************** @@ -284,39 +318,34 @@ // **************************************************************************** - -// **************************************************************************** -// associatorsHelper() -// params: CMPIAssociationMI* self: [in] Handle to this provider -// CMPIContext* context: [in] any additional context info -// CMPIResult* results: [out] Results -// CMPIObjectPath* cop: [in] target namespace and classname, and desired objectpath -// char *assocClass -// char *resultClass -// char *role -// char *resultRole -// char **properties -// int namesOnly -// **************************************************************************** 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 CMPIStatus associatorsHelper( CMPIAssociationMI* self, - const CMPIContext* context, - const CMPIResult* results, - const CMPIObjectPath* cop, - const char *assocClass, - const char *resultClass, - const char *role, - const char *resultRole, - const char** properties, - int namesOnly, - int refs ) +// **************************************************************************** +// doReferences() +// This is the callback called from the SimpleAssociators helper functions +// It "handles" one or more instances of the association class +// to be filtered by the SimpleAssociatior helper functions to return +// the correct object (instance or object path) +// **************************************************************************** +CMPIStatus +doReferences( + omccmpiSimpleAssocCtx ctx, + CMPIAssociationMI* self, + const CMPIBroker *broker, + const CMPIContext* context, + const CMPIResult* results, + const CMPIObjectPath* cop, + const char *assocClass, + const char *resultClass, + const char *role, + const char *resultRole, + const char** properties) { - DEBUGOUT("associatorsHelper: namesOnly: %d refs: %d\n", namesOnly, refs); + DEBUGOUT("doReferences called\n"); CMPIStatus status = {CMPI_RC_OK, NULL}; char * ns = CMGetCharPtr(CMGetNameSpace(cop, NULL)); @@ -327,184 +356,129 @@ if(strcasecmp(objClassName, LEFT_CLASSNAME) == 0) { - // this is a <LEFT_CLASSNAME>, returning a <RIGHT_CLASSNAME> - //DEBUGOUT("ResultClass: %s\n", resultClass?resultClass:"<empty>"); + // this is a LEFT_CLASSNAME + // need to get approprate RIGHT_CLASSNAME for ASSOC_CLASSNAME inst + // but if resultClass is set, it must match + + int bHaveMatch = 1; // TRUE if ((resultClass != NULL) && (*resultClass != 0)) { - //DEBUGOUT("Is resultClass (%s) a parent of %s?\n", resultClass, RIGHT_CLASSNAME); - if (!omccmpiClassIsDerivedFrom( RIGHT_CLASSNAME, - resultClass, - _broker, - ns )) + // check + if (!omccmpiClassIsDerivedFrom(RIGHT_CLASSNAME, + resultClass, + _broker,ns,&status)) { - goto exit; + bHaveMatch = 0; // FALSE } } - // TODO - - // check the incoming cop for anything to help determine results - // see example below for comparing incoming computerSystemName with - // 'this' computer system name - /* - 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 ((resultRole != NULL) && (*resultRole != 0)) { - // create the <right_classname> cop that I'll use below - CMPIObjectPath *rightcop = CMNewObjectPath(_broker, ns, RIGHT_CLASSNAME, &status); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(rightcop)) + // check + if (strcasecmp(resultRole, RIGHT_PROPERTYNAME) != 0) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create <RIGHT_CLASSNAME> object path"); - goto exit; + bHaveMatch = 0; // FALSE } - else - { - // add keys to the RIGHT_ object class - /* - char instanceID[] = "omc:computername"; - CMAddKey(rightcop, "InstanceID", (CMPIValue *)instanceID, CMPI_chars); - */ - } + } - // Create and populate results - if (namesOnly) - { - if (refs) - { - // create an association object path with the <rightcop> - DEBUGOUT("associatorsHelper: creating association path: %s\n", ""); - CMPIObjectPath *assocCop = omccmpiCreateAssociationPath(_broker, - ns, - ASSOC_CLASSNAME, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cop, // cop sent in - rightcop ); - CMReturnObjectPath(results, assocCop); - } - else - { - // return the <rightcop> - CMReturnObjectPath(results, rightcop); - } - } - else - { - if (refs) - { - // create an association instance with the <rightcop> - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - cop, - rightcop ); - CMReturnInstance(results, assocInst); - } - else - { - // return the instance from <rightcop> - CMPIInstance *rightInst = CBGetInstance(_broker, context, rightcop, properties, &status); - CMReturnInstance(results, rightInst); - } - } + if (bHaveMatch) + { + // do work here: + // create and return the appropriate association instance(s) + // + // loop, if necesssary + // do appropriate checks + + // the left cop was passed in + CMPIObjectPath *leftCop = cop; + + // get or create right side object path + CMPIObjectPath *rightCop = CMNewObjectPath(_broker, ns, RIGHT_CLASSNAME, &status); + // add keys + + + // create association instance + CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + ns, + ASSOC_CLASSNAME, + classKeys, + properties, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + leftCop, + rightCop, + &status); + // "handle" the association + omccmpiSimpleAssocResults(ctx, assocInst, &status); } } else if(strcmp(objClassName, RIGHT_CLASSNAME) == 0) { - // this is a <RIGHT_CLASSNAME>, returning a <LEFT_CLASSNAME> - //DEBUGOUT("ResultClass: %s\n", resultClass?resultClass:"<empty>"); + // this is a RIGHT_CLASSNAME + // need to get approprate LEFT_CLASSNAME for ASSOC_CLASSNAME inst + // but if resultClass is set, it must match + + int bHaveMatch = 1; // TRUE if ((resultClass != NULL) && (*resultClass != 0)) { - //DEBUGOUT("Is resultClass (%s) a parent of %s?\n", resultClass, LEFT_CLASSNAME); - if (!omccmpiClassIsDerivedFrom( LEFT_CLASSNAME, - resultClass, - _broker, - ns )) + // check + if (!omccmpiClassIsDerivedFrom(LEFT_CLASSNAME, + resultClass, + _broker,ns,&status)) { - goto exit; + bHaveMatch = 0; // FALSE } } - // TODO - - // check the incoming cop for anything to help determine results - // see example below for comparing incoming computerSystemName with - // 'this' computer system name - /* - CMPIData data = CMGetKey(cop, "InstanceID", &status); - char *inName = CMGetCharPtr(data.value.string); - DEBUGOUT("comparing inName (%s) with name (%s)\n", inName, "omc:computername"); - if (strcasecmp(inName, "omc:computername") == 0) - */ + if ((resultRole != NULL) && (*resultRole != 0)) { - // create the <left_classname> cop that I'll use below - CMPIObjectPath *leftcop = omccmpiCreateCSObjectPath( _broker, ns); - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(leftcop)) + // check + if (strcasecmp(resultRole, LEFT_PROPERTYNAME) != 0) { - CMSetStatusWithChars(_broker, &status, CMPI_RC_ERR_FAILED, - "Could not create <left_classname> cop"); - goto exit; + bHaveMatch = 0; // FALSE } + } - // create and populate results - if (namesOnly) - { - if (refs) - { - // create an association object path with the <leftcop> - CMPIObjectPath *assocCop = omccmpiCreateAssociationPath(_broker, - ns, - ASSOC_CLASSNAME, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - leftcop, - cop ); - CMReturnObjectPath(results, assocCop); - } - else - { - // return the <leftcop> - CMReturnObjectPath(results, leftcop); - } - } - else - { - if (refs) - { - // create an association instance with the <leftcop> - CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, - ns, - ASSOC_CLASSNAME, - LEFT_PROPERTYNAME, - RIGHT_PROPERTYNAME, - leftcop, - cop ); - CMReturnInstance(results, assocInst); - } - else - { - // return the instance from <leftcop> - CMPIInstance *rightInst = CBGetInstance(_broker, context, rightcop, properties, &status); - CMReturnInstance(results, rightInst); - } - } + if (bHaveMatch) + { + // do work here: + // create and return the appropriate association instance(s) + // + // loop, if necesssary + // do appropriate checks + + // get or create left side object path + CMPIObjectPath *leftCop = CMNewObjectPath(_broker, ns, LEFT_CLASSNAME, &status); + // add keys + + // the right cop was passed in + CMPIObjectPath *rightCop = cop; + + + // create association instance + CMPIInstance *assocInst = omccmpiCreateAssociationInst(_broker, + ns, + ASSOC_CLASSNAME, + classKeys, + properties, + LEFT_PROPERTYNAME, + RIGHT_PROPERTYNAME, + leftCop, + rightCop, + &status); + // "handle" the association + omccmpiSimpleAssocResults(ctx, assocInst, &status); } } else { - DEBUGOUT("!!! Object type unknown: %s\n", objsClassName); + DEBUGOUT("!!! Object type unknown: %s\n", objClassName); } } -exit: + //close return handler + CMReturnDone(results); + + DEBUGOUT("Leaving doReferences\n"); return status; } @@ -574,19 +548,10 @@ DEBUGOUT("Associators() called"); - CMPIStatus status = associatorsHelper( self, - context, - results, - cop, - assocClass, - resultClass, - role, - resultRole, - properties, - 0, // not names only - 0 ); // not ref + CMPIStatus status = omccmpiSimpleAssociators( doReferences, self, + _broker, context, results, cop, assocClass, + resultClass, role, resultRole, properties); -exit: DEBUGOUT("Leaving Associatiors(): %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -616,19 +581,10 @@ DEBUGOUT("AssociatorNames() called"); - CMPIStatus status = associatorsHelper( self, - context, - results, - cop, - assocClass, - resultClass, - role, - resultRole, - properties, - 1, // names only - 0 ); // not ref + CMPIStatus status = omccmpiSimpleAssociatorNames( doReferences, self, + _broker, context, results, cop, assocClass, + resultClass, role, resultRole); -exit: DEBUGOUT("Leaving AssociatiorNames(): %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -656,19 +612,10 @@ DEBUGOUT("References() called"); - CMPIStatus status = associatorsHelper( self, - context, - results, - cop, - resultClass, - NULL, - role, - NULL, - properties, - 0, // not names only - 1 ); // refs + CMPIStatus status = omccmpiSimpleReferences( doReferences, self, + _broker, context, results, cop, NULL, + resultClass, role, NULL, properties); -exit: DEBUGOUT("Leaving References(): %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } @@ -694,19 +641,10 @@ DEBUGOUT("ReferenceNames() called"); - CMPIStatus status = associatorsHelper( self, - context, - results, - cop, - resultClass, - NULL, - role, - NULL, - properties, - 1, // names only - 1 ); // refs + CMPIStatus status = omccmpiSimpleReferenceNames( doReferences, self, + _broker, context, results, cop, NULL, + resultClass, role, NULL); -exit: DEBUGOUT("Leaving ReferenceNames(): %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"); return status; } Added: cmpibase/trunk/src/providers/time-service/Makefile.am =================================================================== --- cmpibase/trunk/src/providers/time-service/Makefile.am (rev 0) +++ cmpibase/trunk/src/providers/time-service/Makefile.am 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,96 @@ +include $(top_srcdir)/Makefile.incl.am + +provider_LTLIBRARIES = libomccmpi_systemTimeService.la \ + libomccmpi_remoteTimeServicePort.la +# libomccmpi_hostedTimeService.la \ +# libomccmpi_timeServiceAccessBySAP.la \ +# libomccmpi_timeServiceAvailableToElement.la \ +# libomccmpi_timeServiceTimeZoneSettingData.la \ +# libomccmpi_timeZoneSettingData.la + + +INCLUDES = -I$(top_srcdir)/src/include + +libomccmpi_systemTimeService_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +libomccmpi_systemTimeService_la_SOURCES = \ + systemTimeService.c + +libomccmpi_systemTimeService_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +libomccmpi_remoteTimeServicePort_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +libomccmpi_remoteTimeServicePort_la_SOURCES = \ + remoteTimeServicePort.c + +libomccmpi_remoteTimeServicePort_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +#libomccmpi_hostedTimeService_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +#libomccmpi_hostedTimeService_la_SOURCES = \ + hostedTimeService.c + +#libomccmpi_hostedTimeService_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +#libomccmpi_timeServiceAccessBySAP_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +#libomccmpi_timeServiceAccessBySAP_la_SOURCES = \ + timeServiceAccessBySAP.c + +#libomccmpi_timeServiceAccessBySAP_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +#libomccmpi_timeServiceAvailableToElement_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +#libomccmpi_timeServiceAvailableToElement_la_SOURCES = \ + timeServiceAvailableToElement.c + +#libomccmpi_timeServiceAvailableToElement_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +#libomccmpi_timeServiceTimeZoneSettingData_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +#libomccmpi_timeServiceTimeZoneSettingData_la_SOURCES = \ + timeServiceTimeZoneSettingData.c + +#libomccmpi_timeServiceTimeZoneSettingData_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + + +#libomccmpi_timeZoneSettingData_la_LIBADD = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la + +#libomccmpi_timeZoneSettingData_la_SOURCES = \ + timeZoneSettingData.c + +#libomccmpi_timeZoneSettingData_la_LDFLAGS = \ + -lpthread \ + -version-info 1 + Added: cmpibase/trunk/src/providers/time-service/Makefile.in =================================================================== --- cmpibase/trunk/src/providers/time-service/Makefile.in (rev 0) +++ cmpibase/trunk/src/providers/time-service/Makefile.in 2006-11-01 23:59:10 UTC (rev 12) @@ -0,0 +1,566 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# *********************************************************************** +# MACROS and VARIABLES +# *********************************************************************** + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.incl.am +subdir = src/providers/time-service +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(providerdir)" +providerLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(provider_LTLIBRARIES) +libomccmpi_remoteTimeServicePort_la_DEPENDENCIES = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(top_builddir)/src/lib/omc/libomc_cbase.la +am_libomccmpi_remoteTimeServicePort_la_OBJECTS = \ + remoteTimeServicePort.lo +libomccmpi_remoteTimeServicePort_la_OBJECTS = \ + $(am_libomccmpi_remoteTimeServicePort_la_OBJECTS) +libomccmpi_systemTimeService_la_DEPENDENCIES = \ + $(top_builddir)/src/lib/omc/libomc_cmpi.la \ + $(to... [truncated message content] |