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

📄 testmodelwalkstressclient.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//%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:  Aruran, IBM (aruran.shanmug@in.ibm.com)//// Modified By: ////%/////////////////////////////////////////////////////////////////////////////#include "../TestStressTestClient.h"PEGASUS_USING_PEGASUS;PEGASUS_USING_STD;Boolean verboseTest = false;Boolean quit = false;Boolean nextCheck = false;int status = CLIENT_UNKNOWN;char clientName[] = "ModelWalkStressClient";String errorInfo;/**     Signal handler for SIGALARM.     @param   signum - the alarm identifier.*/void endTest(int signum){    PEGASUS_STD(cout) << "\nRecieved interrupt signal SIGINT!\n"                      << PEGASUS_STD(endl);    quit = true;}class TestModelWalkStressClient:public TestStressTestClient{};/**    GetNameSpaces    If no nameSpace is supplied on the command line, this method looks into    the root and test nameSpaces for the _Namespace class. The names of the     instances of that class are retrued by this method.*/Array<CIMNamespaceName> getNameSpaces(    TestModelWalkStressClient &tmsc,    CIMClient* client,    OptionManager &om,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile){    Array<CIMNamespaceName> topNamespaceNames;    Array<CIMNamespaceName> returnNamespaces;    String tmpNamespace;    om.lookupValue("namespace",tmpNamespace);    if (tmpNamespace != String::EMPTY)    {        returnNamespaces.append(CIMNamespaceName (tmpNamespace));    }    else    {        //        // Get all namespaces for display using the __Namespaces function.        //        CIMName className = "__NameSpace";        //        // We have to append any new top level root namespace if created in        // repository.        //        topNamespaceNames.append("root");        topNamespaceNames.append("test");        Uint32 start = 0;        Uint32 end = topNamespaceNames.size();        //        // for all new elements in the output array.         //        for (Uint32 range = start; range < end; range ++)        {            //            // Get the next increment in naming for all name element in            // the array.            //            Array<CIMInstance> instances = client->enumerateInstances(                topNamespaceNames[range], className);            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }            for (Uint32 i = 0 ; i < instances.size(); i++)            {                Uint32 pos;                //                // if we find the property and it is a string, use it.                //                if ((pos = instances[i].findProperty("name")) != PEG_NOT_FOUND)                {                    CIMValue value;                    String namespaceComponent;                    value = instances[i].getProperty(pos).getValue();                    if (value.getType() == CIMTYPE_STRING)                    {                        value.get(namespaceComponent);                        String ns = topNamespaceNames[range].getString();                        ns.append("/");                        ns.append(namespaceComponent);                        returnNamespaces.append(ns);                    }                }            }        }    }//else block ends here...    if (verboseTest)    {        errorInfo.clear();        errorInfo.append("+++++ Successfully Enumerated all Namespaces that ");        errorInfo.append("have a _NameSpace instance defined for them in the");        errorInfo.append(" root of test namespaces +++++");        tmsc.errorLog(clientPid, clientLog, errorInfo);        errorInfo.clear();    }    return returnNamespaces;}/**    EnumerateAllQualifiers    This method enumerates all the qualifiers in each of the nameSpaces    of the "nameSpacesArray"*/static void enumerateAllQualifiers(    TestModelWalkStressClient &tmsc,    CIMClient* client,    Array<CIMNamespaceName> nameSpacesArray,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile){    Array<CIMQualifierDecl> qualifierDecls;    qualifierDecls.clear();    for (Uint32 i=0; i < nameSpacesArray.size();i++)    {        try        {            qualifierDecls = client->enumerateQualifiers(nameSpacesArray[i]);            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }        }        //        // Following exceptions will be caught in the Main method.        //        catch (CIMException &e)        {            errorInfo.clear();            errorInfo.append("CIMException in enumerateQualifiers : ");            errorInfo.append(e.getMessage());            CIMException cimExp(e.getCode(), errorInfo);            throw cimExp;        }        catch (Exception &e)        {            errorInfo.clear();            errorInfo.append("Exception in enumerateQualifiers : ");            errorInfo.append(e.getMessage());            Exception exp(errorInfo);            throw exp;        }        catch (...)        {            Exception exp("General Exception in enumerateQualifiers ");            throw exp;        }    }    if (verboseTest)    {        errorInfo.clear();        errorInfo.append("+++++ Successfully Enumerated Qualifiers for ");        errorInfo.append("Namespaces +++++");        tmsc.errorLog(clientPid, clientLog, errorInfo);        errorInfo.clear();    }}/**    EnumerateReferenceNames    This method enumerates the references to each instance in the array    "cimInstances" for the "nameSpace" */static void enumerateReferenceNames(    TestModelWalkStressClient &tmsc,    CIMClient* client,     Array<CIMInstance> cimNInstances,    CIMNamespaceName nameSpace,    CIMName referenceClass,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile){    String role = String::EMPTY;    Array<CIMObjectPath> resultObjectPaths;    for (Uint32 i=0; i < cimNInstances.size(); i++)    {        try        {            resultObjectPaths = client->referenceNames(                nameSpace, cimNInstances[i].getPath(),                referenceClass, role);            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }        }        //        // Following exceptions will be caught in the Main method.        //        catch (CIMException &e)        {            errorInfo.clear();            errorInfo.append("CIMException in enumerateReferenceNames : ");            errorInfo.append(e.getMessage());            CIMException cimExp(e.getCode(), errorInfo);            throw cimExp;        }        catch (Exception &e)        {            errorInfo.clear();            errorInfo.append("Exception in enumerateReferenceNames : ");            errorInfo.append(e.getMessage());            Exception exp(errorInfo);            throw exp;        }        catch (...)        {            Exception exp("General Exception in enumerateReferenceNames ");            throw exp;        }    }}/**    EnumerateAssociatorNames    This method enumerates the associators to each instance in the array    "cimInstances" for the "nameSpace" */static void enumerateAssociatorNames(    TestModelWalkStressClient &tmsc,    CIMClient* client,    Array<CIMInstance> cimNInstances,    CIMNamespaceName nameSpace,    CIMName assocClass,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile){    CIMName resultClass = CIMName();    String role = String::EMPTY;    String resultRole = String::EMPTY;    Array<CIMObjectPath> resultObjectPaths;    for (Uint32 i=0; i < cimNInstances.size(); i++)    {        try        {            resultObjectPaths = client->associatorNames(                nameSpace, cimNInstances[i].getPath(),                assocClass, resultClass, role, resultRole);            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }        }        //        // Following exceptions will be caught in the Main method.        //        catch (CIMException &e)        {            errorInfo.clear();            errorInfo.append("CIMException in enumerateAssociatorNames : ");            errorInfo.append(e.getMessage());            CIMException cimExp(e.getCode(), errorInfo);            throw cimExp;        }        catch (Exception &e)        {            errorInfo.clear();            errorInfo.append("Exception in enumerateAssociatorNames : ");            errorInfo.append(e.getMessage());            Exception exp(errorInfo);            throw exp;        }        catch (...)        {            Exception exp("General Exception in enumerateAssociatorNames ");            throw exp;        }    }}/**    EnumerateInstanceRelatedInfo    This method enumerates instances, referances (by way of subrotine) and     associators (by way of subrotine.Exceptions are caught, modified and     re-thrown so that generic exception handling can be used in Main*/static void enumerateInstanceRelatedInfo(    TestModelWalkStressClient &tmsc,    CIMClient *client,     Array<CIMName> classNames,    CIMNamespaceName nameSpace,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile ){    Boolean deepInheritance = true;    Boolean localOnly = true;    Boolean includeQualifiers = false;    Boolean includeClassOrigin = false;    Array<CIMInstance> cimNInstances;    for (Uint32 i=0; i < classNames.size(); i++)    {        try        {            cimNInstances = client->enumerateInstances(                nameSpace, classNames[i], deepInheritance,                localOnly, includeQualifiers, includeClassOrigin);            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }        }        //        // Following exceptions will be caught in the Main method.        //        catch (CIMException &e)        {            errorInfo.clear();            errorInfo.append("CIMException thrown from ");            errorInfo.append("enumerateInstanceRelatedInfo, class = ");            errorInfo.append(classNames[i].getString());            errorInfo.append("  ");            errorInfo.append(e.getMessage());            CIMException cimExp(e.getCode(), errorInfo);            throw cimExp;        }        catch (Exception &e)        {            errorInfo.clear();            errorInfo.append("Exception thrown from ");            errorInfo.append("enumerateInstanceRelatedInfo, class = ");            errorInfo.append(classNames[i].getString());            errorInfo.append("  ");            errorInfo.append(e.getMessage());            Exception exp(errorInfo);            throw exp;        }        catch (...)        {            Exception exp("General Exception in EnumerateInstanceRelatedInfo ");            throw exp;        }        enumerateReferenceNames (tmsc, client, cimNInstances, nameSpace,            CIMName(), clientPid, clientLog, clientId, status, pidFile);        enumerateAssociatorNames (tmsc, client, cimNInstances, nameSpace,            CIMName(), clientPid, clientLog, clientId, status, pidFile);        if (verboseTest)        {            errorInfo.clear();            errorInfo.append("+++++ Successfully Done Instance Operations ");            errorInfo.append("on class = ");            errorInfo.append(classNames[i].getString());            tmsc.errorLog(clientPid, clientLog, errorInfo);            errorInfo.clear();        }    }}/**    EnumerateClassRelatedInfo    This method enumerates classes and instances (by way of subrotine)  */static void enumerateClassRelatedInfo(    TestModelWalkStressClient &tmsc,    CIMClient* client,    OptionManager &om,    Array<CIMNamespaceName> nameSpacesArray,    pid_t clientPid,    String& clientLog,    String &clientId,    int status,    String &pidFile){    Array<CIMName> classNames;    String tmpClassName;    om.lookupValue("classname",tmpClassName);    if (tmpClassName != String::EMPTY)    {        classNames.append(CIMName(tmpClassName));        enumerateInstanceRelatedInfo(tmsc, client, classNames,            *nameSpacesArray.getData(), clientPid, clientLog, clientId,            status, pidFile);    }    else    {        Boolean deepInheritance = true;        CIMName className;        for (Uint32 i=0; i < nameSpacesArray.size();i++)        {            classNames = client->enumerateClassNames(nameSpacesArray[i],                className, deepInheritance);

⌨️ 快捷键说明

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