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

📄 serverprofile.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            }            if(failure)            {                exitFailure(                    String("Association Operations returned inconsistent ") +                    String("results for instance ") +                    currentPath.toString());            }        }        catch(CIMException & e)        {          exitFailure(String("Caught exception while performing ") +            String("association operations on instance ") +            currentPath.toString() + String(": ") + e.getMessage());        }    }}void testAssociationClass(CIMClient & client, const CIMName & className){    Array<CIMInstance> instances = testAnyClass(client, className);    for(unsigned int i = 0, n = instances.size(); i < n; ++i)    {        //        // Now make sure that the references are valid and that association        // traversal between them is working properly.        //        CIMObjectPath referenceA;        CIMObjectPath referenceB;        CIMInstance currentInstance = instances[i];        CIMObjectPath currentInstanceName = currentInstance.getPath();        if(currentInstanceName.getNameSpace().isNull())            currentInstanceName.setNameSpace(interopNamespace);        for(unsigned int j = 0, m = currentInstance.getPropertyCount();            j < m; ++j)        {            CIMProperty currentProp = currentInstance.getProperty(j);            if(currentProp.getValue().getType() == CIMTYPE_REFERENCE)            {                if(referenceA.getKeyBindings().size() == 0)                {                    currentProp.getValue().get(referenceA);                }                else                {                    currentProp.getValue().get(referenceB);                    break;                }            }        }        if(referenceA.getKeyBindings().size() == 0 ||            referenceB.getKeyBindings().size() == 0)        {            exitFailure(                String("Could not find reference properties for ") +                String("association: ") +                currentInstanceName.toString());        }        try        {            client.getInstance(referenceA.getNameSpace(), referenceA);            client.getInstance(referenceB.getNameSpace(), referenceB);        }        catch(CIMException &)        {            exitFailure(String("Could not get instances for association : ") +                currentInstanceName.toString());        }        Boolean associationFailure = false;        try        {            Array<CIMObjectPath> results = client.associatorNames(                referenceA.getNameSpace(), referenceA, className);            Boolean found = false;            for(unsigned int j = 0, m = results.size(); j < m; ++j)            {                CIMObjectPath result = results[j];                result.setHost(referenceB.getHost());                result.setNameSpace(referenceB.getNameSpace());                if(result == referenceB)                {                    found = true;                    break;                }            }            if(found)            {                results = client.associatorNames(referenceB.getNameSpace(),                    referenceB, className);                for(unsigned int j = 0, m = results.size(); j < m; ++j)                {                    CIMObjectPath result = results[j];                    result.setHost(referenceA.getHost());                    result.setNameSpace(referenceA.getNameSpace());                    if(result == referenceA)                    {                        found = true;                        break;                    }                }            }            if(!found)            {                associationFailure = true;            }        }        catch(CIMException & e)        {            cout << "Exception: " << e.getMessage() << endl;            associationFailure = true;        }        if(associationFailure)        {            exitFailure(String("Association traversal failed between ") +                String("instances of association: ") +                currentInstanceName.toString());        }        Boolean referencesFailure = false;        try        {            Array<CIMObjectPath> results = client.referenceNames(                referenceA.getNameSpace(), referenceA, className);            Boolean found = false;            for(unsigned int j = 0, m = results.size(); j < m; ++j)            {                CIMObjectPath currentPath = results[j];                if(currentPath.getNameSpace().isNull())                    currentPath.setNameSpace(interopNamespace);                if(currentPath.getHost().size() != 0)                    currentPath.setHost(String::EMPTY);                if(currentPath == currentInstanceName)                {                    found = true;                    break;                }            }            if(found)            {                results = client.referenceNames(referenceB.getNameSpace(),                    referenceB, className);                for(unsigned int j = 0, m = results.size(); j < m; ++j)                {                    CIMObjectPath currentPath = results[j];                    if(currentPath.getNameSpace().isNull())                        currentPath.setNameSpace(interopNamespace);                    if(currentPath.getHost().size() != 0)                        currentPath.setHost(String::EMPTY);                    if(currentPath == currentInstanceName)                    {                        found = true;                        break;                    }                }            }            if(!found)            {                referencesFailure = true;            }        }        catch(CIMException &)        {            referencesFailure = true;        }        if(referencesFailure)        {            exitFailure(String("References operation failed for ") +                String("instances of association: ") +                currentInstanceName.toString());        }    }}/////////////////////////////////////////////////////////////////    MAIN///////////////////////////////////////////////////////////////int main(int argc, char** argv){    // Create a locally-connected client    CIMClient client;    try    {        client.connectLocal();    }    catch(Exception &)    {        exitFailure(String("Could not connect to server"));    }    testInstanceClass(client, CIMName("CIM_ComputerSystem"));    testInstanceClass(client, CIMName("CIM_ObjectManager"));    testInstanceClass(client, CIMName("CIM_RegisteredSubProfile"));    testInstanceClass(client, CIMName("CIM_RegisteredProfile"));    testInstanceClass(client, CIMName("CIM_CIMXMLCommunicationMechanism"));    testInstanceClass(client, CIMName("CIM_Namespace"));    testInstanceClass(client, CIMName("CIM_SoftwareIdentity"));    testAssociationClass(client, CIMName("CIM_HostedService"));    testAssociationClass(client, CIMName("CIM_ElementConformsToProfile"));    testAssociationClass(client, CIMName("CIM_SubprofileRequiresProfile"));    testAssociationClass(client, CIMName("CIM_ReferencedProfile"));    testAssociationClass(client, CIMName("CIM_ElementSoftwareIdentity"));    testAssociationClass(client, CIMName("CIM_CommMechanismForManager"));    //testAssociationTraversal(client);    return 0;}// END OF FILE

⌨️ 快捷键说明

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