📄 registeredprofile.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"PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN//// Values and ValueMap qualifier names//static const CIMName VALUES_QUALIFIERNAME("Values");static const CIMName VALUEMAP_QUALIFIERNAME("ValueMap");// Property names for RegisteredProfile class#define REGISTEREDPROFILE_PROPERTY_INSTANCEID COMMON_PROPERTY_INSTANCEIDconst CIMName REGISTEREDPROFILE_PROPERTY_ADVERTISETYPES( "AdvertiseTypes");const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDNAME( "RegisteredName");const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDVERSION( "RegisteredVersion");const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION( "RegisteredOrganization");const CIMName REGISTEREDPROFILE_PROPERTY_OTHERREGISTEREDORGANIZATION( "OtherRegisteredOrganization");// Property names for Provider Referenced Profilesconst CIMName REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILES( "RegisteredProfiles");const CIMName REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILES( "DependentProfiles");const CIMName REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILEVERSIONS( "RegisteredProfileVersions");const CIMName REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILEVERSIONS( "DependentProfileVersions");const CIMName REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILES( "OtherRegisteredProfiles");const CIMName REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILES( "OtherDependentProfiles");const CIMNameREFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILEORGANIZATIONS( "OtherRegisteredProfileOrganizations");const CIMNameREFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILEORGANIZATIONS( "OtherDependentProfileOrganizations");//// Method that constructs a CIMInstance object representing an instance of the// PG_RegisteredProfile or PG_RegisteredSubProfile class (depending on the// profileClass parameter).//CIMInstance InteropProvider::buildRegisteredProfile( const String & instanceId, const String & profileName, const String & profileVersion, Uint16 profileOrganization, const String & otherProfileOrganization, const CIMClass & profileClass){ // Form the skeleton instance CIMInstance instance = profileClass.buildInstance( false, false, CIMPropertyList()); // setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_INSTANCEID, instanceId); setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_REGISTEREDNAME, profileName); setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_REGISTEREDVERSION, profileVersion); setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION, profileOrganization); if(profileOrganization == 1) // Other { setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_OTHERREGISTEREDORGANIZATION, otherProfileOrganization); } // Determine if SLP is currently enabled in the server. If so, specify // SLP as the advertise type. Array<Uint16> advertiseTypes; ConfigManager* configManager = ConfigManager::getInstance(); if (String::equal(configManager->getCurrentValue("slp"), "true")) { advertiseTypes.append(3); // Advertised via SLP } else { advertiseTypes.append(2); // Not advertised } setPropertyValue(instance, REGISTEREDPROFILE_PROPERTY_ADVERTISETYPES, advertiseTypes); CIMObjectPath objPath = instance.buildPath(profileClass); objPath.setHost(hostName); objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); instance.setPath(objPath); return instance;}//// Generic method for retrieving instances of profile-related classes. This is// currently used for enumerating the RegisteredProfle, RegisteredSubprofile,// and SubprofileRequiresProfile classes.//Array<CIMInstance> InteropProvider::getProfileInstances( const CIMName & profileType, const Array<String> & defaultSniaProfiles){ Array<CIMInstance> instances; bool isRequiresProfileOperation = profileType.equal( PEGASUS_CLASSNAME_PG_SUBPROFILEREQUIRESPROFILE); Array<CIMInstance> profileCapabilities = repository->enumerateInstancesForClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES); Array<String> instanceIDs; CIMClass registeredProfileClass; CIMClass subprofileReqProfileClass; if(isRequiresProfileOperation) { registeredProfileClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, false, true, false); subprofileReqProfileClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_SUBPROFILEREQUIRESPROFILE, false, true, false); } else { registeredProfileClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, profileType, false, true, false); } // // First build instances based on vendor-created // ProviderProfileCapabilities instances. // Uint32 i = 0; Uint32 n = profileCapabilities.size(); for(; i < n; ++i) { // Extract the useful properties String profileName; Uint16 profileOrganization = 0; String profileVersion; String profileOrganizationName; bool getRegisteredProfileInfo = profileType.equal( PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); CIMInstance & currentCapabilities = profileCapabilities[i]; Array<String> profileNames; Array<String> profileVersions; Array<Uint16> profileOrganizations; Array<String> profileOrganizationNames; String profileId = extractProfileInfo(currentCapabilities, profileCapabilitiesClass, registeredProfileClass, profileName, profileVersion, profileOrganization, profileOrganizationName, profileNames, profileVersions, profileOrganizations, profileOrganizationNames, getRegisteredProfileInfo); Array<String> tmpInstanceIds; if(getRegisteredProfileInfo) { tmpInstanceIds.append(profileId); profileNames.append(profileName); profileVersions.append(profileVersion); profileOrganizations.append(profileOrganization); profileOrganizationNames.append(profileOrganizationName); } else { for(Uint32 j = 0, m = profileNames.size(); j < m; ++j) { tmpInstanceIds.append(buildProfileInstanceId( profileOrganizationNames[j], profileNames[j], profileVersions[j])); } } for(Uint32 j = 0, m = tmpInstanceIds.size(); j < m; ++j) { // See if we've already retrieved an equivalent RegisteredSubProfile bool unique = true; String tmpId; if(isRequiresProfileOperation) tmpId = profileId + ":" + tmpInstanceIds[j]; else tmpId = tmpInstanceIds[j]; for(Uint32 k = 0, x = instanceIDs.size(); k < x; ++k) { if(instanceIDs[k] == tmpId) { unique = false; break; } } if(unique) { if(isRequiresProfileOperation) { instances.append(buildDependencyInstance( profileId, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, tmpInstanceIds[j], PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE, subprofileReqProfileClass)); } else { String subprofileVersion = profileVersion; if(profileVersions.size() >= j) { subprofileVersion = profileVersions[j]; } instances.append(buildRegisteredProfile(tmpId, profileNames[j], subprofileVersion, profileOrganizations[j], profileOrganizationNames[j], registeredProfileClass)); } instanceIDs.append(tmpId); } } } // // Now build instances for the Profiles and/or Subprofiles that Pegasus // implements in this provider.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -