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

📄 providerregistrationmanager.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    CIMInstance givenInstance = cimInstance;    CIMInstance origInstance;    try    {        //        // get the original instance        //        origInstance = _repository->getInstance(            PEGASUS_NAMESPACENAME_INTEROP,            newInstanceRef,            false,            false,            false,            CIMPropertyList());    }    catch (...)    {        PEG_METHOD_EXIT();        throw;    }    //    // creates the instance which replaces the original    //    CIMInstance instance = origInstance.clone ();    //    // loop through the propertyList replacing each property in the original    // with the properties specified in the given instance    //    for (Uint32 i=0; i<propertyList.size(); i++)    {        Uint32 origPos = instance.findProperty(propertyList[i]);        if (origPos != PEG_NOT_FOUND)        {            //            // Property set in the original            //            CIMProperty OrigProperty = instance.getProperty(origPos);            //            // get the given property value            //            Uint32 givenPos = givenInstance.findProperty(propertyList[i]);            if (givenPos != PEG_NOT_FOUND)            {                //                // Property set in both original and given                //                CIMProperty givenProperty;                givenProperty = givenInstance.getProperty(givenPos);                //                // copy over the property from the given to the original                //                if (includeQualifiers)                {                    //                    // Total property replacement                    //                    instance.removeProperty(origPos);                    instance.addProperty(givenProperty);                }                else                {                    //                    // Replace only the property value                    //                    OrigProperty.setValue(givenProperty.getValue());                    instance.removeProperty(origPos);                    instance.addProperty(OrigProperty);                }            }            else            {                //                // Property set in original and not in given                // just remove the property (set to null)                //                instance.removeProperty(origPos);            }        }        else        {            //            // Property not set in the original            //            //            // Get the given property value            //            Uint32 givenPos = givenInstance.findProperty(propertyList[i]);            if (givenPos != PEG_NOT_FOUND)            {                //                // property set in given and not in original                //                CIMProperty givenProperty;                givenProperty = givenInstance.getProperty(givenPos);                //                // copy over the property from the given to the original                //                if (includeQualifiers)                {                    // Total property copy                    instance.addProperty(givenProperty);                }                else                {                    // copy only the property value                    CIMProperty newProperty(givenProperty.getName(),                                            givenProperty.getValue(),                                            givenProperty.getArraySize(),                                            givenProperty.getReferenceClassName(),                                            givenProperty.getClassOrigin(),                                            givenProperty.getPropagated());                    instance.addProperty(newProperty);                }            }        }    }    //    // delete old instance    //    _deleteInstance(ref, OP_MODIFY);    //    // create the new instance    //    CIMObjectPath cimRef = _createInstance(ref, instance, OP_MODIFY);    //    // if only modify SupportedMethods, do not send notification to    // subscription service    //    if (propertyList.size() == 1 &&        (propertyList[0].equal (CIMName (_PROPERTY_SUPPORTEDMETHODS))))    {        return;    }    //    // get provider types    // if the provider is indication provider, send notification    // to subscription service    Array<Uint16> providerTypes;    instance.getProperty(instance.findProperty(        CIMName (_PROPERTY_PROVIDERTYPE))).getValue().get(providerTypes);    for (Uint32 k=0; k < providerTypes.size(); k++)    {        if (providerTypes[k] == _INDICATION_PROVIDER)        {            _sendModifyNotifyMessage(instance, origInstance);        }    }    PEG_METHOD_EXIT();}Array<Uint16> ProviderRegistrationManager::getProviderModuleStatus(    const String & providerModuleName){    Array<Uint16> _providerModuleStatus;    ReadLock lock(_registrationTableLock);    _providerModuleStatus = _getProviderModuleStatus (providerModuleName);    return (_providerModuleStatus);}Boolean ProviderRegistrationManager::updateProviderModuleStatus(    const String& providerModuleName,    const Array<Uint16>& removeStatus,    const Array<Uint16>& appendStatus,    Array<Uint16>& outStatus){    WriteLock lock(_registrationTableLock);    outStatus = _getProviderModuleStatus (providerModuleName);    Array<Uint16> currentStatus = outStatus;    //    //  Remove any status elements to be removed    //    for (Uint32 j = 0; j < removeStatus.size(); j++)    {        for (Uint32 i = outStatus.size(); i > 0; i--)        {            if (outStatus[i-1] == removeStatus[j])            {                outStatus.remove(i-1);            }        }    }    //    //  Append any status elements to be appended, if not already in the array    //    for (Uint32 k = 0; k < appendStatus.size(); k++)    {        if (!Contains (outStatus, appendStatus[k]))        {            outStatus.append(appendStatus[k]);        }    }    //    // find the instance from repository    //    try    {        Array <CIMKeyBinding> moduleKeyBindings;        moduleKeyBindings.append (CIMKeyBinding            (_PROPERTY_PROVIDERMODULE_NAME,             providerModuleName, CIMKeyBinding::STRING));        CIMObjectPath reference ("", CIMNamespaceName (),            PEGASUS_CLASSNAME_PROVIDERMODULE, moduleKeyBindings);        //        // update repository        //        _repository->setProperty(            PEGASUS_NAMESPACENAME_INTEROP,            reference, _PROPERTY_OPERATIONALSTATUS, outStatus);        //        //  get instance from the repository        //        CIMInstance _instance = _repository->getInstance(            PEGASUS_NAMESPACENAME_INTEROP,            reference,            false,            false,            false,            CIMPropertyList());        //        // remove old entry from table        //        String _moduleKey = _generateKey(providerModuleName, MODULE_KEY);        ProviderRegistrationTable* _entry = 0;        if (_registrationTable->table.lookup(_moduleKey, _entry))        {            delete _entry;            _registrationTable->table.remove(_moduleKey);        }        //        // add the updated instance to the table        //        Array<CIMInstance> instances;        instances.append(_instance);        _addInstancesToTable(_moduleKey, instances);    }    catch (const Exception & e)    {        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Failed to update provider module status: " + e.getMessage());        return false;    }    catch (...)    {        return (false);    }    PEG_AUDIT_LOG(logUpdateProvModuleStatus(providerModuleName, currentStatus,        outStatus));    return (true);}void ProviderRegistrationManager::_initialRegistrationTable(){    CIMInstance instance;    CIMObjectPath reference;    String providerName;    String providerModuleName;    String className;    String capabilityKey;    Array<String> namespaces;    Array<Uint16> providerType;    Array<String> supportedMethods;    Array<CIMInstance> cimNamedInstances;    Array<String> indicationDestinations;    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,                     "ProviderRegistrationManager::_initialRegistrationTable()");    try    {        //        // get all instances of providerModule class        //        Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL4,            "nameSpace = %s; className = %s",            (const char *)                PEGASUS_NAMESPACENAME_INTEROP.getString().getCString(),            (const char *)                PEGASUS_CLASSNAME_PROVIDERMODULE.getString().getCString());        cimNamedInstances = _repository->enumerateInstancesForClass(            PEGASUS_NAMESPACENAME_INTEROP,            PEGASUS_CLASSNAME_PROVIDERMODULE,            false,            false,            false,            CIMPropertyList());        Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL4,                      "PG_ProviderModule class has = %d instances",                      cimNamedInstances.size());        for(Uint32 i = 0, n=cimNamedInstances.size(); i < n; i++)        {            Array<Uint16> status;            Array<CIMInstance> instances;            instance = cimNamedInstances[i];            reference = cimNamedInstances[i].getPath ();            String vendor, version, interfaceType, interfaceVersion, location;            Boolean userContextSpecified = false;            Uint16 userContext = 0;            //            // Name, Version, InterfaceType, InterfaceVersion, and Location            // properties must be set, otherwise, property OperationalStatus            // is set to Error.            //            Uint32 posModuleName = instance.findProperty(_PROPERTY_PROVIDERMODULE_NAME);            Uint32 posVendor = instance.findProperty(_PROPERTY_VENDOR);            Uint32 posVersion = instance.findProperty(_PROPERTY_VERSION);            Uint32 posInterfaceType = instance.findProperty(_PROPERTY_INTERFACETYPE);            Uint32 posInterfaceVersion = instance.findProperty(_PROPERTY_INTERFACEVERSION);            Uint32 posLocation = instance.findProperty(_PROPERTY_LOCATION);            Uint32 posUserContext = instance.findProperty(                PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);            Uint32 posDesignatedUser = instance.findProperty(                PEGASUS_PROPERTYNAME_MODULE_DESIGNATEDUSER);            if (posModuleName != PEG_NOT_FOUND)            {                // get provider module name                instance.getProperty(posModuleName).getValue().get(providerModuleName);            }            else            {                providerModuleName.clear();            }            if (posVendor != PEG_NOT_FOUND)            {                instance.getProperty(posVendor).getValue().get(vendor);            }            if (posVersion != PEG_NOT_FOUND)            {                instance.getProperty(posVersion).getValue().get(version);            }            if (posInterfaceType != PEG_NOT_FOUND)            {                instance.getProperty(posInterfaceType).getValue().get(interfaceType);            }            if (posInterfaceVersion != PEG_NOT_FOUND)            {                instance.getProperty(posInterfaceVersion).getValue().get(interfaceVersion);            }            if (posLocation != PEG_NOT_FOUND)            {                instance.getProperty(posLocation).getValue().get(location);            }            if (posUserContext != PEG_NOT_FOUND)            {                CIMValue userContextValue =                    instance.getProperty(posUserContext).getValue();                if (!userContextValue.isNull())                {                    userContextSpecified = true;                    userContextValue.get(userContext);                }            }            if (posModuleName == PEG_NOT_FOUND || providerModuleName.size() == 0 ||                posVendor == PEG_NOT_FOUND || vendor.size() == 0 ||                posVersion == PEG_NOT_FOUND || version.size() == 0 

⌨️ 快捷键说明

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