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

📄 cimprovidercommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_REMOVE);                    }                    if (options.isSet (OPTION_REMOVE) > 1)                    {                        //                        // More than one remove provider option was found                        //                        throw DuplicateOptionException(OPTION_REMOVE);                    }                    _operationType = OPERATION_TYPE_REMOVE;                    break;                }                case OPTION_ENABLE:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_ENABLE);                    }                    if (options.isSet (OPTION_ENABLE) > 1)                    {                        //                        // More than one stop option was found                        //                        throw DuplicateOptionException(OPTION_ENABLE);                    }                    _operationType = OPERATION_TYPE_ENABLE;                    break;                }                case OPTION_LIST:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_LIST);                    }                    if (options.isSet (OPTION_LIST) > 1)                    {                        //                        // More than one list option was found                        //                        throw DuplicateOptionException(OPTION_LIST);                    }                    _operationType = OPERATION_TYPE_LIST;                    break;                }                case OPTION_MODULE:                {                    if (options.isSet (OPTION_MODULE) > 1)                    {                        //                        // More than one module option was found                        //                        throw DuplicateOptionException(OPTION_MODULE);                    }                    _moduleName = options [i].Value ();                    _moduleSet = true;                    break;                }                case OPTION_PROVIDER:                {                    if (options.isSet (OPTION_PROVIDER) > 1)                    {                        //                        // More than one provider option was found                        //                        throw DuplicateOptionException(OPTION_PROVIDER);                    }                    _providerName = options [i].Value ();                    _providerSet = true;                    break;                }                case OPTION_STATUS:                {                    if (options.isSet (OPTION_STATUS) > 1)                    {                        //                        // More than one status option was found                        //                        throw DuplicateOptionException(OPTION_STATUS);                    }                    _statusSet = true;                    break;                }#ifdef PEGASUS_OS_OS400                case OPTION_QUIET_VALUE:                {                        _defaultQuietSet = true;                        break;                }#endif            //PEP#167 - 2 new cases added below for HELP and VERSION            case OPTION_HELP:            {                if (_operationType != OPERATION_TYPE_UNINITIALIZED)                {                    //                    // More than one operation option was found                    //                    throw UnexpectedOptionException(OPTION_HELP);                }                if (options.isSet (OPTION_HELP) > 1)                {                    //                    // More than one list option was found                    //                    throw DuplicateOptionException(OPTION_HELP);                }                _operationType = OPERATION_TYPE_HELP;                break;            }            case OPTION_VERSION:            {                if (_operationType != OPERATION_TYPE_UNINITIALIZED)                {                    //                    // More than one operation option was found                    //                    throw UnexpectedOptionException(OPTION_VERSION);                }                if (options.isSet (OPTION_VERSION) > 1)                {                    //                    // More than one list option was found                    //                    throw DuplicateOptionException(OPTION_VERSION);                }                _operationType = OPERATION_TYPE_VERSION;                break;            }                default:                {                    //                    // Should never get here                    //                    break;                }            }        }    }    //    // Some more validations    //    if ( _operationType == OPERATION_TYPE_UNINITIALIZED )    {        //        // No operation type was specified        // Show the usage        //        throw CommandFormatException(localizeMessage(            MSG_PATH, REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING));    }    if ( _operationType == OPERATION_TYPE_DISABLE )    {        if ( _providerSet )        {            //l10n            //CommandFormatException e("Unexpected Option.");            throw CommandFormatException(localizeMessage(MSG_PATH,                UNEXPECTED_OPTION_KEY,                UNEXPECTED_OPTION));        }        if ( !_moduleSet )        {            throw MissingOptionException(OPTION_MODULE);        }    }    if ( _operationType == OPERATION_TYPE_ENABLE )    {        if ( _providerSet )        {            //l10n            //CommandFormatException e("Unexpected Option.");            throw CommandFormatException(localizeMessage(MSG_PATH,                UNEXPECTED_OPTION_KEY,                UNEXPECTED_OPTION));        }        if ( !_moduleSet )        {            throw MissingOptionException(OPTION_MODULE);        }    }    if ( _operationType == OPERATION_TYPE_REMOVE && !_moduleSet )    {        throw MissingOptionException(OPTION_MODULE);    }    if ( _operationType == OPERATION_TYPE_LIST && _providerSet )    {        //l10n        //CommandFormatException e("Unexpected Option.");        throw CommandFormatException(localizeMessage(MSG_PATH,            UNEXPECTED_OPTION_KEY,            UNEXPECTED_OPTION));    }    if ( _operationType == OPERATION_TYPE_LIST && _statusSet && _moduleSet)    {        //l10n        //CommandFormatException e("Unexpected Option.");        throw CommandFormatException(localizeMessage(MSG_PATH,            UNEXPECTED_OPTION_KEY,            UNEXPECTED_OPTION));    }#ifdef PEGASUS_OS_OS400    if ( _operationType == OPERATION_TYPE_LIST && _defaultQuietSet )    {        //        // An invalid option was encountered        //        throw InvalidOptionException(OPTION_QUIET_VALUE);    }#endif}/**    Executes the command and writes the results to the PrintWriters.*/Uint32 CIMProviderCommand::execute (    ostream& outPrintWriter,    ostream& errPrintWriter){    if ( _operationType == OPERATION_TYPE_UNINITIALIZED )    {        //        // The command was not initialized        //        return 1;    }    //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);    }#ifdef PEGASUS_OS_OS400    // disable standard out 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    //    // 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);//PEP101        _client->setTimeout(CIMPROVIDERCOMMAND_CLIENT_DEFAULTTIMEOUT);        _client->setRequestDefaultLanguages(); //l10n    }    catch (Exception & e)    {        errPrintWriter << e.getMessage() << endl;        return ( RC_ERROR );    }    try    {        //        // Open connection with CIMSever        //        _client->connectLocal();    }    catch(const Exception&)    {        //l10n        //outPrintWriter << CIMOM_NOT_RUNNING << endl;        outPrintWriter << localizeMessage(MSG_PATH,            CIMOM_NOT_RUNNING_KEY,            CIMOM_NOT_RUNNING) << endl;        return 1;    }    //    // Perform the requested operation    //    switch ( _operationType )    {        case OPERATION_TYPE_REMOVE:            try            {                _deleteProvider( outPrintWriter, errPrintWriter );            }            catch (CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_FAILED)                {                    //l10n                    //outPrintWriter << DELETE_PROVIDER_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        DELETE_PROVIDER_FAILURE_KEY,                        DELETE_PROVIDER_FAILURE) << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    //l10n                    //outPrintWriter << DELETE_PROVIDER_FAILURE << endl;                    //outPrintWriter << PG_PROVIDER_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        DELETE_PROVIDER_FAILURE_KEY,                        DELETE_PROVIDER_FAILURE) << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        PG_PROVIDER_SCHEMA_NOT_LOADED_KEY,                        PG_PROVIDER_SCHEMA_NOT_LOADED) << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (Exception& e)            {                errPrintWriter << e.getMessage() << endl;                return ( RC_ERROR );            }            break;            case OPERATION_TYPE_ENABLE:            try            {                _StartProvider( outPrintWriter, errPrintWriter );            }            catch (CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_FAILED)                {                    //l10n                    //outPrintWriter << START_PROVIDER_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        START_PROVIDER_FAILURE_KEY,                        START_PROVIDER_FAILURE) << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    //l10n                    //outPrintWriter << START_PROVIDER_FAILURE << endl;                    //outPrintWriter << PG_PROVIDER_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        START_PROVIDER_FAILURE_KEY,                        START_PROVIDER_FAILURE) << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        PG_PROVIDER_SCHEMA_NOT_LOADED_KEY,                        PG_PROVIDER_SCHEMA_NOT_LOADED) << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (Exception& e)            {                errPrintWriter << e.getMessage() << endl;                return ( RC_ERROR );            }            break;

⌨️ 快捷键说明

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