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

📄 interopprovider.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.////==============================================================================/////////////////////////////////////////////////////////////////////////////////  Interop Provider - This provider services those classes from the//  DMTF Interop schema in an implementation compliant with the SMI-S v1.1//  Server Profile////  Please see PG_ServerProfile20.mof in the directory//  $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the//  classes supported by this control provider.////  Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP //  namespace. There is a test on each operation that returns //  the Invalid Class CIMDError//  This is a control provider and as such uses the Tracer functions//  for data and function traces.  Since we do not expect high volume//  use we added a number of traces to help diagnostics.///////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/PegasusVersion.h>#include <cctype>#include <iostream>#include "InteropProvider.h"#include "InteropProviderUtils.h"#include "InteropConstants.h"#include <Pegasus/Common/StatisticalData.h>PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN/***************************************************************************** * * The following are constants representing property names for the classes * managed by the Interop Provider. Where multiple classes have properties of * the same name, there will be a common CIMName object defined, and a macro * defined that points to the common CIMName object, but whose macro name * reflects the class in which the property is used. * *****************************************************************************///// Constructor for the InteropProvider control provider//InteropProvider::InteropProvider(CIMRepository * rep) : repository(rep),    hostName(System::getHostName()), providerInitialized(false),    profileIds(Array<String>()), conformingElements(Array<CIMNameArray>()),    elementNamespaces(Array<CIMNamespaceArray>()){    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider");#ifndef PEGASUS_DISABLE_PERFINST    try    {        initProvider();    }    catch(const Exception & e)    {        // Provider initialization may fail if the repository is not        // populated    }#endif        PEG_METHOD_EXIT();}//// Local version of getInstance to be used by other functions in the the// provider. Returns a single instance. Note that it always returns an// instance. If none was found, it is uninialitized.//CIMInstance InteropProvider::localGetInstance(    const OperationContext & context,    const CIMObjectPath & instanceName,    const CIMPropertyList & propertyList){    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance");    Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,        "%s getInstance. instanceName= %s , PropertyList= %s",        thisProvider,        (const char *)instanceName.toString().getCString(),        (const char *)propertyListToString(propertyList).getCString());    // Test if we're looking for something outside of our namespace. This will    // happen during associators calls from PG_RegisteredProfile instances    // through the PG_ElementConformsToProfile association    CIMNamespaceName opNamespace = instanceName.getNameSpace();    CIMName opClass = instanceName.getClassName();    if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP &&        opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE)    {        AutoMutex mut(interopMut);        return cimomHandle.getInstance(context, opNamespace,            instanceName, false, false, false, propertyList);    }    // Create reference from host, namespace, class components of    // instance name    CIMObjectPath ref;    ref.setHost(instanceName.getHost());    ref.setClassName(opClass);    ref.setNameSpace(opNamespace);    // Enumerate instances for this class. Returns all instances    // Note that this returns paths setup and instances already    // filtered per the input criteria.    Array<CIMInstance> instances =  localEnumerateInstances(        context,        ref,        propertyList);    // deliver a single instance if found.    CIMInstance retInstance;    bool found = false;    for(Uint32 i = 0, n = instances.size(); i < n; i++)    {        CIMObjectPath currentInstRef = instances[i].getPath();        currentInstRef.setHost(instanceName.getHost());        currentInstRef.setNameSpace(instanceName.getNameSpace());        if(instanceName == currentInstRef)        {            retInstance = instances[i];            found = true;            break;        }    }    if(!found)    {      cout << "Coule not find instance: " << instanceName.toString() << endl;    }    PEG_METHOD_EXIT();    return retInstance;}//// Local version of enumerateInstances to be used by other functions in the// provider. Note that this delivers instances as a group rather than one// at a time. This design point may need to be revisited if this provider// is used in environments such that returning segmented responses would have// significant performance advantages. For now, that doesn't seem to be the// case.//Array<CIMInstance> InteropProvider::localEnumerateInstances(    const OperationContext & context,    const CIMObjectPath & ref,    const CIMPropertyList& propertyList){    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,        "InteropProvider::localEnumerateInstances()");    const CIMName & className = ref.getClassName();    Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,        "%s enumerateInstances. referenc= %s , PropertyList= %s",        thisProvider,        (const char *)className.getString().getCString(),        (const char *)propertyListToString(propertyList).getCString());    // Verify that ClassName is correct and get its enum value    TARGET_CLASS classEnum  = translateClassInput(className);    Array<CIMInstance> instances;    switch(classEnum)    {        case PG_OBJECTMANAGER:        {            instances.append(getObjectManagerInstance());            break;        }        case PG_CIMXMLCOMMUNICATIONMECHANISM:        {            instances = enumCIMXMLCommunicationMechanismInstances();            break;        }        case PG_NAMESPACEINMANAGER:        {            instances = enumNamespaceInManagerInstances();            break;        }        case PG_COMMMECHANISMFORMANAGER:        {            instances = enumCommMechanismForManagerInstances();            break;        }        case PG_NAMESPACE:        {            instances = enumNamespaceInstances();            break;        }        case PG_REGISTEREDPROFILE:        {            instances = enumRegisteredProfileInstances();            break;        }        case PG_REGISTEREDSUBPROFILE:        {            instances = enumRegisteredSubProfileInstances();            break;        }        case PG_REFERENCEDPROFILE:        {            instances = enumReferencedProfileInstances();            break;        }        case PG_ELEMENTCONFORMSTOPROFILE:        {            instances = enumElementConformsToProfileInstances(context,                ref.getNameSpace());            break;        }        case PG_SUBPROFILEREQUIRESPROFILE:        {            instances = enumSubProfileRequiresProfileInstances();            break;        }        case PG_SOFTWAREIDENTITY:        {            instances = enumSoftwareIdentityInstances();            break;        }        case PG_ELEMENTSOFTWAREIDENTITY:        {            instances = enumElementSoftwareIdentityInstances();            break;        }        case PG_INSTALLEDSOFTWAREIDENTITY:        {            instances = enumInstalledSoftwareIdentityInstances();            break;        }        case PG_COMPUTERSYSTEM:        {            instances.append(getComputerSystemInstance());            break;        }        case PG_HOSTEDOBJECTMANAGER:        {            instances.append(getHostedObjectManagerInstance());            break;        }

⌨️ 快捷键说明

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