⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimconfigcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    String    defaultValue  = String::EMPTY;    String    currentValue  = String::EMPTY;    String    plannedValue  = String::EMPTY;    String    pegasusHome   = String::EMPTY;    Boolean   gotCurrentValue = false;    Boolean   gotPlannedValue = false;#ifdef PEGASUS_OS_OS400    // disable standard output and standard error    if( _defaultQuietSet && (_operationType != OPERATION_TYPE_LIST) ){        freopen("/dev/null","w",stdout);        freopen("/dev/null","w",stderr);        // Set the stderr stream to buffered with 32k.          // Allows utf-8 to be sent to stderr (P9A66750)        setvbuf(stderr, new char[32768], _IOLBF, 32768);    }#endif    if ( _operationType == OPERATION_TYPE_UNINITIALIZED )    {        //        // The command was not initialized        //        return ( RC_ERROR );    }    //PEP#167 - Added Options HELP and VERSION    //PEP#167 - CIMServer need not be running for these to work    else if (_operationType == OPERATION_TYPE_HELP)    {        cerr << usage << endl;        return (RC_SUCCESS);    }    else if(_operationType == OPERATION_TYPE_VERSION)    {        cerr << "Version " << PEGASUS_PRODUCT_VERSION << endl;        return (RC_SUCCESS);    }    //    // Get environment variables    //#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM#pragma convert(37)    const char* env = getenv("PEGASUS_HOME");#pragma convert(0)    // Set pegasusHome to the env var,if it is set.  Otherwise,    // use the OS/400 default path.    if (env != NULL)    {	char home[256] = {0};	if (strlen(env) < 256)	{	    strcpy(home, env);	    EtoA(home);	}    }    else        pegasusHome = OS400_DEFAULT_PEGASUS_HOME;    String currentFile = FileSystem::getAbsolutePath(        pegasusHome.getCString(), PEGASUS_CURRENT_CONFIG_FILE_PATH);    String plannedFile = FileSystem::getAbsolutePath(        pegasusHome.getCString(), PEGASUS_PLANNED_CONFIG_FILE_PATH);#else    const char* env = getenv("PEGASUS_HOME");    String currentFile =        FileSystem::getAbsolutePath(env, PEGASUS_CURRENT_CONFIG_FILE_PATH);    String plannedFile =        FileSystem::getAbsolutePath(env, PEGASUS_PLANNED_CONFIG_FILE_PATH);#endif    try    {        //        // Open default config files and load current config properties        //        _configFileHandler = new ConfigFileHandler(currentFile, plannedFile, true);    }    catch (const NoSuchFile&)    {    }    catch (const FileNotReadable& fnr)    {    	//l10n        //errPrintWriter << FILE_NOT_READABLE << fnr.getMessage() << endl;        errPrintWriter << localizeMessage(MSG_PATH, FILE_NOT_READABLE_KEY, FILE_NOT_READABLE) << fnr.getMessage() << endl;        return ( RC_ERROR );    }    catch (const ConfigFileSyntaxError& cfse)    {        errPrintWriter << cfse.getMessage() << endl;        return ( RC_ERROR );    }    //    // Get local host name    //    _hostName.assign(System::getHostName());    try    {        // Construct the CIMClient and set to request server messages        // in the default language of this client process.        _client.reset(new CIMClient);        _client->setRequestDefaultLanguages(); //l10n    }    catch (const Exception & e)    {        errPrintWriter << e.getMessage() << endl;        return ( RC_ERROR );            }    try    {        //        // Open connection with CIMSever        //        _client->connectLocal();        connected = true;    }    catch(const Exception&)    {        //        // Failed to connect, so process the request offline.        // When CIMOM is running the config command updates changes to         // config properties in the planned config file, so load only        // planned config properties.         //        _configFileHandler->loadPlannedConfigProperties();        connected = false;    }    //    // Perform the requested operation    //    switch ( _operationType )    {        case OPERATION_TYPE_GET:            try            {                if (connected)                {                    Array<String> propertyValues;                    _getPropertiesFromCIMServer( outPrintWriter,                         errPrintWriter, _propertyName, propertyValues);                    defaultValue = propertyValues[1];                    currentValue = propertyValues[2];                    gotCurrentValue = true;                    plannedValue = propertyValues[3];                    gotPlannedValue = true;                }                else                {                    if (_defaultValueSet)                    {                    	//l10n                        //errPrintWriter << "Option -" << OPTION_DEFAULT_VALUE <<                           //" is not valid for this command when" <<                           //" CIM server is not running." << endl;                        errPrintWriter << localizeMessage(MSG_PATH,                         						OPTION_INVALID_CIM_RUNNING_KEY,                         						OPTION_INVALID_CIM_RUNNING,                         						String(&OPTION_DEFAULT_VALUE,1)) << endl;                          return ( RC_ERROR );                    }                    else                     {                        gotCurrentValue = _configFileHandler->getCurrentValue (                             _propertyName, currentValue );                        gotPlannedValue = _configFileHandler->getPlannedValue (                             _propertyName, plannedValue );                    }                }            }            catch (const CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_NOT_FOUND ||                     code == CIM_ERR_FAILED)                {                	//l10n                    //outPrintWriter << PROPERTY_NOT_FOUND << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    							PROPERTY_NOT_FOUND_KEY,                    							PROPERTY_NOT_FOUND)                    							 << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                	//l10n                    //outPrintWriter << FAILED_TO_GET_PROPERTY << endl <<                        //CONFIG_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    							FAILED_TO_GET_PROPERTY_KEY,                    							FAILED_TO_GET_PROPERTY)                    							 << endl <<                     				  localizeMessage(MSG_PATH,                    				  			CONFIG_SCHEMA_NOT_LOADED_KEY,                    				  			CONFIG_SCHEMA_NOT_LOADED) << endl;                }                else                {                	//l10n                    //errPrintWriter << FAILED_TO_GET_PROPERTY <<                        //e.getMessage() << endl;                    outPrintWriter << localizeMessage(MSG_PATH,FAILED_TO_GET_PROPERTY_KEY,                    							      FAILED_TO_GET_PROPERTY)                     			   << e.getMessage() << endl;                    			                }                return ( RC_ERROR );            }            catch (const Exception& e)            {            	//l10n                //outPrintWriter << FAILED_TO_GET_PROPERTY << endl <<                    //e.getMessage() << endl;                outPrintWriter << localizeMessage(MSG_PATH,FAILED_TO_GET_PROPERTY_KEY,                    							      FAILED_TO_GET_PROPERTY) << endl                    			   << e.getMessage() << endl;                return ( RC_ERROR );            }            if( _currentValueSet || ( !_plannedValueSet && !_defaultValueSet ) )            {                if (gotCurrentValue)                {                	//l10n                    //outPrintWriter << "Current value: " << currentValue << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    							      CURRENT_VALUE_IS_KEY,                    								  CURRENT_VALUE_IS,                    								  currentValue) << endl;                }                else                {                	//l10n                    //outPrintWriter << "Current value can not be determined " <<                        //"because the CIM server is not running." << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    								  CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING_KEY,                    								  CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING) << endl;                }            }            if( _plannedValueSet )            {                if (gotPlannedValue)                {                	//l10n                    //outPrintWriter << "Planned value: " << plannedValue << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    								  PLANNED_VALUE_IS_KEY,                    								  PLANNED_VALUE_IS,                     								  plannedValue) << endl;                }                else                {                	//l10n                    //outPrintWriter << "Planned value can not be determined "                        //"because the CIM server is not running." << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                    								  CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING_KEY,                    								  CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING) << endl;                }            }            if( _defaultValueSet )            {            	//l10n                //outPrintWriter << "Default value: " << defaultValue << endl;                outPrintWriter << localizeMessage(MSG_PATH,                								  DEFAULT_VALUE_IS_KEY,                								  DEFAULT_VALUE_IS,                     							  defaultValue) << endl;            }            break;         case OPERATION_TYPE_SET:            //            // send changes to CIMOM if running, else send to config file            //            try            {                if (connected)                {                    _updatePropertyInCIMServer( outPrintWriter,                         errPrintWriter, _propertyName, _propertyValue, false);                    if ( _currentValueSet )                    {                    	//l10n                        //outPrintWriter << CURRENT_VALUE_OF_PROPERTY                            //<< _propertyName << IS_SET_TO << "\""                             //<< _propertyValue << "\"" << IN_CIMSERVER << endl;                                                   outPrintWriter << localizeMessage(MSG_PATH,                       									 CURRENT_VALUE_OF_PROPERTY_IS_KEY,                       									 CURRENT_VALUE_OF_PROPERTY_IS,                       									 _propertyName.getString(),                       									 _propertyValue) << endl;                    }                    if ( _plannedValueSet )                    {                    	//l10n                        //outPrintWriter << PLANNED_VALUE_OF_PROPERTY                            //<< _propertyName << IS_SET_TO << "\"" <<_propertyValue                            //<< "\"" << IN_CIMSERVER << endl;                        outPrintWriter << localizeMessage(MSG_PATH,                        								  PLANNED_VALUE_OF_PROPERTY_IS_KEY,                       									  PLANNED_VALUE_OF_PROPERTY_IS,                       									  _propertyName.getString(),                       									  _propertyValue) << endl;                    }                }                else                {                    if (_currentValueSet)                    {                    	//l10n                        //outPrintWriter << CURRENT_VALUE_OF_PROPERTY <<                            //_propertyName <<"' can not be set " <<                            //"because the CIM server is not running." << endl;                        outPrintWriter << localizeMessage(MSG_PATH,                        								  CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET_KEY,                        								  CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET,                        								  _propertyName.getString()) << endl;                        return ( RC_ERROR );                    }                    else if (_plannedValueSet)                    {                        if ( !_configFileHandler->updatePlannedValue( 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -