📄 registeredprofile.cpp
字号:
// String profileId = buildProfileInstanceId(profileOrgName, profileName, profileVersions[j]); String dependentId = buildProfileInstanceId(dependentOrgName, dependentName, dependentVersions[j]); String instanceId = profileId + ":" + dependentId; bool unique = true; for(Uint32 k = 0, x = instanceIds.size(); k < x; ++k) { if(instanceIds[k] == instanceId) { unique = false; break; } } if(unique) { // This ReferencedProfile association hasn't been created yet. // Adding this to the list of instanceIds ensures that a // duplicate won't be created later. instanceIds.append(instanceId); // Now find out whether the profile and dependent profiles are // RegisteredProfile or RegisteredSubProfile instances. CIMName profileType; if(currentProfile >= 1000) profileType = PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE; else profileType = PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE; CIMName dependentType; if(currentDependent >= 1000) dependentType = PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE; else dependentType = PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE; // // Create the actual ReferencedProfile association instance. // instances.append(buildDependencyInstance( profileId, profileType, dependentId, dependentType, referencedProfileClass)); } } } return instances;}//// Given an instance of PG_ProviderProfileCapabilities, this method retrieves// the values necessary for constructing instances of PG_RegisteredProfile,// PG_RegisteredSubProfile, and all of their associations.//String extractProfileInfo(const CIMInstance & profileCapabilities, const CIMClass & capabilitiesClass, const CIMClass & profileClass, String & name, String & version, Uint16 & organization, String & organizationName, Array<String> & subprofileNames, Array<String> & subprofileVersions, Array<Uint16> & subprofileOrganizations, Array<String> & subprofileOrganizationNames, bool noSubProfileInfo){ Uint16 registeredProfile = getRequiredValue<Uint16>(profileCapabilities, PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE); // Retrieve information about the RegisteredProfile if(registeredProfile == 0) // Other { name = getRequiredValue<String>(profileCapabilities, PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDPROFILE); organizationName = getRequiredValue<String>(profileCapabilities, PROFILECAPABILITIES_PROPERTY_OTHERPROFILEORGANIZATION); } else { // Retrieve the profile and organization name from the ValueMap String mappedProfileName = translateValue(registeredProfile, PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE, VALUEMAP_QUALIFIERNAME, VALUES_QUALIFIERNAME, capabilitiesClass); if(mappedProfileName.size() == 0) { throw CIMOperationFailedException( profileCapabilities.getPath().toString() + " has invalid property " + PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE.getString()); } Uint32 index = mappedProfileName.find(Char16(':')); PEGASUS_ASSERT(index != PEG_NOT_FOUND); organizationName = mappedProfileName.subString(0, index); name = mappedProfileName.subString(index+1); } version = getRequiredValue<String>(profileCapabilities, PROFILECAPABILITIES_PROPERTY_PROFILEVERSION); // Translate the organization name into the organization ValueMap value // that will be used to create a PG_RegisteredProfile instance for this // profile. String organizationMapping = translateValue(organizationName, REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION, VALUES_QUALIFIERNAME, VALUEMAP_QUALIFIERNAME, profileClass); if(organizationMapping.size() == 0) { organization = 1; } else { organization = atoi((const char *)organizationMapping.getCString()); } // Check whether information about the subprofiles associated to the // registered profile is requested. if(!noSubProfileInfo) { // Retrieve the ValueMap values for the subprofiles associated with the // RegisteredProfile. Array<Uint16> registeredSubprofiles = getRequiredValue<Array<Uint16> >(profileCapabilities, PROFILECAPABILITIES_PROPERTY_REGISTEREDSUBPROFILES); // It is possible that a subprofile could contain a different version // number than its parent profile, so retrieve the list. If the // SubprofileVersions property isn't present, is NULL, or is an empty // array, then the version from the parent profile will be used. Uint32 subprofileVersionsIndex = profileCapabilities.findProperty( PROFILECAPABILITIES_PROPERTY_SUBPROFILEVERSIONS); if(subprofileVersionsIndex != PEG_NOT_FOUND) { CIMValue val = profileCapabilities.getProperty(subprofileVersionsIndex).getValue(); if(!val.isNull()) { val.get(subprofileVersions); Uint32 numVersions = subprofileVersions.size(); if(numVersions != 0 && numVersions != registeredSubprofiles.size()) { throw CIMOperationFailedException( profileCapabilities.getPath().toString() + " does not contain enough entries in property " + PROFILECAPABILITIES_PROPERTY_SUBPROFILEVERSIONS .getString()); } } } // Either none were supplied or the property wasn't supplied, so // use the version value from the scoping profile. if(subprofileVersions.size() == 0) { // Add a version string for each registered subprofile for(unsigned int i = 0, n = registeredSubprofiles.size(); i < n; ++i) { subprofileVersions.append(version); } } // Retrieve any specified "Other" Registered Subprofiles. Array<String> otherRegisteredSubprofiles; Uint32 otherSubprofileIndex = profileCapabilities.findProperty( PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDSUBPROFILES); Uint32 numOtherSubprofiles = 0; if(otherSubprofileIndex != PEG_NOT_FOUND) { profileCapabilities.getProperty(otherSubprofileIndex).getValue(). get(otherRegisteredSubprofiles); numOtherSubprofiles = otherRegisteredSubprofiles.size(); } Array<String> otherSubprofileOrganizations; Uint32 otherOrganizationsIndex = profileCapabilities.findProperty( PROFILECAPABILITIES_PROPERTY_OTHERSUBPROFILEORGANIZATIONS); Uint32 numOrgs = 0; if(otherOrganizationsIndex != PEG_NOT_FOUND) { CIMValue val = profileCapabilities.getProperty(otherOrganizationsIndex).getValue(); if(!val.isNull()) { val.get(otherSubprofileOrganizations); numOrgs = otherSubprofileOrganizations.size(); } } // There must be corresponding entries in the // OtherRegisteredSubprofiles and OtherSubprofileOrganizations // properties if(numOrgs != numOtherSubprofiles) { throw CIMOperationFailedException( profileCapabilities.getPath().toString() + " does not contain enough entries in property " + PROFILECAPABILITIES_PROPERTY_OTHERSUBPROFILEORGANIZATIONS .getString()); } // Now loop through all of the retrieved subprofile information and // set the output parameters. otherSubprofileIndex = 0; for(Uint32 k = 0, x = registeredSubprofiles.size(); k < x; ++k) { Uint16 subprofileMapping = registeredSubprofiles[k]; String subprofileName; String subprofileOrg; if(subprofileMapping == 0) // "Other" { // Retrieve the subprofile name and organization from the // arrays containing the "other" information if(otherSubprofileIndex == numOtherSubprofiles) { throw CIMOperationFailedException( profileCapabilities.getPath().toString() + " does not contain enough entries in property " + PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDSUBPROFILES .getString()); } subprofileName = otherRegisteredSubprofiles[otherSubprofileIndex]; subprofileOrg = otherSubprofileOrganizations[otherSubprofileIndex++]; } else { // Retrieve the subprofile name and organization from the // ValueMap value. subprofileName = translateValue( subprofileMapping, PROFILECAPABILITIES_PROPERTY_REGISTEREDSUBPROFILES, VALUEMAP_QUALIFIERNAME, VALUES_QUALIFIERNAME, capabilitiesClass); if(subprofileName.size() == 0) { throw CIMOperationFailedException( profileCapabilities.getPath().toString() + " has invalid property " + PROFILECAPABILITIES_PROPERTY_REGISTEREDSUBPROFILES. getString()); } Uint32 orgIndex = subprofileName.find(Char16(':')); if(orgIndex != PEG_NOT_FOUND) { subprofileOrg = subprofileName.subString(0, orgIndex); subprofileName = subprofileName.subString(orgIndex+1); } else { subprofileOrg = organizationName; } } subprofileNames.append(subprofileName); subprofileOrganizationNames.append(subprofileOrg); // Translate the organization name into an integral value String orgMapping = translateValue(organizationName, REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION, VALUES_QUALIFIERNAME, VALUEMAP_QUALIFIERNAME, profileClass); if(organizationMapping.size() == 0) { subprofileOrganizations.append(Uint16(1)); // "Other" } else { subprofileOrganizations.append( atoi((const char *)organizationMapping.getCString())); } } } return buildProfileInstanceId(organizationName, name, version);}PEGASUS_NAMESPACE_END// END_OF_FILE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -