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

📄 cliclientlib.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        cout << "ExecQuery "            << "Namespace = " << opts.nameSpace            << ", queryLanguage = " << opts.queryLanguage            << ", query = " << opts.query            << endl;    }    Array<CIMObject> objects;    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    objects = client.execQuery( opts.nameSpace,                                opts.queryLanguage,                                opts.query );    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    if (opts.summary)    {      String s = "instances of class";        _displaySummary(objects.size(), s, opts.className.getString(),opts);    }    else    {        // Output the returned instances        for (Uint32 i = 0; i < objects.size(); i++)            outputFormatObject(opts.outputType, objects[i]);    }    return(0);}int deleteInstance(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "deleteInstance "            << "Namespace = " << opts.nameSpace            << ", Object = " << opts.objectName            << endl;    }    // if request is class only, do this interactively    // Need to get this into objectpath format before doing the call.    CIMObjectPath thisObject(opts.objectName);    if ((thisObject.getKeyBindings().size() == 0) ? true : false)    {        // get the instance to delete        if(!_selectInstance(client, opts, CIMName(opts.objectName), thisObject))            return(0);    }    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    client.deleteInstance(opts.nameSpace,                          thisObject);    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    return(0);}/*NAMESPACE = 1Class = 2OBJECT = Object*2OBJECTNAME = OBJECT*2INSTANCENAME = OBJECTNAME * 2METHODNAME = INSTANCENAME * 2PROPERTYNAME = 2PROPERTYVALUE=2INPARAMS = 2DEEPINHERITANCE = 2LOCALONLY = 2ASSOCCLASS = 4RESULTCLASS = 8ROLE = 16RESULTROLE = 32InCLUDEQUALIFIERS = 64INCLUDECLASSORIGIN = 128PROPDERTYLIST = 256*/int getInstance(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "getInstance "            << "Namespace = " << opts.nameSpace            << ", Instance = " << opts.objectName            << ", localOnly = " << _toString(opts.localOnly)            << ", includeQualifiers = " << _toString(opts.includeQualifiers)            << ", includeClassOrigin = " << _toString(opts.includeClassOrigin)            << ", PropertyList = " << buildPropertyListString(opts.propertyList)            << endl;    }    CIMObjectPath thisObject(opts.objectName);    if ((thisObject.getKeyBindings().size() == 0) ? true : false)    {        // get the instance to delete        if(!_selectInstance(client, opts, CIMName(opts.objectName),thisObject))            return(0);    }    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    CIMInstance cimInstance = client.getInstance(opts.nameSpace,                                                 thisObject,                                                 opts.localOnly,                                                 opts.includeQualifiers,                                                 opts.includeClassOrigin,                                                 opts.propertyList);    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    // Check Output Format to print results    if (opts.summary)    {        if (opts.time)        {            cout << opts.saveElapsedTime << endl;        }    }    else    {        outputFormatInstance(opts.outputType, cimInstance);    }    return(0);}/****    CIMObjectPath createInstance(    const CIMNamespaceName& nameSpace,    const CIMInstance& newInstance    ); ***/int createInstance(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "createInstance "            << "Namespace = " << opts.nameSpace            << ", ClassName = " << opts.className            << endl;    }    // get the class. Exceptions including class_not_found are automatic    CIMClass thisClass =        client.getClass(opts.nameSpace, opts.className,false,true,true,CIMPropertyList());    // Tokenize the parameter pairs    //Array<keyValuePair> inputs;    Array<CIMName> propertyNameList;    Array<String> propertyValueList;    // ATTN: Need to account for returning key without value here.    if (opts.extraParams != 0)    {        /* Here loop starts from 1, since the Class Name is coming as first parameter and           we want only the property name and value here        */        for (Uint32 i = 1 ; i < opts.extraParams.size() ; i++)        {            String key;            String value;            _tokenPair(opts.extraParams[i], key, value);            propertyNameList.append(CIMName(key));            propertyValueList.append(value);            if (thisClass.findProperty(CIMName(key)) == PEG_NOT_FOUND)                cout << "Warning property Name not in class: " << opts.extraParams[i] << endl;        }        if (opts.verboseTest)        {            // This loop gives all the property names and property values of the instance            for (Uint32 i=0; i < propertyNameList.size(); i++)            {                cout << "Property: " << propertyNameList[i]                     << " value: " << propertyValueList[i]                     << endl;            }        }    }    CIMPropertyList myPropertyList(propertyNameList);    // create the instance with the defined properties    CIMInstance newInstance = thisClass.buildInstance(true, true, myPropertyList);    // Set all the property Values to the instance    for (Uint32 i=0; i < propertyValueList.size(); i++)    {        newInstance.getProperty(i).setValue(CIMValue( propertyValueList[i]));    }    // Now add the parameters from the input. Array.    //Note that we do NO checking.  Each input parameter is a simple    //name=value.    // At this point we also treat them all as strings since we have not    // defined a means to handle typing.    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    CIMObjectPath rtndPath = client.createInstance(opts.nameSpace,                                                 newInstance);    // Need to put values into the parameters.    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    // Check Output Format to print results    if (opts.summary)    {        if (opts.time)        {            cout << opts.saveElapsedTime << endl;        }    }    else    {        cout << rtndPath.toString() << endl;;    }    return(0);}int enumerateClassNames(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "EnumerateClasseNames "            << "Namespace= " << opts.nameSpace            << ", Class= " << opts.className            << ", deepInheritance= " << (opts.deepInheritance? "true" : "false")            << endl;    }    Array<CIMName> classNames;    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    classNames = client.enumerateClassNames(opts.nameSpace,                                        opts.className,                                        opts.deepInheritance);    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    if (opts.summary)    {      String s = "class names";        _displaySummary(classNames.size(), s,             opts.className.getString(),opts);    }    else    {        //simply output the list one per line for the moment.        for (Uint32 i = 0; i < classNames.size(); i++)                cout << classNames[i] << endl;    }    return(0);}int enumerateClasses(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "EnumerateClasses "            << "Namespace= " << opts.nameSpace            << ", Class= " << opts.className            << ", deepInheritance= " << _toString(opts.deepInheritance)            << ", localOnly= " << _toString(opts.localOnly)            << ", includeQualifiers= " << _toString(opts.includeQualifiers)            << ", includeClassOrigin= " << _toString(opts.includeClassOrigin)            << endl;    }    // Added to allow "" string input to represent NULL CIMName.    /*    CIMName myClassName = CIMName();    if (opts.className != "")    {        myClassName = opts.className;    }    */    Array<CIMClass> classes;    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    classes = client.enumerateClasses(opts.nameSpace,                                        opts.className,                                        opts.deepInheritance,                                        opts.localOnly,                                        opts.includeQualifiers,                                        opts.includeClassOrigin);    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    if (opts.summary)    {        String s = "classes";        _displaySummary(classes.size(), s, opts.className.getString(),opts);    }    else    {        // Output the returned instances        for (Uint32 i = 0; i < classes.size(); i++)        {            CIMClass myClass = classes[i];            outputFormatClass(opts.outputType, myClass);        }    }    return(0);}int deleteClass(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "deleteClasses "            << "Namespace = " << opts.nameSpace            << ", Class = " << opts.className            << endl;    }    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    client.deleteClass(opts.nameSpace, opts.className);    if (opts.time)    {        opts.elapsedTime.stop();        opts.saveElapsedTime = opts.elapsedTime.getElapsed();    }    return(0);}int getClass(CIMClient& client, Options& opts){    if (opts.verboseTest)    {        cout << "getClass "            << "Namespace= " << opts.nameSpace            << ", Class= " << opts.className            << ", deepInheritance= " << _toString(opts.deepInheritance)            << ", localOnly= " << _toString(opts.localOnly)            << ", includeQualifiers= " << _toString(opts.includeQualifiers)            << ", includeClassOrigin= " << _toString(opts.includeClassOrigin)            << ", PropertyList= " << buildPropertyListString(opts.propertyList)            << endl;    }    if (opts.time)    {        opts.elapsedTime.reset();        opts.elapsedTime.start();    }    CIMClass cimClass = client.getClass(opts.nameSpace,                                        opts.className,                                        opts.localOnly,                                        opts.includeQualifiers,                                        opts.includeClassOrigin,                                        opts.propertyList);    if (opts.time)    {

⌨️ 快捷键说明

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