📄 software.cpp
字号:
//%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 "InteropProvider.h"#include "InteropProviderUtils.h"#include "InteropConstants.h"#include <Pegasus/Common/PegasusVersion.h>PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN// Property names for SoftwareIdentity#define SOFTWAREIDENTITY_PROPERTY_NAME COMMON_PROPERTY_NAME#define SOFTWAREIDENTITY_PROPERTY_ELEMENTNAME COMMON_PROPERTY_ELEMENTNAME#define SOFTWAREIDENTITY_PROPERTY_CAPTION COMMON_PROPERTY_CAPTION#define SOFTWAREIDENTITY_PROPERTY_MAJORVERSION \ PROVIDERMODULE_PROPERTY_MAJORVERSION#define SOFTWAREIDENTITY_PROPERTY_MINORVERSION \ PROVIDERMODULE_PROPERTY_MINORVERSION#define SOFTWAREIDENTITY_PROPERTY_REVISIONNUMBER \ PROVIDERMODULE_PROPERTY_REVISIONNUMBER#define SOFTWAREIDENTITY_PROPERTY_BUILDNUMBER \ PROVIDERMODULE_PROPERTY_BUILDNUMBERconst CIMName SOFTWAREIDENTITY_PROPERTY_INSTANCEID("InstanceID");const CIMName SOFTWAREIDENTITY_PROPERTY_VERSION("VersionString");const CIMName SOFTWAREIDENTITY_PROPERTY_MANUFACTURER("Manufacturer");const CIMName SOFTWAREIDENTITY_PROPERTY_CLASSIFICATIONS( "Classifications");//// Given the necessary software information, this function constructs an// instance of the PG_SoftwareIdentity class.//CIMInstance InteropProvider::buildSoftwareIdentity( const String & module, const String & provider, const String & vendor, const String & version, Uint16 majorVersion, Uint16 minorVersion, Uint16 revisionNumber, Uint16 buildNumber, bool extendedVersionSupplied, const String & interfaceType, const String & elementName, const String & caption){ String instanceId(module + "+" + provider); String name(provider + " (" + interfaceType + ")"); // Use double-ifs to prevent locking for every request if(softwareIdentityClass.isUninitialized()) { AutoMutex autoMut(interopMut); if(softwareIdentityClass.isUninitialized()) { softwareIdentityClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, false, true, false); } } CIMInstance softwareIdentity = softwareIdentityClass.buildInstance(false, false, CIMPropertyList()); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_INSTANCEID, instanceId); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_NAME, name); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_VERSION, version); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_MANUFACTURER, vendor); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_CLASSIFICATIONS, providerClassifications); if(extendedVersionSupplied) { setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_MAJORVERSION, majorVersion); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_MINORVERSION, minorVersion); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_REVISIONNUMBER, revisionNumber); setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_BUILDNUMBER, buildNumber); } if(elementName.size() > 0) { setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_ELEMENTNAME, elementName); } if(caption.size() > 0) { setPropertyValue(softwareIdentity, SOFTWAREIDENTITY_PROPERTY_CAPTION, caption); } softwareIdentity.setPath(softwareIdentity.buildPath(softwareIdentityClass)); return softwareIdentity;}//// Given an instance of PG_Provider, this method extracts information needed to// construct SoftwareIdentity instances for that provider.//void InteropProvider::extractSoftwareIdentityInfo( const CIMInstance & providerInstance, String & moduleName, String & providerName, String & vendor, String & version, Uint16 & majorVersion, Uint16 & minorVersion, Uint16 & revisionNumber, Uint16 & buildNumber, bool & extendedVersionSupplied, String & interfaceType, String & elementName, String & caption){ // Get the module and provider name from the PG_ProviderInstance supplied moduleName = getRequiredValue<String>(providerInstance, PROVIDER_PROPERTY_PROVIDERMODULENAME); providerName = getRequiredValue<String>(providerInstance, PROVIDER_PROPERTY_NAME); // Now retrieve the software info from the desired PG_ProviderModule Array<CIMName> propertyList; propertyList.append(PROVIDERMODULE_PROPERTY_NAME); propertyList.append(PROVIDERMODULE_PROPERTY_VENDOR); propertyList.append(PROVIDERMODULE_PROPERTY_VERSION); propertyList.append(PROVIDERMODULE_PROPERTY_INTERFACETYPE); // Need to find the ProviderModule instance for this provider to retrieve // version information. Array<CIMInstance> providerModules = repository->enumerateInstancesForClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDERMODULE, true, false, false, CIMPropertyList(propertyList)); Uint32 moduleIndex = PEG_NOT_FOUND; for(Uint32 i = 0, n = providerModules.size(); i < n; ++i) { CIMInstance & currentModule = providerModules[i]; Uint32 index = currentModule.findProperty( PROVIDERMODULE_PROPERTY_NAME); if(index != PEG_NOT_FOUND) { String currentModuleName; currentModule.getProperty(index).getValue().get(currentModuleName); if(moduleName == currentModuleName) { moduleIndex = i; break; } } } if(moduleIndex == PEG_NOT_FOUND) { throw CIMOperationFailedException( "Could not retrieve provider module for provider " + providerInstance.getPath().toString()); } CIMInstance & providerModule = (CIMInstance &)providerModules[moduleIndex]; version = getRequiredValue<String>(providerModule, PROVIDERMODULE_PROPERTY_VERSION); vendor = getRequiredValue<String>(providerModule, PROVIDERMODULE_PROPERTY_VENDOR); interfaceType = getRequiredValue<String>(providerModule, PROVIDERMODULE_PROPERTY_INTERFACETYPE); // Extract the element name if present Uint32 elementNameIndex = providerInstance.findProperty( PROVIDER_PROPERTY_ELEMENTNAME); if(elementNameIndex != PEG_NOT_FOUND) { CIMValue elementNameValue( providerInstance.getProperty(elementNameIndex).getValue()); if(!elementNameValue.isNull()) { elementNameValue.get(elementName); } } // Extract the caption if present Uint32 captionIndex = providerInstance.findProperty( PROVIDER_PROPERTY_CAPTION); if(elementNameIndex != PEG_NOT_FOUND) { CIMValue captionValue( providerInstance.getProperty(captionIndex).getValue()); if(!captionValue.isNull()) { captionValue.get(caption); } } // Now see if optional extended version information is available extendedVersionSupplied = false; Uint32 majorIndex = providerInstance.findProperty( PROVIDERMODULE_PROPERTY_MAJORVERSION); if(majorIndex != PEG_NOT_FOUND) { CIMValue majorValue = providerInstance.getProperty(majorIndex).getValue(); if(!majorValue.isNull()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -