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

📄 cli.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                    getProperty(client, opts);                    break;                case ID_SetProperty :                    if (argc != 5)                        cout << "Usage: cli setproperty instancename propertyname value " << endl;                    setProperty(client, opts);                    break;                case ID_EnumerateQualifiers :                    enumerateQualifiers(client, opts);                    break;                case ID_SetQualifier :                    cerr << "SetQualifer not implemented" << endl;                        exit(1);                    break;                case ID_GetQualifier :                    if (!_getQualifierNameInput(argc, argv, opts))                        exit(1);                    getQualifier(client, opts);                    break;                case ID_DeleteQualifier :                    if (!_getQualifierNameInput(argc, argv, opts))                        exit(1);                    deleteQualifier(client, opts);                    break;                /* Reference params are                    [IN] <objectName> ObjectName,                    [IN,OPTIONAL,NULL] <className> ResultClass = NULL,                    [IN,OPTIONAL,NULL] string Role = NULL,                    [IN,OPTIONAL] boolean IncludeQualifiers = false,                    [IN,OPTIONAL] boolean IncludeClassOrigin = false,                    [IN,OPTIONAL,NULL] string PropertyList [] = NULL                */                case ID_References  :                    if (!_getObjectNameInput(argc, argv, opts, true))                        exit(1);                    references(client, opts);                    break;                case ID_ReferenceNames :                    if (!_getObjectNameInput(argc, argv, opts, true))                        exit(1);                    referenceNames(client, opts);                    break;                case ID_Associators :                    if (!_getObjectNameInput(argc, argv, opts, true))                        exit(1);                    associators(client, opts);                    break;                case ID_AssociatorNames :                    if (!_getObjectNameInput(argc, argv, opts, true))                        exit(1);                    associatorNames(client,opts);                    break;                case ID_EnumerateNamespaces :                    // Note that the following constants are fixed here.  We                    // should be getting them from the environment to assure that                    // others know that we are using them.                    opts.className = CIMName("CIM_Namespace");                    if (argc > 2)                    {                        opts.nameSpace = argv[2];                        opts.inputObjectName = argv[2];                    }                    else                        // set nameSpace to interop namespace name                        opts.nameSpace = PEGASUS_NAMESPACENAME_INTEROP.getString();                    enumerateNamespaces_Namespace(client,opts);                    break;                    /*                        CIMValue invokeMethod(                            const CIMNamespaceName& nameSpace,                            const CIMObjectPath& instanceName,                            const CIMName& methodName,                            const Array<CIMParamValue>& inParameters,                    Array<CIMParamValue>& outParameters                    */                case ID_InvokeMethod :                    if (argc < 4)                    {                        cout << "Usage: InvokeMethod requires object and method names\n."                             << "       input parameters are optional through -ip option"                             << "       or as additional parameters to this call. For"                             << "       additional parameters, enter each parameter as"                             << "       name=value without spaces."                             << endl;                        exit(1);                    }                    opts.objectName = argv[2];                    opts.inputObjectName = argv[2];                    opts.methodName = CIMName(argv[3]);                    // If there are any extra arguments they must be parameters                    // These parameters  can be used in addtion to parameters                    // ifrom the -ip option setting. Parameters found here must                    // be key=value pairs or they will generate an exception.                    if (argc > 4)                    {                        // get input params from command line                        for (Sint32 i = 4 ; i < argc; i++)                        {                            CIMParamValue pv;                            String s = argv[i];                            pv = _createMethodParamValue(s, opts);                            opts.inParams.append(pv);                        }                    }                    invokeMethod(client, opts);                    break;                case ID_ShowOptions :                    showUsage(argv[0]);                    break;                case ID_ExecQuery:                    opts.query = argv[2];                    if (argc==4)                        opts.queryLanguage = argv[3];                    executeQuery(client, opts);                    break;                case ID_StatisticsOn:                    setObjectManagerStatistics(client, true);                    break;                case ID_StatisticsOff:                    setObjectManagerStatistics(client, false);                    break;                //case ID_Unknown :                default:                    cout << "Invalid Command. Command name must be first parm or --c parameter."                        << " \n  ex. cli enumerateclasses\n"                        << "Enter " << argv[0] << " -h for help."                        << endl;                    exit(1);                    break;            }            if (opts.repeat > 0)            {                if (opts.verboseTest)                {                    cout << "Repetitition " << opts.repeat << endl;                }                opts.repeat--;                if (opts.time)                {                    totalTime += opts.saveElapsedTime;                    maxTime = LOCAL_MAX(maxTime, opts.saveElapsedTime);                    minTime = LOCAL_MIN(minTime, opts.saveElapsedTime);                    rtTotalTime += (returnedPerformanceData.roundTripTime);                    maxRtTime = LOCAL_MAX(maxRtTime, returnedPerformanceData.roundTripTime);                    minRtTime = LOCAL_MIN(minRtTime, returnedPerformanceData.roundTripTime);                    if (returnedPerformanceData.serverTimeKnown)                    {                        serverTotalTime += (returnedPerformanceData.serverTime);                        maxServerTime = LOCAL_MAX(maxServerTime, returnedPerformanceData.serverTime);                        minServerTime = LOCAL_MIN(minServerTime, returnedPerformanceData.serverTime);                    }                }            }        } while (opts.repeat > 0  );        if (opts.time)        {            if (repeatCount == 0)            {                cout << CommandTable[cmdIndex].CommandName                    << " "                    << opts.inputObjectName                    << " Time= "                    << opts.saveElapsedTime                    << " Sec "                    << " SvrTime= "                    << CIMValue(returnedPerformanceData.serverTime).toString()                    << " us "                    << " RtTime= "                    << CIMValue(returnedPerformanceData.roundTripTime).                           toString()                    << " us "                    << "Req size= "                    << CIMValue(returnedPerformanceData.requestSize).toString()                    << " b Resp size= "                    << CIMValue(returnedPerformanceData.responseSize).toString()                    << " b"                    << endl;            }            else            {                cout << CommandTable[cmdIndex].CommandName                    << " "                    << opts.inputObjectName                    << " Total Time "                    << totalTime                    << " for "                    << repeatCount                    << " ops. Avg= "                    << (totalTime * 1000000)/repeatCount                    << " us min= "                    << minTime * 1000000                    << " us max= "                    << (maxTime * 1000000)                     << " us SvrTime avg= "                    << CIMValue(serverTotalTime/repeatCount).toString()                    << " us SvrTime min= "                    << CIMValue(minServerTime).toString()                    << " us SvrTime max= "                    << CIMValue(maxServerTime).toString()                    << " us"                    << " RtTime avg= "                    << CIMValue(rtTotalTime/repeatCount).toString()                    << " us RtTime min= "                    << CIMValue(minRtTime).toString()                    << " us RtTime max= "                    << CIMValue(maxRtTime).toString()                    << " us"                    << endl;            }        }    }    catch(CIMException& e)    {        cerr << argv[0] << " CIMException: "<<" Cmd= " << opts.cimCmd            << " Object= " << opts.inputObjectName             << "\n" << e.getMessage()             << endl;        opts.termCondition = 1;    }    catch(Exception& e)    {        PEGASUS_STD(cerr) << argv[0] << " Pegasus Exception: " << e.getMessage()                <<  ". Cmd = " << opts.cimCmd << " Object = " << opts.inputObjectName << PEGASUS_STD(endl);            opts.termCondition = 1;    }    catch(...)    {        cerr << argv[0] << " Caught General Exception:" << endl;        opts.termCondition = 1;    }    totalElapsedExecutionTime.stop();    if (opts.time)    {        // if abnormal term, dump all times        if (opts.termCondition == 1)        {            cout << "Exception" << endl;            cout << "Prev Time " << opts.saveElapsedTime << " Sec" << endl;            opts.saveElapsedTime = opts.elapsedTime.getElapsed();            cout << "Last Time " << opts.saveElapsedTime << " Sec" << endl;            cout << "Total Time " << totalTime << " for "                << repeatCount << " operations. Avg.= " << totalTime/repeatCount                << " min= " << minTime << " max= " << maxTime << endl;        }        cout << "Total Elapsed Time= " << totalElapsedExecutionTime.getElapsed() << " Sec. Terminated at " << System::getCurrentASCIITime() << endl;    }    if (opts.delay != 0)    {        Threads::sleep(opts.delay * 1000);    }    return(opts.termCondition);}//PEGASUS_NAMESPACE_END// END_OF_FILE

⌨️ 快捷键说明

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