tog-pegasus/pegasus-2.5.1-obz4955.patch

606 lines
20 KiB
Diff
Raw Normal View History

--- pegasus/src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp.obz4955 2006-01-30 11:18:48.000000000 -0500
+++ pegasus/src/Providers/ManagedSystem/OperatingSystem/OperatingSystem_Linux.cpp 2006-05-02 14:43:14.000000000 -0400
@@ -96,59 +96,75 @@
/**
- getName method of the Linux implementation for the OS Provider
-
- Calls uname() to get the operating system name.
+ getVendorInfo method for Linux implementation of OS Provider
+ Gets the system text from vendor's release file
*/
-Boolean OperatingSystem::getName(String& osName)
+static void getVendorInfo(
+ String& releaseText,
+ String& nameText )
{
- String s, buffer_s;
- Uint32 buffer_index; // rexex match index
+ static const Uint32 MAX_RELEASE_STRING_LEN=128;
char info_file[MAXPATHLEN];
- char buffer[MAXPATHLEN];
+ char buffer[MAX_RELEASE_STRING_LEN];
struct stat statBuf;
- FILE *vf;
- s.clear();
+
for (int ii = 0; LINUX_VENDOR_INFO[ii].vendor_name != NULL ; ii++)
{
- memset(info_file, 0, MAXPATHLEN);
- strcat(info_file, "/etc/");
- strcat(info_file, LINUX_VENDOR_INFO[ii].determining_filename);
-
+ sprintf(info_file, "/etc/%s",
+ LINUX_VENDOR_INFO[ii].determining_filename );
// If the file exists in /etc, we know what distro we're in
if (!stat(info_file, &statBuf))
{
- s.assign(LINUX_VENDOR_INFO[ii].vendor_name);
- s.append(" Distribution");
+ // Set the default OS name
+ nameText.assign(LINUX_VENDOR_INFO[ii].vendor_name);
+ nameText.append(" Distribution");
if (LINUX_VENDOR_INFO[ii].optional_string == NULL)
{
- // try to set s to a more descript value from the etc file
- vf = fopen(info_file, "r");
+ // try to set text to a more descriptive value from the etc file
+ FILE *vf = fopen(info_file, "r");
if (vf)
{
- if (fgets(buffer, MAXPATHLEN, vf) != NULL)
- {
- buffer_s.assign(buffer);
-
- // parse the text to extract Distribution Name
- buffer_index = buffer_s.find(" release");
- if ( buffer_index != PEG_NOT_FOUND )
- {
- // then we have found a valid index into the config file
- s.assign(buffer_s.subString(0,buffer_index));
- }
+ if (fgets(buffer, MAX_RELEASE_STRING_LEN, vf) != NULL)
+ {
+ String buffer_s = buffer;
+
+ // parse the text to extract first line
+ Uint32 buffer_index = buffer_s.find( '\n' );
+ if ( buffer_index != PEG_NOT_FOUND )
+ {
+ // We have found a valid index into the
+ // release string. Now get just the OS name.
+ releaseText = buffer_s.subString(0,buffer_index);
+ buffer_index = releaseText.find( " release" );
+ if ( buffer_index != PEG_NOT_FOUND )
+ {
+ nameText.assign( releaseText.subString(0,buffer_index) );
+ }
+ }
}
fclose(vf);
}
}
+ break;
}
}
- osName.assign(s);
- return true;
+}
+
+/**
+ getName method of the Linux implementation for the OS Provider
+
+ Calls getVendorInfo() to get the operating system name.
+ */
+Boolean OperatingSystem::getName(String& osName)
+{
+ String releaseText;
+ getVendorInfo( releaseText, osName );
+
+ return true;
}
/**
@@ -204,23 +220,24 @@
/**
getCaption method for Linux implementation of OS Provider
- Uses a string constant for the Caption.
+ Gets the text from the system's release file.
*/
Boolean OperatingSystem::getCaption(String& caption)
{
-
- caption.assign("The current Operating System");
-
+ String osName;
+ getVendorInfo( caption, osName );
return true;
}
+/**
+ getDescription method for Linux implementation of OS Provider
+
+ Gets the text from the system's release file.
+ */
Boolean OperatingSystem::getDescription(String& description)
{
-
- description.assign("This instance reflects the Operating System"
- " on which the CIMOM is executing (as distinguished from instances"
- " of other installed operating systems that could be run).");
-
+ String osName;
+ getVendorInfo( description, osName );
return true;
}
--- pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient.cpp.obz4955 2006-01-30 11:18:49.000000000 -0500
+++ pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient.cpp 2006-05-02 14:45:05.000000000 -0400
@@ -61,6 +61,8 @@
# include "OSTestClient_VMS.cpp"
#elif defined (PEGASUS_OS_SOLARIS)
# include "OSTestClient_Solaris.cpp"
+#elif defined (PEGASUS_OS_LINUX)
+# include "OSTestClient_Linux.cpp"
# else
# include "OSTestClient_Stub.cpp"
#endif
--- pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient_Linux.cpp.obz4955 2006-05-02 14:46:08.000000000 -0400
+++ pegasus/src/Providers/ManagedSystem/OperatingSystem/tests/OSTestClient/OSTestClient_Linux.cpp 2006-05-02 14:38:31.000000000 -0400
@@ -0,0 +1,449 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; Symantec Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//==============================================================================
+//
+//
+//%/////////////////////////////////////////////////////////////////////////////
+
+
+// This file has the OS-specific routines that will be called to get
+// a validation of the CIM information vs. the current test system
+
+#include "OSTestClient.h"
+
+PEGASUS_USING_PEGASUS;
+PEGASUS_USING_STD;
+
+
+static const struct
+{
+ const char *vendor_name;
+ const char *determining_filename;
+ const char *optional_string;
+} LINUX_VENDOR_INFO[] = {
+ { "Caldera", "coas", "Caldera Linux" },
+ { "Corel", "environment.corel", "Corel Linux" },
+ { "Debian GNU/Linux", "debian_version", NULL },
+ { "Mandrake", "mandrake-release", NULL },
+ { "Red Hat", "redhat-release", NULL },
+ { "SuSE", "SuSE-release", NULL },
+ { "Turbolinux", "turbolinux-release", NULL },
+ { NULL, NULL, NULL }
+};
+
+
+/**
+ getVendorInfo method for Linux implementation of OS Provider
+
+ Gets the system text from vendor's release file
+ */
+static void getVendorInfo(
+ String& releaseText,
+ String& nameText )
+{
+ static const Uint32 MAX_RELEASE_STRING_LEN=128;
+ char info_file[MAXPATHLEN];
+ char buffer[MAX_RELEASE_STRING_LEN];
+ struct stat statBuf;
+
+
+ for (int ii = 0; LINUX_VENDOR_INFO[ii].vendor_name != NULL ; ii++)
+ {
+ sprintf(info_file, "/etc/%s",
+ LINUX_VENDOR_INFO[ii].determining_filename );
+
+ // If the file exists in /etc, we know what distro we're in
+ if (!stat(info_file, &statBuf))
+ {
+ // Set the default OS name
+ nameText.assign(LINUX_VENDOR_INFO[ii].vendor_name);
+ nameText.append(" Distribution");
+ if (LINUX_VENDOR_INFO[ii].optional_string == NULL)
+ {
+ // try to set text to a more descriptive value from the etc file
+ FILE *vf = fopen(info_file, "r");
+ if (vf)
+ {
+ if (fgets(buffer, MAX_RELEASE_STRING_LEN, vf) != NULL)
+ {
+ String buffer_s = buffer;
+
+ // parse the text to extract first line
+ Uint32 buffer_index = buffer_s.find( '\n' );
+ if ( buffer_index != PEG_NOT_FOUND )
+ {
+ // We have found a valid index into the
+ // release string. Now get just the OS name.
+ releaseText = buffer_s.subString(0,buffer_index);
+ buffer_index = releaseText.find( " release" );
+ if ( buffer_index != PEG_NOT_FOUND )
+ {
+ nameText.assign( releaseText.subString(0,buffer_index) );
+ }
+ }
+ }
+ fclose(vf);
+ }
+ }
+ break;
+ }
+ }
+}
+
+/**
+ goodCSCreationClassName method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if valid, else FALSE.
+ */
+Boolean OSTestClient::goodCSCreationClassName(const String &cs_ccn,
+ Boolean verbose)
+{
+ // This assumes the only right answer is CIM_UnitaryComputerSystem
+ // replace with approprate check for the given OS/Provider
+
+ if (verbose)
+ cout<<"Checking " <<cs_ccn<< " against CIM_UnitaryComputerSystem"<<endl;
+ return (String::equalNoCase(cs_ccn, "CIM_UnitaryComputerSystem"));
+}
+
+/*
+ GoodCSName method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodCSName(const String &csname, Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking " <<csname<< " against hostname " <<endl;
+ cout<<"- No check written for CSName " <<endl;
+
+ // always returns success; replace with appropriate OS/Provider code
+ return true;
+}
+
+/*
+ GoodCreationClassName method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodCreationClassName(const String &ccn,
+ Boolean verbose)
+{
+ // This assumes the only right answer is CIM_OperatingSystem
+ // replace with approprate check for the given OS/Provider
+
+ if (verbose)
+ cout<<"Checking " << ccn << " against CIM_OperatingSystem"<<endl;
+
+ return (String::equalNoCase(ccn, "CIM_OperatingSystem"));
+}
+
+/*
+ GoodName method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodName(const String &name, Boolean verbose)
+{
+ String releaseText, osName;
+
+ if (verbose)
+ cout<<"Checking " << name << " against OS name "<<endl;
+ getVendorInfo( releaseText, osName );
+ return (String::equal( name, osName ));
+}
+/* GoodCaption method for the OS Provider Test Client
+
+ Checks the specified value against the expected value
+ and returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodCaption(const String &cap,
+ Boolean verbose)
+{
+ String releaseText, osName;
+
+ // has check against standard caption
+ if (verbose)
+ cout<<"Checking Caption " << cap << endl;
+ getVendorInfo( releaseText, osName );
+ return (String::equal(cap, releaseText ) );
+}
+
+/*
+ GoodDescription method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodDescription(const String &desc,
+ Boolean verbose)
+{
+ String releaseText, osName;
+
+ // has check against standard description
+ if (verbose)
+ cout<<"Checking Description " << desc << endl;
+ getVendorInfo( releaseText, osName );
+ return (String::equal(desc, releaseText) );
+}
+
+/*
+ GoodInstallDate method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodInstallDate(const CIMDateTime &idate,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking InstallDate " << idate.toString() << endl;
+ cout<<"- No check written for InstallDate " << endl;
+ return true;
+}
+
+/*
+ GoodStatus method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodStatus(const String &stat,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking Status" << stat << endl;
+ cout<<"- No check written for Status " << endl;
+ return true;
+}
+
+/*
+ GoodOSType method for the OS Provider Test Client
+
+ Checks the specified value against the expected value and
+ returns TRUE if the same, else FALSE
+ */
+Boolean OSTestClient::goodOSType(const Uint16 &ostype,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking OSType " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodOtherTypeDescription(const String &otdesc,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking OtherTypeDescription " << otdesc << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodVersion(const String &version, Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking Version " << version << endl;
+ cout<<"- No check written for Version " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodLastBootUpTime(const CIMDateTime &btime,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking LastBootUpTime " << btime.toString() << endl;
+ cout<<"- No check written for LastBootUpTime " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodLocalDateTime(const CIMDateTime &ltime,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking LocalDateTime " << ltime.toString() << endl;
+ cout<<"- No check written for LocalDateTime " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodCurrentTimeZone(const Sint16 &tz, Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking CurrentTimeZone " << tz << endl;
+ cout<<"- No check written for CurrentTimeZone " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodNumberOfLicensedUsers(const Uint32 &nlusers,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking NumberOfLicensedUsers " << nlusers << endl;
+ cout<<"- No check written for NumberOfLicensedUsers " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodNumberOfUsers(const Uint32 &nusers,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking NumberOfUsers " << nusers << endl;
+ cout<<"- No check written for NumberOfUsers " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodNumberOfProcesses(const Uint32 &nprocs,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking NumberOfProcesses " << nprocs << endl;
+ cout<<"- No check written for NumberOfProcesses " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodMaxNumberOfProcesses(const Uint32 &maxprocs,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking MaxNumberOfProcs " << maxprocs << endl;
+ cout<<"- No check written for MaxNumberOfProcesses " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodTotalSwapSpaceSize(const Uint64 &totalswap,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking TotalSwapSpaceSize " << endl;
+ cout<<"- No check written for TotalSwapSpaceSize " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodTotalVirtualMemorySize(const Uint64 &totalvmem,
+ Boolean verbose)
+
+{
+ if (verbose)
+ cout<<"Checking TotalVirtualMemorySize " << endl;
+ cout<<"- No check written for TotalVirtualMemorySize" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodFreeVirtualMemory(const Uint64 &freevmem,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking FreeVirtualMemory " << endl;
+ cout<<"- No check written for FreeVirtualMemory" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodFreePhysicalMemory(const Uint64 &freepmem,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking FreePhysicalMemory " << endl;
+ cout<<"- No check written for FreePhysicalMemory" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodTotalVisibleMemorySize(const Uint64 &totalvmem,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking TotalVisibleMemorySize " << endl;
+ cout<<"- No check written for TotalVisibleMemorySize" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodSizeStoredInPagingFiles(const Uint64 &pgsize,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking SizeStoredInPagingFiles " << endl;
+ cout<<"- No check written for SizeStoredInPagingFiles" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodFreeSpaceInPagingFiles(const Uint64 &freepg,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking FreeSpaceInPagingFiles " << endl;
+ cout<<"- No check written for FreeSpaceInPagingFiles" << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodMaxProcessMemorySize(const Uint64 &maxpmem,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking MaxProcessMemSize " << endl;
+ cout<<"- No check written for MaxProcessMemSize " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodDistributed(const Boolean &distr,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking Distributed " << endl;
+ cout<<"- No check written for Distributed " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodMaxProcessesPerUser(const Uint32 &umaxproc,
+ Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking MaxProcsPerUser " << umaxproc << endl;
+ cout<<"- No check written for MaxProcsPerUser " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodOSCapability(const String &cap, Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking OSCapability " << cap << endl;
+ cout<<"- No check written for OSCapability " << endl;
+ return true;
+}
+
+Boolean OSTestClient::goodSystemUpTime(const Uint64 &uptime, Boolean verbose)
+{
+ if (verbose)
+ cout<<"Checking SystemUpTime " << endl;
+ cout<<"- No check written for SystemUpTime " << endl;
+ return true;
+}
+