--- 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 " <