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

📄 cli.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//%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.////==============================================================================//// Author:  Karl Schopmeyer (k.schopmeyer@opengroup.org)//          Mary Hinton (m.hinton@verizon.net)//// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company//                (carolann_graves@hp.com)//              Adrian Schuur (schuur@de.ibm.com)//              Aruran, IBM (ashanmug@in.ibm.com) for Bug#4065,#4228////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/PegasusAssert.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/Threads.h>#include <Pegasus/Client/CIMClient.h>#include <Clients/CLITestClients/CLIClientLib/CLIClientLib.h>#include <Pegasus/Common/Tracer.h>#include <Pegasus/Common/Stopwatch.h>PEGASUS_USING_PEGASUS;PEGASUS_USING_STD;//////////////////////////////////////////////////////////////////////////** getClassName - gets the classname object * and puts in into the opts.className holder * If rqd, parameter must exist. Otherwise * it subsitutes NULL for the string. * Also puts the arguement in inputObjectName * @param- rqd - true if parameter required * @return True if parameter found.*/Boolean _getClassNameInput(int argc, char** argv, Options& opts, Boolean rqd){    if (argc > 2)    {        opts.className = CIMName(argv[2]);        opts.inputObjectName = argv[2];    }    else    {        if (rqd)        {                cerr << "Class Name Required. ex. gc CIM_Door" << endl;                return(false);        }        else        {                opts.className = CIMName();                opts.inputObjectName = "";        }    }    return(true);}/** getObjectName - gets the classname object * and puts in into the opts.className holder * If rqd, parameter must exist. Otherwise * it subsitutes NULL for the string. * Also puts the arguement in inputObjectName * @param- rqd - true if parameter required * @return True if parameter found.*/Boolean _getObjectNameInput(int argc, char** argv, Options& opts, Boolean rqd){    if (argc > 2)    {        opts.objectName = argv[2];        opts.inputObjectName = argv[2];    }    else    {        if (rqd)        {                cerr << "Object Name Required" << endl;                return(false);        }        else        {                opts.objectName = "";                opts.inputObjectName = "";        }    }    return(true);}/** _getQualifierNameInput - Gets a single parameter for * qualifier * @return true if parameter found*/Boolean _getQualifierNameInput(int argc, char** argv, Options& opts){    if (argc > 2)    {        opts.qualifierName = argv[2];        opts.inputObjectName = argv[2];    }    else    {        cerr << "Qualifier Name Required" << endl;        return(false);    }    return(true);}Boolean setObjectManagerStatistics(CIMClient & client, Boolean newState){    CIMName gathStatName ("GatherStatisticalData");    Array<CIMInstance> instancesObjectManager;    CIMInstance instObjectManager;    Uint32 prop_num;    Array<CIMName> plA;    plA.append(gathStatName);    CIMPropertyList statPropertyList(plA);    // Create property list that represents correct request    // get instance.  Get only the gatherstatitistics property    instancesObjectManager  = client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP,            "CIM_ObjectManager",            true, false, false, false, statPropertyList);    PEGASUS_TEST_ASSERT(instancesObjectManager.size() == 1);    instObjectManager = instancesObjectManager[0];    instObjectManager.setPath(instancesObjectManager[0].getPath());         // set correct path into instance        prop_num = instObjectManager.findProperty(gathStatName);    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);        instObjectManager.getProperty(prop_num).setValue(CIMValue(newState));        client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP, instObjectManager,         false, statPropertyList);    CIMInstance updatedInstance = client.getInstance(PEGASUS_NAMESPACENAME_INTEROP,        instObjectManager.getPath(), false, false, false, statPropertyList);    prop_num = updatedInstance.findProperty(gathStatName);    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);    CIMProperty p = updatedInstance.getProperty(prop_num);    CIMValue v = p.getValue();    Boolean rtn;    v.get(rtn);    //// Need to get it again    cout << "Updated Status= " << ((rtn)? "true" : "false") << endl;    return(rtn);}ClientOpPerformanceData returnedPerformanceData;class ClientStatistics : public ClientOpPerformanceDataHandler{public:    virtual void handleClientOpPerformanceData (const ClientOpPerformanceData & item)    {        if (!(0 <= item.operationType) || !(39 >= item.operationType))        {           cerr << "Operation type out of expected range in ClientOpPerformanceData " << endl;           exit(1);        }        returnedPerformanceData.operationType =  item.operationType;        if (item.roundTripTime == 0)        {           cerr << "roundTripTime is incorrect in ClientOpPerformanceData " << endl;        }        returnedPerformanceData.roundTripTime =  item.roundTripTime;        if (item.requestSize == 0)        {            cerr << "requestSize is incorrect in ClientOpPerformanceData " << endl;        }        returnedPerformanceData.requestSize =  item.requestSize;        if (item.responseSize == 0)        {            cerr << "responseSize is incorrect in ClientOpPerformanceData " << endl;        }        returnedPerformanceData.responseSize =  item.responseSize;        if (item.serverTimeKnown)         {            /* Bypass this because we are getting server times zero            if (item.serverTime == 0)            {                cerr << "serverTime is incorrect in ClientOpPerformanceData " << endl;            }            */            returnedPerformanceData.serverTime =  item.serverTime;            returnedPerformanceData.serverTimeKnown =  item.serverTimeKnown;            returnedPerformanceData.roundTripTime =  item.roundTripTime;        }   }   //returnedPerformanceData = item;   // Copy the data to public place};/////////////////////////////////////////////////////////////////////////            Main///////////////////////////////////////////////////////////////////////int main(int argc, char** argv){    // If no arguments, simply print usage message and terminate.    if (argc == 1)    {        showUsage(argv[0]);        exit(0);    }    //****** Show the args diagnostic display    if (strcmp(argv[1],"displayargs") == 0)    {        cout << "argc = " << argc << endl;        for (int i = 0; i < argc; i++)            cout << "argv[" << i << "] = " << argv[i] << endl;    }    // Get options (from command line and from configuration file); this    // removes corresponding options and their arguments from the command    // line.    OptionManager om;    Options opts;    try    {        // assume that the config file is local to directory where called.        String testHome = ".";        GetOptions(om, argc, argv, testHome);        // Initialize all of the function input parameters.        opts.location =  String::EMPTY;#ifdef PEGASUS_HAS_SSL        opts.ssl = false;        opts.clientCert = String::EMPTY;        opts.clientKey = String::EMPTY;#endif        opts.nameSpace = "root/cimv2";        opts.cimCmd = "unknown";        opts.className = CIMName();        opts.objectName = "unknown";        opts.isXmlOutput = false;        opts.outputFormatType = OUTPUT_MOF;        opts.user = String::EMPTY;        opts.password = String::EMPTY;        opts.verboseTest = false;        opts.localOnly = true;        opts.deepInheritance = false;        opts.includeQualifiers = true;        opts.includeClassOrigin = false;        opts.assocClassName = String::EMPTY;        opts.assocClass = CIMName();        opts.resultClassName = String::EMPTY;        opts.resultClass = CIMName();        opts.role = String::EMPTY;        opts.resultRole = String::EMPTY;        opts.propertyListText = String::EMPTY;        opts.propertyList.clear();

⌨️ 快捷键说明

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