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

📄 serverprofile.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.////==============================================================================#include <Pegasus/Common/Config.h>#include <Pegasus/Common/CIMName.h>#include <Pegasus/Common/CIMObjectPath.h>#include <Pegasus/Common/CIMInstance.h>#include <Pegasus/Common/String.h>#include <Pegasus/Client/CIMClient.h>PEGASUS_USING_STD;PEGASUS_USING_PEGASUS;const CIMNamespaceName interopNamespace = CIMNamespaceName("root/PG_InterOp");void exitFailure(const String & msg){    cout << (const char *)msg.getCString() << endl;    exit(-1);}Array<CIMInstance> testAnyClass(CIMClient & client, const CIMName & className){    Array<CIMObjectPath> instanceNames = client.enumerateInstanceNames(        interopNamespace, className);    Array<CIMInstance> instances = client.enumerateInstances(        interopNamespace, className);    if(instanceNames.size() != instances.size())    {        exitFailure(className.getString() +            String(": number of results of EnumerateInstanceNames does not ") +            String("match EnumerateInstances"));    }    for(unsigned int i = 0, n = instanceNames.size(); i < n; ++i)    {        Boolean found = false;        for(unsigned int j = 0, m = instances.size(); j < m; ++j)        {            if(instanceNames[i] == instances[j].getPath())            {                found = true;                break;            }        }        if(!found)        {            exitFailure(className.getString() +                String(": Could not find object path in results of ") +                String("EnumerateInstances: ") + instanceNames[i].toString());        }        try        {            client.getInstance(interopNamespace, instanceNames[i]);        }        catch(CIMException &)        {            exitFailure(className.getString() +                String(": GetInstance operation failed for object ") +                instanceNames[i].toString());        }    }    return instances;}void testInstanceClass(CIMClient & client, const CIMName & className){    Array<CIMInstance> instances = testAnyClass(client, className);    for(unsigned int i = 0, n = instances.size(); i < n; ++i)    {        CIMInstance currentInstance = instances[i];        CIMObjectPath currentPath = currentInstance.getPath();        if(currentPath.getNameSpace().isNull())          currentPath.setNameSpace(interopNamespace);        //        // Now test association traversal        // Note that the "TestAssociationClass" method does a very good job        // of testing association traversal between references contained in        // instances of the supplied association class. Therefore, all we really        // have to do here is make sure that the results of the associators,        // associatorNames, references, and referenceNames operations are        // consistent.        //        Boolean failure = false;        try        {            Array<CIMObject> associatorsResults = client.associators(                currentPath.getNameSpace(), currentPath);            Array<CIMObjectPath> associatorNamesResults =                client.associatorNames(                    currentPath.getNameSpace(), currentPath);            Array<CIMObject> referencesResults = client.references(                currentPath.getNameSpace(), currentPath);            Array<CIMObjectPath> referenceNamesResults = client.referenceNames(                currentPath.getNameSpace(), currentPath);            Uint32 numResults = associatorsResults.size();            if(numResults != associatorNamesResults.size() ||                numResults != referencesResults.size() ||                numResults != referenceNamesResults.size())            {                failure = true;            }            else            {                // Check that the results for the references and referenceNames                // operations are consistent.                unsigned int j = 0;                for(j = 0; j < numResults; ++j)                {                    CIMObjectPath currentReferenceName =                        referenceNamesResults[j];                    Boolean found = false;                    for(unsigned int k = 0; k < numResults; ++k)                    {                        if(currentReferenceName ==                            referencesResults[k].getPath())                        {                            found = true;                            break;                        }                    }                    if(!found)                    {                        failure = true;                        break;                    }                }                // Check that that results for the associatorNames call is                // consistent with the associators call and the references                // call.                for(j = 0; j < numResults; ++j)                {                    CIMObjectPath currentAssociatorName =                        associatorNamesResults[j];                    Boolean found = false;                    unsigned int k = 0;                    for(k = 0; k < numResults; ++k)                    {                        if(currentAssociatorName ==                            associatorsResults[k].getPath())                        {                            found = true;                            break;                        }                    }                    if(!found)                    {                        failure = true;                        break;                    }                    found = false;                    for(k = 0; k < numResults; ++k)                    {                        CIMObject referenceInstance = referencesResults[k];                        for(unsigned int x = 0,                            m = referenceInstance.getPropertyCount();                            x < m; ++x)                        {                            CIMProperty currentProp =                                referenceInstance.getProperty(x);                            if(currentProp.getType() == CIMTYPE_REFERENCE)                            {                                CIMObjectPath currentRef;                                currentProp.getValue().get(currentRef);                                currentRef.setHost(                                    currentAssociatorName.getHost());                                if(currentRef == currentAssociatorName)                                {                                    found = true;                                    break;                                }                            }                        }                        if(found)                            break;                    }                    if(!found)                    {                        failure = true;                        break;                    }                }

⌨️ 快捷键说明

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