version 1.36, 2005/05/24 10:42:51
|
version 1.57.4.1, 2006/01/10 18:34:04
|
|
|
// CIM_ObjectManagerCommunicationMechanism | // CIM_ObjectManagerCommunicationMechanism |
// CIM_CIMXMLCommunicationMechanism | // CIM_CIMXMLCommunicationMechanism |
// CIM_ProtocolAdapter (Note: Removed because deprecated class in cim 2.9) | // CIM_ProtocolAdapter (Note: Removed because deprecated class in cim 2.9) |
// CIM_Namespace (Effective Pegasus 2.4 we use PG_Namespace which |
// CIM_Namespace -- Only creates are allowed directly against this class. |
// is a subclass of CIM_Namespace with additional properties for |
// This allows the publice class CIM_Namespace to be used to |
// shared namespaces. |
// create namespaces. Modifies, deletes must use the returned |
|
// paths. Enumerates references, etc. all use hiearchy. |
|
// NOTE: Changes the class to PG_Namespace and returns that |
|
// objectpath |
|
// |
|
// PG_Namespace - Pegasus particular subclass of CIM_Namespace that |
|
// add the parameters for shared namespaces |
|
// |
|
// PG_CIMXMLCommunicationMechanism - Pegasus subclass of |
|
// CIM_CIMXMLCommunicationMechanism that adds support for passing |
|
// additional communication parameters (ie. port, https vs. http, etc.) |
// | // |
// It also services the Interop associations tied to these classes | // It also services the Interop associations tied to these classes |
// including: | // including: |
// CIM_NamespaceInManager | // CIM_NamespaceInManager |
// ... | // ... |
|
// 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 | // This is a control provider and as such uses the Tracer functions |
// for data and function traces. Since we do not expect high volume | // for data and function traces. Since we do not expect high volume |
// use we added a number of traces to help diagnostics. | // use we added a number of traces to help diagnostics. |
|
|
3. Review the key parameters on create, etc. to be sort out which are | 3. Review the key parameters on create, etc. to be sort out which are |
required from user and which we can supply. I think we are asking too | required from user and which we can supply. I think we are asking too |
much of the user right now. | much of the user right now. |
|
|
*/ | */ |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
#include <Pegasus/Common/OperationContext.h> | #include <Pegasus/Common/OperationContext.h> |
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
#include <Pegasus/Common/XmlWriter.h> | #include <Pegasus/Common/XmlWriter.h> |
#include <Pegasus/Config/ConfigManager.h> |
|
#include <Pegasus/Common/StatisticalData.h> | #include <Pegasus/Common/StatisticalData.h> |
#include <Pegasus/Common/HashTable.h> | #include <Pegasus/Common/HashTable.h> |
|
#include <Pegasus/Common/PegasusVersion.h> |
| |
| |
#include <stdlib.h> | #include <stdlib.h> |
|
|
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN |
|
|
|
#define CDEBUG(X) | #define CDEBUG(X) |
#define LDEBUG() | #define LDEBUG() |
//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl) |
//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider (" << __LINE__ << ") " << X << PEGASUS_STD(endl) |
//#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::TRACE, "$0", X) | //#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::TRACE, "$0", X) |
| |
//************************************************************************** | //************************************************************************** |
|
|
//************************************************************************** | //************************************************************************** |
| |
const char * thisProvider = "InteropProvider"; | const char * thisProvider = "InteropProvider"; |
// The following should be moved to somewhere like constants. |
|
static const String PegasusInstanceIDGlobalPrefix = "PEG"; |
|
| |
/** |
// This Mutex serializes access to the instance change CIM requests. Keeps from mixing |
The constants representing the class names we process |
// instance creates, modifications, and deletes. This keeps the provider from |
*/ |
// simultaneously execute creates, modifications, and deletes of instances. While |
// ATTN DELETE: static const CIMName __NAMESPACE_CLASSNAME = CIMName ("__Namespace"); |
// these operations are largely protected by the locking mechanisms of the |
static const CIMName CIM_NAMESPACE_CLASSNAME = CIMName ("CIM_Namespace"); |
// repository this mutex guarantees that the provider will not simultaneously |
static const CIMName PG_NAMESPACE_CLASSNAME = CIMName ("PG_Namespace"); |
// execute the instance change operations. |
|
Mutex changeControlMutex; |
static const CIMName CIM_OBJECTMANAGER_CLASSNAME = CIMName ("CIM_ObjectManager"); |
|
static const CIMName CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME = |
// Values and ValueMap qualifier names |
CIMName ("CIM_ObjectManagerCommunicationMechanism"); |
static const CIMName VALUES_QUALIFIERNAME("Values"); |
static const CIMName PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME = |
static const CIMName VALUEMAP_QUALIFIERNAME("ValueMap"); |
CIMName ("PG_CIMXMLCommunicationMechanism"); |
|
static const CIMName CIM_COMMMECHANISMFORMANAGER_CLASSNAME = |
// Some Commonly shared property names |
CIMName ("CIM_CommMechanismForManager"); |
static const CIMName COMMON_PROPERTY_NAME("Name"); |
static const CIMName CIM_NAMESPACEINMANAGER_CLASSNAME = |
|
CIMName ("CIM_NamespaceInManager"); |
|
| |
// Property Names for __Namespace Class |
// Property Names for CIM_Namespace Class |
static const CIMName NAMESPACE_PROPERTYNAME = CIMName ("Name"); |
#define NAMESPACE_PROPERTYNAME COMMON_PROPERTY_NAME |
|
|
|
// Root Namespace Name for test. |
static const CIMNamespaceName ROOTNS = CIMNamespaceName ("root"); | static const CIMNamespaceName ROOTNS = CIMNamespaceName ("root"); |
| |
| |
// Property names for CIM_ObjectManager Class | // Property names for CIM_ObjectManager Class |
static const CIMName OM_GATHERSTATISTICALDATA = | static const CIMName OM_GATHERSTATISTICALDATA = |
CIMName ("GatherStatisticalData"); | CIMName ("GatherStatisticalData"); |
|
|
// Property for the slp template. | // Property for the slp template. |
static const CIMName OM_DESCRIPTIONPROPERTY = | static const CIMName OM_DESCRIPTIONPROPERTY = |
CIMName("Description"); | CIMName("Description"); |
|
|
CIMName ("ObjectManagerName"); | CIMName ("ObjectManagerName"); |
static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME = | static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME = |
CIMName ("CreationClassName"); | CIMName ("CreationClassName"); |
static const CIMName CIM_NAMESPACE_PROPERTY_NAME = CIMName ("Name"); |
#define CIM_NAMESPACE_PROPERTY_NAME COMMON_PROPERTY_NAME |
static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO = | static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO = |
CIMName ("ClassInfo"); | CIMName ("ClassInfo"); |
static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO = | static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO = |
|
|
CIMName ("IsShareable"); | CIMName ("IsShareable"); |
static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE = | static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE = |
CIMName ("ParentNamespace"); | CIMName ("ParentNamespace"); |
static const CIMName PG_NAMESPACE_PROPERTY_NAME = |
#define PG_NAMESPACE_PROPERTY_NAME COMMON_PROPERTY_NAME |
CIMName ("Name"); |
|
| |
|
// Property names for RegisteredProfile |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_INSTANCEID("InstanceId"); |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_ADVERTISETYPES( |
|
"AdvertiseTypes"); |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDNAME( |
|
"RegisteredName"); |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDVERSION( |
|
"RegisteredVersion"); |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION( |
|
"RegisteredOrganization"); |
|
static const CIMName REGISTEREDPROFILE_PROPERTY_OTHERREGISTEREDORGANIZATION( |
|
"OtherRegisteredOrganization"); |
|
|
|
// Property names for ElementConformsToProfile |
|
static const CIMName ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD( |
|
"ConformantStandard"); |
|
static const CIMName ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT( |
|
"ManagedElement"); |
|
|
|
// Property names for ProviderProfileCapabilities |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE( |
|
"RegisteredProfile"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_REGISTEREDSUBPROFILES( |
|
"RegisteredSubProfiles"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_PROFILEVERSION( |
|
"ProfileVersion"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDPROFILE( |
|
"OtherRegisteredProfile"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDSUBPROFILES( |
|
"OtherRegisteredSubProfiles"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDORGANIZATION( |
|
"OtherRegisteredOrganization"); |
|
static const CIMName PROFILECAPABILITIES_PROPERTY_CONFORMINGELEMENTS( |
|
"ConformingElements"); |
|
|
|
// Property names for Provider Referenced Profiles |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILES( |
|
"RegisteredProfiles"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILES( |
|
"DependentProfiles"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILEVERSIONS( |
|
"RegisteredProfileVersions"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILEVERSIONS( |
|
"DependentProfileVersions"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILES( |
|
"OtherRegisteredProfiles"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILES( |
|
"OtherDependentProfiles"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILEORGANIZATIONS( |
|
"OtherRegisteredProfileOrganizations"); |
|
static const CIMName REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILEORGANIZATIONS( |
|
"OtherDependentProfileOrganizations"); |
|
|
|
// Property names for ProviderModule class |
|
#define PROVIDERMODULE_PROPERTY_NAME COMMON_PROPERTY_NAME |
|
static const CIMName PROVIDERMODULE_PROPERTY_VENDOR("Vendor"); |
|
static const CIMName PROVIDERMODULE_PROPERTY_VERSION("Version"); |
|
static const CIMName PROVIDERMODULE_PROPERTY_INTERFACETYPE("InterfaceType"); |
|
|
|
// Property names for Provider class |
|
#define PROVIDER_PROPERTY_NAME COMMON_PROPERTY_NAME |
|
static const CIMName PROVIDER_PROPERTY_PROVIDERMODULENAME( |
|
"ProviderModuleName"); |
|
|
|
// Property names for PG_Capabilities class |
|
#define CAPABILITIES_PROPERTY_PROVIDERMODULENAME PROVIDER_PROPERTY_PROVIDERMODULENAME |
|
static const CIMName CAPABILITIES_PROPERTY_PROVIDERNAME("ProviderName"); |
|
|
|
// Property names for PG_ProviderCapabilities |
|
#define PROVIDERCAPABILITIES_PROPERTY_PROVIDERMODULENAME PROVIDER_PROPERTY_PROVIDERMODULENAME |
|
#define PROVIDERCAPABILITIES_PROPERTY_PROVIDERNAME CAPABILITIES_PROPERTY_PROVIDERNAME |
|
static const CIMName PROVIDERCAPABILITIES_PROPERTY_CLASSNAME("ClassName"); |
|
static const CIMName PROVIDERCAPABILITIES_PROPERTY_NAMESPACES("Namespaces"); |
|
|
|
// Generic property names for Dependency and its subclasses |
|
static const CIMName PROPERTY_ANTECEDENT("Antecedent"); |
|
static const CIMName PROPERTY_DEPENDENT("Dependent"); |
|
|
|
// Property names for SoftwareIdentity |
|
static const CIMName SOFTWAREIDENTITY_PROPERTY_INSTANCEID("InstanceID"); |
|
#define SOFTWAREIDENTITY_PROPERTY_NAME COMMON_PROPERTY_NAME |
|
static const CIMName SOFTWAREIDENTITY_PROPERTY_VERSION("VersionString"); |
|
static const CIMName SOFTWAREIDENTITY_PROPERTY_MANUFACTURER("Manufacturer"); |
|
static const CIMName SOFTWAREIDENTITY_PROPERTY_CLASSIFICATIONS("Classifications"); |
|
|
|
// Implementation-specific constant strings |
|
static const String SNIA_NAME("SNIA"); |
|
static const String SNIA_VER_110("1.1.0"); |
|
static const String INTEROP_PROVIDER_NAME("Interoperability Provider"); |
|
static const String PEGASUS_MODULE_NAME = String(PEGASUS_CIMOM_GENERIC_NAME) + |
|
String(" ") + String(PEGASUS_PRODUCT_NAME); |
|
static const String PEGASUS_INTERNAL_PROVIDER_TYPE("Internal Control Provider"); |
|
|
|
// Create a context container to prevent reentry into the |
// Defines to serve as the ENUM for class selection for instance | // Defines to serve as the ENUM for class selection for instance |
// operations. | // operations. |
| |
enum targetClass{ |
enum TARGET_CLASS { |
//__NAMESPACE = 1, |
PG_NAMESPACE, |
PG_NAMESPACE = 1, |
PG_OBJECTMANAGER, |
CIM_OBJECTMANAGER = 2, |
PG_CIMXMLCOMMUNICATIONMECHANISM, |
PG_CIMXMLCOMMUNICATIONMECHANISM = 3, |
PG_NAMESPACEINMANAGER, |
CIM_NAMESPACEINMANAGERINST =4, |
PG_COMMMECHANISMFORMANAGER, |
CIM_COMMMECHANISMFORMANAGERINST=5, |
PG_REGISTEREDPROFILE, |
CIM_NAMESPACEINMANAGER=6 |
PG_REGISTEREDSUBPROFILE, |
|
PG_REFERENCEDPROFILE, |
|
PG_ELEMENTCONFORMSTOPROFILE, |
|
PG_SUBPROFILEREQUIRESPROFILE, |
|
PG_SOFTWAREIDENTITY, |
|
PG_ELEMENTSOFTWAREIDENTITY, |
|
PG_COMPUTERSYSTEM, |
|
PG_HOSTEDOBJECTMANAGER, |
|
PG_HOSTEDACCESSPOINT |
}; | }; |
| |
enum targetAssocClass{ |
inline String concatPathArray(Array<CIMObjectPath>& p) |
CIM_NAMESPACEINMANAGERASSOC = 1, |
{ |
CIM_COMMMECHANISMFORMANAGERASSOC=2 |
String rtn; |
}; |
for (Uint32 i = 0 ; i < p.size() ; i++) |
|
{ |
|
if (i > 0) |
|
rtn.append(" "); |
|
rtn.append(p[i].toString()); |
|
} |
|
return(rtn); |
|
} |
|
|
|
/* Gets the value for the CIMObjectManager name. This is a key |
|
property with the following characteristics. |
|
1. It is persistent. This must be persistent through CIMOM |
|
restarts. We will save it in the instance database to achieve this. |
|
2. It must be unique. We cannot create duplicate CIMOM names |
|
3. It is based on the DMTF description of how unique InstanceIds |
|
are defined (Trademark/etc followed by unique identification. |
|
Use the Global constant PegasusInstanceIDGlobalPrefix as the |
|
prefix allowing this to be changed. |
|
*/ |
|
inline String buildObjectManagerName() |
|
{ |
|
return (String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + Guid::getGuid()); |
|
} |
|
|
|
inline CIMObjectPath buildInstancePath(const CIMClass & cimClass, |
|
const String & hostName, |
|
const CIMNamespaceName & nameSpace, |
|
const CIMInstance & instance) |
|
{ |
|
CIMObjectPath objPath = instance.buildPath(cimClass); |
|
objPath.setHost(hostName); |
|
objPath.setNameSpace(nameSpace); |
|
return objPath; |
|
} |
|
|
|
template <class RetClass> |
|
RetClass getRequiredValue(const CIMInstance & instance, |
|
const CIMName & propName) |
|
{ |
|
RetClass retVal; |
|
Uint32 index = instance.findProperty(propName); |
|
if(index == PEG_NOT_FOUND) |
|
{ |
|
throw CIMOperationFailedException("Instance " + |
|
instance.getPath().toString() + |
|
" missing expected property " + propName.getString()); |
|
} |
|
const CIMValue & tmpVal = instance.getProperty(index).getValue(); |
|
if(tmpVal.isNull()) |
|
{ |
|
throw CIMOperationFailedException("Instance " + |
|
instance.getPath().toString() + |
|
" has unexpected NULL value for property " + propName.getString()); |
|
} |
| |
|
tmpVal.get(retVal); |
|
|
|
return retVal; |
|
} |
| |
//************************************************************* | //************************************************************* |
// Constructor | // Constructor |
//********************************************************** | //********************************************************** |
InteropProvider::InteropProvider(CIMRepository* repository) |
InteropProvider::InteropProvider(CIMRepository * rep) : repository(rep), |
|
hostName(System::getHostName()), namespacesInitialized(false) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); |
_repository = repository; |
objectManagerName = buildObjectManagerName(); |
|
profileCapabilitiesClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES, false, true, false); |
|
providerClassifications.append(Uint16(5)); // "Instrumentation" |
//*********************************************** | //*********************************************** |
// This is a tempory fix untill there is a method created for the InteropProvider to | // This is a tempory fix untill there is a method created for the InteropProvider to |
// do it's inaliaztion work. This fix sets StatisticalData::CopyGSD, enabling the |
// do it's inalization work. This fix sets StatisticalData::CopyGSD, enabling the |
//statistical gathering function. | //statistical gathering function. |
Array<CIMInstance> instance = repository->enumerateInstances(CIMNamespaceName("root/cimv2"), CIMName ("CIM_ObjectManager")); |
|
| |
if(instance.size() > 0) |
Boolean instancesExists = true; |
|
Array<CIMInstance> instance; |
|
|
|
try |
|
{ |
|
instance = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER); |
|
} |
|
catch(Exception e) |
|
{ |
|
instancesExists = false; |
|
} |
|
|
|
if(instance.size() > 0 && instancesExists) |
{ | { |
Boolean output = false; | Boolean output = false; |
Uint32 pos; | Uint32 pos; |
|
|
} | } |
} | } |
} | } |
//******************************************* end of temporary fix |
|
PEG_METHOD_EXIT(); |
// Initialize the namespaces so that all namespaces with the |
|
// CIM_elementConformsToProfile class also have the |
|
// PG_elementConformsToProfile class |
|
if(!namespacesInitialized) |
|
{ |
|
AutoMutex mut(interopMut); |
|
if(!namespacesInitialized) |
|
{ |
|
Array<CIMNamespaceName> namespaceNames = |
|
repository->enumerateNameSpaces(); |
|
CIMClass conformsClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE); |
|
for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i) |
|
{ |
|
// Check if the PG_ElementConformsToProfile class is present |
|
CIMNamespaceName & currentNamespace = namespaceNames[i]; |
|
|
|
CIMClass tmpCimClass; |
|
CIMClass tmpPgClass; |
|
try |
|
{ |
|
tmpCimClass = repository->getClass(currentNamespace, |
|
PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE); |
|
tmpPgClass = repository->getClass(currentNamespace, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE); |
|
} |
|
catch(...) |
|
{ |
|
// Note: if either of the two classes aren't found, an |
|
// exception will be thrown, which we can ignore since it's |
|
// an expected case |
|
// TBD: Log trace message here? |
} | } |
| |
|
// If the CIM_ElementConformsToProfile class is present, but |
|
// the PG_ElementConformsToProfile class is not, then add it |
|
// to that namespace. |
|
if(!tmpCimClass.isUninitialized() && |
|
tmpPgClass.isUninitialized()) |
|
{ |
|
CIMObjectPath newPath = conformsClass.getPath(); |
|
newPath.setNameSpace(currentNamespace); |
|
conformsClass.setPath(newPath); |
|
repository->createClass(currentNamespace, |
|
conformsClass); |
|
} |
|
} |
| |
|
namespacesInitialized = true; |
|
} |
|
} |
|
PEG_METHOD_EXIT(); |
|
} |
| |
//*************************************************************** | //*************************************************************** |
// Provider Utility Functions | // Provider Utility Functions |
//*************************************************************** | //*************************************************************** |
| |
String _showBool(Boolean x) |
inline String boolToString(Boolean x) |
{ | { |
return(x? "true" : "false"); | return(x? "true" : "false"); |
} | } |
| |
static String _toStringPropertyList(const CIMPropertyList& pl) |
inline String propertyListToString(const CIMPropertyList& pl) |
{ | { |
|
if(pl.isNull()) |
|
return "NULL"; |
|
else if(pl.size() == 0) |
|
return "EMPTY"; |
|
|
String tmp; | String tmp; |
for (Uint32 i = 0; i < pl.size() ; i++) | for (Uint32 i = 0; i < pl.size() ; i++) |
{ | { |
|
|
tmp.append(", "); | tmp.append(", "); |
tmp.append(pl[i].getString()); | tmp.append(pl[i].getString()); |
} | } |
return(tmp); |
return tmp; |
} | } |
| |
static String _showPropertyList(const CIMPropertyList& pl) |
/** Determines if the namespace is allowable for this operation. |
|
This provider is designed to accept either all namespaces or |
|
limit itself to just one for operations. In all cases, it |
|
will provide the required answers and use the correct namespace |
|
for any persistent information. However, it may be configured |
|
to either accept input operations from any namespace or simply |
|
from one (normally the interop namespace). |
|
@ objectReference for the operation. This must include the |
|
namespace and class name for the operation. |
|
@return Returns normally if the namespace test is passed. Otherwise |
|
it generates a CIMException (CIM_ERR_NOT_SUPPORTED) |
|
@exception CIMException(CIM_ERR_NOT_SUPPORTED) |
|
*/ |
|
bool namespaceSupported(const CIMObjectPath & path) |
{ | { |
if (pl.isNull()) |
// To allow use of all namespaces, uncomment the following line |
return("NULL"); |
// return; |
|
if(path.getNameSpace().getString() == PEGASUS_NAMESPACENAME_INTEROP) |
|
return true; |
| |
String tmp; |
throw CIMNotSupportedException(path.getClassName().getString() + |
|
" in namespace " + path.getNameSpace().getString()); |
|
|
|
return false; |
|
} |
|
|
|
/* complete the instance by setting the complete path into the instance |
|
and executing the instance filter to set the qualifiers, classorigin and |
|
propertylist in accordance with the input. Note that this can only remove |
|
characteristics, except for the path completion so that it expects instances |
|
with qualifiers included, class origin included and a complete property |
|
list. |
|
*/ |
|
void normalizeInstance(CIMInstance& instance, const CIMObjectPath& path, |
|
Boolean includeQualifiers, Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
CIMObjectPath p = instance.getPath(); |
|
p.setHost(path.getHost()); |
|
p.setNameSpace(path.getNameSpace()); |
| |
tmp.append((pl.size() == 0) ? "Empty" : _toStringPropertyList(pl)); |
instance.setPath(p); |
return(tmp); |
instance.filter(includeQualifiers, |
|
includeClassOrigin, |
|
propertyList ); |
} | } |
| |
/** get one string property from an instance. Note that these functions simply | /** get one string property from an instance. Note that these functions simply |
|
|
not exist, is Null, or is not a string type. The substitute is String::EMPTY | not exist, is Null, or is not a string type. The substitute is String::EMPTY |
@return String value found or defaultValue. | @return String value found or defaultValue. |
*/ | */ |
String _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const String& defaultValue) |
String getPropertyValue(const CIMInstance& instance, |
|
const CIMName& propertyName, const String& defaultValue) |
{ | { |
String output = defaultValue; | String output = defaultValue; |
Uint32 pos; |
Uint32 pos = instance.findProperty(propertyName); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
if(pos != PEG_NOT_FOUND) |
{ | { |
CIMConstProperty p1 = instance.getProperty(pos); | CIMConstProperty p1 = instance.getProperty(pos); |
if (p1.getType() == CIMTYPE_STRING) | if (p1.getType() == CIMTYPE_STRING) |
|
|
if (!v1.isNull()) | if (!v1.isNull()) |
v1.get(output); | v1.get(output); |
} | } |
|
else |
|
{ |
|
throw CIMInvalidParameterException( |
|
"Incorrect Property Type for Property " + |
|
propertyName.getString()); |
|
} |
} | } |
return(output); |
|
|
return output; |
} | } |
| |
// Overload of _getPropertyValue for boolean type |
// Overload of getPropertyValue for boolean type |
Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const Boolean defaultValue) |
Boolean getPropertyValue(const CIMInstance& instance, |
|
const CIMName& propertyName, const Boolean defaultValue) |
{ | { |
Boolean output = defaultValue; | Boolean output = defaultValue; |
Uint32 pos; |
Uint32 pos = instance.findProperty(propertyName); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
if(pos != PEG_NOT_FOUND) |
{ | { |
CIMConstProperty p1 = instance.getProperty(pos); | CIMConstProperty p1 = instance.getProperty(pos); |
if (p1.getType() == CIMTYPE_BOOLEAN) | if (p1.getType() == CIMTYPE_BOOLEAN) |
|
|
if (!v1.isNull()) | if (!v1.isNull()) |
v1.get(output); | v1.get(output); |
} | } |
|
else |
|
{ |
|
throw CIMInvalidParameterException( |
|
"Incorrect Property Type for Property " + |
|
propertyName.getString()); |
|
} |
} | } |
return(output); | return(output); |
} | } |
|
|
If everything fails, gets the definition normally | If everything fails, gets the definition normally |
used for localhost (127.0.0.1). | used for localhost (127.0.0.1). |
| |
@param hostName String with the name of the host |
@param hostName String with the name of the host. Allows |
@return String with the IP address to be used |
String:EMPTY and in that case, gets it directly from system. |
NOTE: This code should not be in slpprovider. This |
@param namespaceType - Uint32 representing the |
should be in the Interop classes but for the moment |
access protocol for this request. This is exactly |
it is not. |
the definition in the PG_CIMXMLCommunicationMechanism |
|
mof for the property namespaceAccessProtocol. |
|
@param port String defining the port to be used. If |
|
String::EMPTY, it is not valid and the defaultPortNumber |
|
is to be inserted. |
|
@param defaultPortNumber Uint32 defining a default port |
|
number to be used if port string is not provided. |
|
@return String with the IP address to be used. This must |
|
be the complete address sufficient to access the |
|
IP address. Therefore, it includes the port number. |
*/ | */ |
String _getHostAddress(String hostName) |
String getHostAddress(const String & hostName, Uint32 namespaceType, |
|
const String & port, Uint32 defaultPortNumber) |
{ | { |
String ipAddress; | String ipAddress; |
|
|
if (hostName == String::EMPTY) | if (hostName == String::EMPTY) |
hostName = System::getHostName(); |
ipAddress = System::getHostIP(System::getHostName()); |
|
else |
|
ipAddress = System::getHostIP(hostName); |
| |
if ((ipAddress = System::getHostIP(hostName)) == String::EMPTY) |
if(ipAddress == String::EMPTY) |
{ | { |
// set default address if everything else failed | // set default address if everything else failed |
ipAddress = String("127.0.0.1"); | ipAddress = String("127.0.0.1"); |
} | } |
return ipAddress; |
|
} |
|
| |
Array<String> _getFunctionalProfiles(Array<Uint16> & profiles) |
// Question: is there a case where we leave off the port number. |
|
// Code to get the property service_location_tcp ( which is equivalent to "IP address:5988") |
|
|
|
// if port is valid port number, we use it. Else use |
|
// the default portnumber provided. |
|
// One or the other MUST not be zero. |
|
ipAddress.append(":"); |
|
if(port == String::EMPTY) |
|
{ |
|
// convert portNumber to ascii |
|
char buffer[32]; |
|
sprintf(buffer, "%u", defaultPortNumber); |
|
ipAddress.append(buffer); |
|
} |
|
else |
{ | { |
Array<String> profileDescriptions; |
ipAddress.append(port); |
profiles.append(2); profileDescriptions.append("Basic Read"); |
|
profiles.append(3); profileDescriptions.append("Basic Write"); |
|
profiles.append(4); profileDescriptions.append("Schema Manipulation"); |
|
profiles.append(5); profileDescriptions.append("Instance Manipulation"); |
|
profiles.append(6); profileDescriptions.append("Association Traversal"); |
|
profiles.append(8); profileDescriptions.append("Qualifier Declaration"); |
|
profiles.append(9); profileDescriptions.append("Indications"); |
|
return(profileDescriptions); |
|
} | } |
| |
/* get the prefix that will be part of the cimom identification |
// now fillout the serviceIDAttribute from the object manager instance name property. |
This can be either the default PEG or if the environment |
// This is a key field so must have a value. |
variable PEGASUS_TRADEMARK_PREFIX is defined this is used. |
//String strUUID = _getPropertyValue( instance_ObjMgr, namePropertyName, "DefaultEmptyUUID"); |
NOTE: getting from the environment variable is a hack until |
|
we can come up with a better source. |
|
@return String containing the unique name for the CIMOM ID |
|
*/ |
|
| |
String getTrademarkCIMOMIDPrefix() |
return ipAddress; |
|
} |
|
/** Fills in the CIMOperation functional profiles and corresponding description |
|
array. This function is closely linked to compile and configuration |
|
features in the CIM Server to determine if certain features are |
|
enabled and/or compiled. Definitions correspond to the DMTF SLP template |
|
version 1.0. |
|
@param Array<Uint16> profiles provides an array for the profiles |
|
@return Array<String> with the corresponding profile text descriptions |
|
*/ |
|
Array<String> getFunctionalProfiles(Array<Uint16> & profiles) |
{ | { |
|
Array<String> profileDescriptions; |
|
// Note that zero and 1 are unknown and other. Not used by us |
|
// 2 - 5 are not optional in Pegasus |
|
profiles.append(2); |
|
profileDescriptions.append("Basic Read"); |
| |
char * trademark; |
profiles.append(3); |
trademark = getenv("PEGASUS_TRADEMARK_PREFIX"); |
profileDescriptions.append("Basic Write"); |
return((trademark)? trademark : PegasusInstanceIDGlobalPrefix); |
|
} |
profiles.append(4); |
/** Builds the UUID string for this CIMOM. |
profileDescriptions.append("Schema Manipulation"); |
**/ |
|
String getUUIDString() |
profiles.append(5); |
|
profileDescriptions.append("Instance Manipulation"); |
|
|
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
if (String::equal(configManager->getCurrentValue("enableAssociationTraversal"), "true")) |
{ | { |
return(Guid::getGuid()); |
profiles.append(6); |
|
profileDescriptions.append("Association Traversal"); |
} | } |
|
#ifndef PEGASUS_DISABLE_EXECQUERY |
|
profiles.append(7); |
|
profileDescriptions.append("Query Execution"); |
|
#endif |
|
profiles.append(8); |
|
profileDescriptions.append("Qualifier Declaration"); |
| |
/* Test the keys in the CIM_Namespace for valid values |
if (String::equal(configManager->getCurrentValue("enableIndicationService"), "true")) |
This includes all of the keys above the name key. |
|
THis is a dummy for now. |
|
ATTN: KS Extend and finish this function. |
|
*/ |
|
Boolean _validateProperties(const CIMObjectPath& path) |
|
{ | { |
return true; |
profiles.append(9); |
|
profileDescriptions.append("Indications"); |
} | } |
| |
Boolean _validateProperties(const CIMInstance& instance) |
return(profileDescriptions); |
{ |
|
return true; |
|
} | } |
| |
/* Validate that the property exists, is string type and | /* Validate that the property exists, is string type and |
|
|
value in the property | value in the property |
@return True if passes all tests | @return True if passes all tests |
*/ | */ |
Boolean _validateRequiredProperty(const CIMInstance& instance, |
Boolean validateRequiredProperty(const CIMInstance& instance, |
const CIMName& propertyName, |
const CIMName& propertyName, const String& value) |
const String& value) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_validateRequiredProperty()"); | "InteropProvider::_validateRequiredProperty()"); |
Uint32 pos; |
Uint32 pos = instance.findProperty (propertyName); |
| |
if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND) |
if(pos == PEG_NOT_FOUND) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(false); |
return false; |
} | } |
// | // |
// Get the property | // Get the property |
|
|
return(false); | return(false); |
} | } |
| |
Boolean _validateRequiredProperty(const CIMInstance& instance, |
|
|
Boolean validateRequiredProperty(const CIMInstance& instance, |
const CIMName& propertyName, | const CIMName& propertyName, |
const Uint16& value) | const Uint16& value) |
{ | { |
|
|
return(true); | return(true); |
} | } |
| |
Boolean _validateRequiredProperty(const CIMObjectPath& objectPath, |
Boolean validateRequiredProperty(const CIMObjectPath& objectPath, |
const CIMName& propertyName, | const CIMName& propertyName, |
const String value) | const String value) |
{ | { |
|
|
return(true); | return(true); |
} | } |
| |
/* Query the repository for array of all namespacenames |
/* Verify that this is one of the legal classnames for instance operations and |
@return Array<CIMNamespaceName> with all namespaces |
return an indicator as to which one it is. |
@exception Passes all exception that repository may generate. |
@param - Classname |
|
@return - Uint32 indicating type |
|
@Exceptions - throws CIMNotSupportedException if invalid class. |
*/ | */ |
Array<CIMNamespaceName> InteropProvider::_enumerateNameSpaces() |
TARGET_CLASS translateClassInput(const CIMName& className) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_enumerateNameSpaces()"); |
"InteropProvider::translateClassInput"); |
|
if(className.equal(PEGASUS_CLASSNAME_PG_OBJECTMANAGER)) |
|
return PG_OBJECTMANAGER; |
| |
Array<CIMNamespaceName> namespaceNames; |
else if(className.equal(PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM)) |
|
return PG_CIMXMLCOMMUNICATIONMECHANISM; |
| |
namespaceNames = _repository->enumerateNameSpaces(); |
else if(className.equal(PEGASUS_CLASSNAME_PG_NAMESPACEINMANAGER)) |
|
return PG_NAMESPACEINMANAGER; |
| |
PEG_METHOD_EXIT(); |
else if(className.equal(PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER)) |
return(namespaceNames); |
return PG_COMMMECHANISMFORMANAGER; |
} |
|
| |
/* get a class defintion. Gets the class defined by |
else if(className.equal(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE)) |
the parameters. Generates exception of class not defined. |
return PG_REGISTEREDPROFILE; |
@param namespace in which to look for the class. |
|
@param name of class to get. |
|
@return the CIMClass object |
|
@Exceptions any repository exceptions if class not found. |
|
*/ |
|
CIMClass InteropProvider::_getClass(const CIMNamespaceName& nameSpace, |
|
const CIMName& className) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_getClass"); |
|
| |
CIMClass myClass = _repository->getClass(nameSpace, className, |
else if(className.equal(PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE)) |
false,true,true); |
return PG_REGISTEREDSUBPROFILE; |
PEG_METHOD_EXIT(); |
|
return myClass; |
|
} |
|
| |
/* Verify that this is one of the legal classnames and |
else if(className.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) |
return indicator which. |
return PG_REFERENCEDPROFILE; |
@param - Classname |
|
@return - Uint32 indicating type |
|
@Exceptions - throws CIMNotSupportedException if invalid class. |
|
*/ |
|
static targetClass _verifyValidClassInput(const CIMName& className) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_verifyValidClassInput"); |
|
if (className.equal(CIM_OBJECTMANAGER_CLASSNAME)) |
|
return CIM_OBJECTMANAGER; |
|
| |
if (className.equal(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME)) |
else if(className.equal(PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE)) |
return PG_CIMXMLCOMMUNICATIONMECHANISM; |
return PG_ELEMENTCONFORMSTOPROFILE; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_SUBPROFILEREQUIRESPROFILE)) |
|
return PG_SUBPROFILEREQUIRESPROFILE; |
| |
if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME)) |
else if(className.equal(PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY)) |
return CIM_NAMESPACEINMANAGER; |
return PG_SOFTWAREIDENTITY; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_ELEMENTSOFTWAREIDENTITY)) |
|
return PG_ELEMENTSOFTWAREIDENTITY; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM)) |
|
return PG_COMPUTERSYSTEM; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER)) |
|
return PG_HOSTEDOBJECTMANAGER; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT)) |
|
return PG_HOSTEDACCESSPOINT; |
| |
// Last entry, reverse test and return OK if PG_Namespace | // Last entry, reverse test and return OK if PG_Namespace |
// Note: Changed to PG_Namespace for CIM 2.4 | // Note: Changed to PG_Namespace for CIM 2.4 |
if (!className.equal(PG_NAMESPACE_CLASSNAME)) |
else if(!className.equal(PEGASUS_CLASSNAME_PG_NAMESPACE)) |
throw CIMNotSupportedException | throw CIMNotSupportedException |
(className.getString() + " not supported by Interop Provider"); | (className.getString() + " not supported by Interop Provider"); |
| |
|
|
return PG_NAMESPACE; | return PG_NAMESPACE; |
} | } |
| |
static targetAssocClass _verifyValidAssocClassInput(const CIMName& className) |
TARGET_CLASS translateAssocClassInput(const CIMName& className) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_verifyValidAssocClassInput"); |
"InteropProvider::translateAssocClassInput"); |
if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME)) |
|
return CIM_NAMESPACEINMANAGERASSOC; |
|
| |
// Last entry, reverse test and return OK if CIM_CommMech.... |
if(className.equal(PEGASUS_CLASSNAME_PG_NAMESPACEINMANAGER)) |
if (!className.equal(CIM_COMMMECHANISMFORMANAGER_CLASSNAME)) |
return PG_NAMESPACEINMANAGER; |
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
else if(className.equal(PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER)) |
|
return PG_COMMMECHANISMFORMANAGER; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) |
|
return PG_REFERENCEDPROFILE; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE)) |
|
return PG_ELEMENTCONFORMSTOPROFILE; |
|
|
|
else if(className.equal(PEGASUS_CLASSNAME_PG_ELEMENTSOFTWAREIDENTITY)) |
|
return PG_ELEMENTSOFTWAREIDENTITY; |
|
|
|
// Last entry, reverse test and return OK if PG_SubProfileRequiresProfile |
|
else if(!className.equal(PEGASUS_CLASSNAME_PG_SUBPROFILEREQUIRESPROFILE)) |
|
{ |
|
throw CIMNotSupportedException(className.getString() + |
|
" not supported by association operations in the Interop Provider"); |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return CIM_COMMMECHANISMFORMANAGERASSOC; |
return PG_SUBPROFILEREQUIRESPROFILE; |
} | } |
| |
/* validate the authorization of the user name against the namespace. |
|
|
/* |
|
* Retrieves the user ID from the operation context. |
*/ | */ |
String _validateUserID(const OperationContext & context) |
String retrieveUserID(const OperationContext & context) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_validateUserID"); | "InteropProvider::_validateUserID"); |
//ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER |
|
String userName; | String userName; |
try | try |
{ | { |
IdentityContainer container = context.get(IdentityContainer::NAME); | IdentityContainer container = context.get(IdentityContainer::NAME); |
userName = container.getUserName(); | userName = container.getUserName(); |
} | } |
|
|
catch (...) | catch (...) |
{ | { |
userName = String::EMPTY; | userName = String::EMPTY; |
|
|
@param value String value to set into property | @param value String value to set into property |
| |
*/ | */ |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const String& value) |
void setPropertyValue(CIMInstance& instance, const CIMName& propertyName, const CIMValue & value) |
{ |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} |
|
|
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Boolean& value) |
|
{ |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} |
|
|
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Uint16& value) |
|
{ |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} |
|
|
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<String>& value) |
|
{ |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} |
|
|
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<Uint16>& value) |
|
{ |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} |
|
|
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const CIMObjectPath& value) |
|
{ | { |
Uint32 pos; |
Uint32 pos = instance.findProperty(propertyName); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
if(pos != PEG_NOT_FOUND) |
instance.getProperty(pos).setValue(CIMValue(value)); |
instance.getProperty(pos).setValue(value); |
} | } |
| |
/** add the correct values to the common keys defined for all of the classes. This is | /** add the correct values to the common keys defined for all of the classes. This is |
systemcreationclassname and systemname | systemcreationclassname and systemname |
Note that if the properties do not exist, we simply ignore them. | Note that if the properties do not exist, we simply ignore them. |
*/ | */ |
void _fixInstanceCommonKeys(CIMInstance& instance) |
void fixInstanceCommonKeys(CIMInstance& instance) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_fixInstanceCommonKeys()"); | "InteropProvider::_fixInstanceCommonKeys()"); |
String SystemCreationClassName = System::getSystemCreationClassName (); | String SystemCreationClassName = System::getSystemCreationClassName (); |
| |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
|
SystemCreationClassName); |
| |
// Add property SystemName | // Add property SystemName |
|
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getFullyQualifiedHostName()); |
System::getFullyQualifiedHostName()); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
|
@return CIMInstance of this class with properties complete. | @return CIMInstance of this class with properties complete. |
@exception passes on any exceptions received from the repository request. | @exception passes on any exceptions received from the repository request. |
*/ | */ |
CIMInstance InteropProvider::_buildInstanceSkeleton(const CIMName& className) |
CIMInstance InteropProvider::buildInstanceSkeleton( |
|
const CIMNamespaceName & nameSpace, |
|
const CIMName& className, |
|
CIMClass& returnedClass) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstanceSkeleton()"); | "InteropProvider::_buildInstanceSkeleton()"); |
CIMClass myClass; |
// get class with lo = false, qualifier = true classorig = true |
|
returnedClass = repository->getClass(nameSpace, |
CIMInstance skeleton(className); |
className, false, true, true); |
myClass = _repository->getClass(_operationNamespace, className, false, true, true); |
CIMInstance skeleton = returnedClass.buildInstance(true,true,CIMPropertyList()); |
|
|
// copy the qualifiers |
|
for (Uint32 i = 0 ; i < myClass.getQualifierCount() ; i++) |
|
skeleton.addQualifier(myClass.getQualifier(i)); |
|
|
|
// copy the properties |
|
for (Uint32 i = 0 ; i < myClass.getPropertyCount() ; i++) |
|
skeleton.addProperty(myClass.getProperty(i)); |
|
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(skeleton.clone()); |
return skeleton; |
} | } |
| |
/* build a single instance of the cimxmlcommunicationmechanism class | /* build a single instance of the cimxmlcommunicationmechanism class |
using the parameter provided as the name property |
using the parameter provided as the name property. |
|
Builds the complete instance and sets the path into it. |
@parm name String representing the name to be used for this object. | @parm name String representing the name to be used for this object. |
@return CIMInstance of the class | @return CIMInstance of the class |
*/ | */ |
CIMInstance InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism( |
CIMInstance InteropProvider::buildCIMXMLCommunicationMechanismInstance( |
const String& namespaceType, | const String& namespaceType, |
|
const Uint16& accessProtocol, |
const String& IPAddress, | const String& IPAddress, |
const Boolean& includeQualifiers, |
const CIMClass & targetClass) |
const Boolean& includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism()"); |
"InteropProvider::buildCIMXMLCommunicationMechanismInstance()"); |
|
CIMInstance instance = targetClass.buildInstance(false, false, |
|
CIMPropertyList()); |
| |
CIMInstance instance = _buildInstanceSkeleton(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME); |
fixInstanceCommonKeys(instance); |
|
|
_fixInstanceCommonKeys(instance); |
|
| |
//CreationClassName | //CreationClassName |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString()); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
|
PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString()); |
| |
//Name, this CommunicationMechanism. We need to make it unique. To do this | //Name, this CommunicationMechanism. We need to make it unique. To do this |
// we simply append the commtype to the classname since we have max of two right | // we simply append the commtype to the classname since we have max of two right |
// now. | // now. |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, (String("PEGASUSCOMM") + namespaceType)); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, |
|
(String("PEGASUSCOMM") + namespaceType)); |
| |
// CommunicationMechanism Property - Force to 2. | // CommunicationMechanism Property - Force to 2. |
_setPropertyValue(instance, OM_COMMUNICATIONMECHANISM, Uint16(2)); |
setPropertyValue(instance, OM_COMMUNICATIONMECHANISM, Uint16(2)); |
| |
//Functional Profiles Supported Property. | //Functional Profiles Supported Property. |
Array<Uint16> profiles; | Array<Uint16> profiles; |
Array<String> profileDescriptions = _getFunctionalProfiles(profiles); |
Array<String> profileDescriptions = getFunctionalProfiles(profiles); |
| |
// Set functional profiles in instance | // Set functional profiles in instance |
_setPropertyValue(instance, OM_FUNCTIONALPROFILESSUPPORTED, profiles); |
setPropertyValue(instance, OM_FUNCTIONALPROFILESSUPPORTED, profiles); |
| |
_setPropertyValue(instance, OM_FUNCTIONALPROFILEDESCRIPTIONS, profileDescriptions); |
setPropertyValue(instance, OM_FUNCTIONALPROFILEDESCRIPTIONS, profileDescriptions); |
| |
// Multiple OperationsSupported Property | // Multiple OperationsSupported Property |
_setPropertyValue(instance, OM_MULTIPLEOPERATIONSSUPPORTED, false); |
setPropertyValue(instance, OM_MULTIPLEOPERATIONSSUPPORTED, false); |
| |
// AuthenticationMechanismsSupported Property | // AuthenticationMechanismsSupported Property |
Array<Uint16> authentications; | Array<Uint16> authentications; |
Array<String> authenticationDescriptions; | Array<String> authenticationDescriptions; |
| |
// Note that we have fixed authentication here. |
//TODO - get from system. |
authentications.append(3); authenticationDescriptions.append("Basic"); |
authentications.append(3); |
|
//authenticationDescriptions.append("Basic"); |
| |
_setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMSSUPPORTED, authentications); |
setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMSSUPPORTED, authentications); |
| |
_setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMDESCRIPTIONS, authenticationDescriptions); |
setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMDESCRIPTIONS, authenticationDescriptions); |
| |
_setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion); |
setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion); |
| |
// Obsolete function | // Obsolete function |
_setPropertyValue(instance, "namespaceType", namespaceType); |
setPropertyValue(instance, "namespaceType", namespaceType); |
|
|
|
setPropertyValue(instance, "namespaceAccessProtocol", accessProtocol); |
| |
_setPropertyValue(instance, "IPAddress", IPAddress); |
setPropertyValue(instance, "IPAddress", IPAddress); |
|
|
|
// build the instance path and set into instance |
|
CIMObjectPath objPath = instance.buildPath(targetClass); |
|
objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
objPath.setHost(hostName); |
|
instance.setPath(objPath); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instance); |
return instance; |
} | } |
| |
Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism( |
Array<CIMInstance> InteropProvider::enumCIMXMLCommunicationMechanismInstances() |
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism"); |
"InteropProvider::enumCIMXMLCommunicationMechanismInstances"); |
| |
// This is a temporary hack to get the multiple connections. |
|
ConfigManager* configManager = ConfigManager::getInstance(); | ConfigManager* configManager = ConfigManager::getInstance(); |
Boolean enableHttpConnection = String::equal( | Boolean enableHttpConnection = String::equal( |
configManager->getCurrentValue("enableHttpConnection"), "true"); | configManager->getCurrentValue("enableHttpConnection"), "true"); |
Boolean enableHttpsConnection = String::equal( | Boolean enableHttpsConnection = String::equal( |
configManager->getCurrentValue("enableHttpsConnection"), "true"); | configManager->getCurrentValue("enableHttpsConnection"), "true"); |
| |
String IPAddress = _getHostAddress(System::getHostName()); |
|
Array<CIMInstance> instances; | Array<CIMInstance> instances; |
|
Uint32 namespaceAccessProtocol; |
|
String namespaceType; |
| |
|
CIMClass commMechClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, |
|
false); |
if (enableHttpConnection) | if (enableHttpConnection) |
{ | { |
CDEBUG("building pgcimxmlinstances 1"); |
namespaceAccessProtocol = 2; |
CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism( |
namespaceType = "http"; |
"http", IPAddress, |
Uint32 portNumberHttp; |
includeQualifiers, |
String httpPort = configManager->getCurrentValue("httpPort"); |
includeClassOrigin, |
if (httpPort == String::EMPTY) |
propertyList); |
{ |
|
portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, |
|
WBEM_DEFAULT_HTTP_PORT); |
|
} |
|
CIMInstance instance = |
|
buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
|
getHostAddress(hostName, namespaceAccessProtocol, httpPort, |
|
portNumberHttp), commMechClass); |
instances.append(instance); | instances.append(instance); |
} | } |
| |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
CDEBUG("building pgcimxmlinstances 2"); |
namespaceAccessProtocol = 3; |
CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism( |
namespaceType = "https"; |
"https", IPAddress, |
Uint32 portNumberHttps; |
includeQualifiers, |
String httpsPort = configManager->getCurrentValue("httpsPort"); |
includeClassOrigin, |
if (httpsPort == String::EMPTY) |
propertyList); |
{ |
|
portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, |
|
WBEM_DEFAULT_HTTPS_PORT); |
|
} |
|
CIMInstance instance = |
|
buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
|
getHostAddress(hostName, namespaceAccessProtocol, httpsPort, |
|
portNumberHttps), commMechClass); |
|
|
instances.append(instance); | instances.append(instance); |
} | } |
PEG_METHOD_EXIT(); |
|
return(instances); |
|
} |
|
/* Gets the value for the CIMObjectManager name. This is a key |
|
property with the following characteristics. |
|
1. It is persistent. This must be persistent through CIMOM |
|
restarts. We will save it in the instance database to achieve this. |
|
2. It must be unique. We cannot create duplicate CIMOM names |
|
3. It is based on the DMTF description of how unique InstanceIds |
|
are defined (Trademark/etc followed by unique identification. |
|
Use the Global constant PegasusInstanceIDGlobalPrefix as the |
|
prefix allowing this to be changed. |
|
*/ |
|
String buildObjectManagerName() |
|
{ |
|
return(getTrademarkCIMOMIDPrefix() + ":" + getUUIDString()); |
|
} |
|
| |
/** get either the local or disk CIMObjectmanager instance. |
|
@return Boolean true if already exists. False if |
|
not initialized. Also returns with the current version set |
|
into local parameter. |
|
ATTN: Probably should get rid of the local parameter since |
|
this is used so infrequently, waste of space. |
|
*/ |
|
Boolean InteropProvider::_getInstanceFromRepositoryCIMObjectManager( |
|
CIMInstance& rtnInstance, |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_getInstanceCIMObjectManager"); |
|
// Try to get persistent instance from repository |
|
Array<CIMInstance> instances; |
|
try |
|
{ |
|
instances = _repository->enumerateInstances(_operationNamespace, |
|
CIM_OBJECTMANAGER_CLASSNAME, true, false, includeQualifiers, |
|
includeClassOrigin, propertyList); |
|
|
|
CDEBUG("_getInstancefrom... " << instances.size()); |
|
if (instances.size() >= 1) |
|
{ |
|
// set this instance into global variable. |
|
rtnInstance = instances[0]; |
|
|
|
// log entry if there is more than one instance. |
|
// Some day we may support multiple entries to see other CIMOMs but |
|
// for now this should be illegal and represent an internal error. |
|
// but we will still continue to use the first entry. |
|
if (instances.size() > 1) |
|
{ |
|
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Error. Multiple definitons of : $0", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
|
} |
|
CDEBUG("getInstanceFromRepository returning true"); |
|
return(true); |
|
} |
|
else |
|
{ |
|
CDEBUG("getInstanceFromRepository returning false"); |
|
return(false); |
|
} |
|
} |
|
catch(const CIMException&) |
|
{ |
|
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
|
PEG_METHOD_EXIT(); |
|
throw; |
|
} |
|
catch(const Exception&) |
|
{ |
|
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; |
return instances; |
} |
|
} | } |
| |
/** build an instance of the CIM_ObjectManager class filling out |
/** get an instance of the CIM_ObjectManager class filling out |
the required properties if one does not already exist in the | the required properties if one does not already exist in the |
repository. This function will either return an instance | repository. This function will either return an instance |
or throw an exception. | or throw an exception. |
|
|
@exception repository instances if exception to enumerateInstances | @exception repository instances if exception to enumerateInstances |
for this class. | for this class. |
*/ | */ |
CIMInstance InteropProvider::_getInstanceCIMObjectManager( |
CIMInstance InteropProvider::getObjectManagerInstance( |
const Boolean includeQualifiers, |
const CIMObjectPath& objectPath, |
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstanceCIMObjectManager"); |
"InteropProvider::getObjectManagerInstance"); |
| |
// Try to get the current object. If true then it is already created. | // Try to get the current object. If true then it is already created. |
CIMInstance instance; | CIMInstance instance; |
if (!_getInstanceFromRepositoryCIMObjectManager(instance, includeQualifiers,includeClassOrigin,propertyList)) |
bool found = false; |
|
try |
{ | { |
// |
if(objectPath.getKeyBindings().size() == 0) |
// No instance in the repository. Build new instance and save it. |
{ |
// |
// If a real object path is not specified (only the class and |
CDEBUG("Creating New instance of CIMOBjectManager"); |
// and namespace are present), then we can enumerate and pick |
instance = _buildInstanceSkeleton(CIM_OBJECTMANAGER_CLASSNAME); |
// the first instance (if any) and then set found to true |
|
Array<CIMInstance> tmpInstances = repository->enumerateInstances( |
_fixInstanceCommonKeys(instance); |
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER, true, false, false, false, |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,CIM_OBJECTMANAGER_CLASSNAME.getString()); |
propertyList); |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME,buildObjectManagerName()); |
Uint32 numInstances = tmpInstances.size(); |
_setPropertyValue(instance, CIMName("ElementName"), String("Pegasus")); |
if(numInstances == 1) |
|
{ |
|
instance = tmpInstances[0]; |
|
} |
|
PEGASUS_ASSERT(numInstances <= 1); |
|
} |
|
else |
|
{ |
|
instance = repository->getInstance(PEGASUS_NAMESPACENAME_INTEROP, |
|
objectPath, false, false, false, propertyList); |
|
} |
| |
|
found = (!instance.isUninitialized()); |
|
} |
|
catch(...) |
|
{ |
|
} |
|
|
|
if(!found) |
|
{ |
|
// |
|
// No instance in the repository. Build new instance and save it. |
// | // |
//Description property this object manager instance |
CIMClass omClass; |
// default is Pegasus CIM_Server Version. |
instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP, |
// Provided undocumented option to get this from the environment. |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER, omClass); |
// This should probably be removed or documented. |
|
// |
fixInstanceCommonKeys(instance); |
String description; |
|
char * envDescription; |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
envDescription = getenv("PEGASUS_CIMOM_DESCRIPTION"); |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString()); |
|
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, objectManagerName); |
|
setPropertyValue(instance, CIMName("ElementName"), String("Pegasus")); |
| |
description = (envDescription) ? envDescription : |
// |
|
//Description property this object manager instance |
|
// default is Pegasus CIM_Server Version. Get from |
|
// fields defined in PegasusVersion. |
|
// TODO. Add as an alternative the capability to get this |
|
// from config parameters. |
|
// If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it. |
|
// Otherwise build form the components below. |
|
|
|
String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ? |
|
String(PEGASUS_CIMOM_DESCRIPTION) |
|
: |
|
String(PEGASUS_CIMOM_GENERIC_NAME) + " " + |
String(PEGASUS_PRODUCT_NAME) + " Version " + | String(PEGASUS_PRODUCT_NAME) + " Version " + |
String(PEGASUS_PRODUCT_VERSION); |
String(PEGASUS_PRODUCT_VERSION) + " " + |
|
String(PEGASUS_PRODUCT_STATUS); |
| |
_setPropertyValue(instance, CIMName("Description"), description); |
setPropertyValue(instance, CIMName("Description"), description); |
| |
//Property GatherStatisticalData. Initially this is set to false | //Property GatherStatisticalData. Initially this is set to false |
// and can then be modified by a modify instance on the instance. | // and can then be modified by a modify instance on the instance. |
| |
Boolean gatherStatDataFlag = false; | Boolean gatherStatDataFlag = false; |
| |
_setPropertyValue(instance, OM_GATHERSTATISTICALDATA, Boolean(gatherStatDataFlag)); |
setPropertyValue(instance, OM_GATHERSTATISTICALDATA, Boolean(gatherStatDataFlag)); |
| |
// ATTN: This one is a problem KS rethink this. |
// Set the statistics property into the Statisticaldata class so that |
// the following is a temporary hack to set the value of the statistics |
// it can perform statistics gathering if necessary. |
// gathering function dynamically. We simply get the correct value |
|
// and call the internal method to set it each time this object is |
|
// built. |
|
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
StatisticalData* sd = StatisticalData::current(); | StatisticalData* sd = StatisticalData::current(); |
sd->setCopyGSD(gatherStatDataFlag); | sd->setCopyGSD(gatherStatDataFlag); |
|
|
| |
// write instance to the repository | // write instance to the repository |
CIMObjectPath instancePath; | CIMObjectPath instancePath; |
// Add the instance path to this if necessary ATTN ATTN: |
|
try | try |
{ | { |
CDEBUG("Create Instance for CIM_ObjectManager"); |
instancePath = repository->createInstance( |
instancePath = _repository->createInstance(_operationNamespace, |
objectPath.getNameSpace(), instance); |
instance ); |
instance.setPath(instancePath); |
} | } |
catch(const CIMException&) | catch(const CIMException&) |
{ | { |
// ATTN: KS generate log error if this not possible |
// TODO ATTN: KS generate log error if this not possible |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
instance.setPath(instancePath); |
|
} | } |
instance.filter(includeQualifiers, includeClassOrigin, propertyList); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instance); |
return instance; |
} | } |
| |
/** Get the instances of CIM_Namespace. Gets all instances of the namespace from |
/** get an instance of the PG_ComputerSystem class produced by the |
the repository namespace management functions |
ComputerSystem provider in the root/cimv2 namespace. |
Pegasus 2.4 - This now gets CIM_Namespace and its subclass PG_Namespace |
This function will either return an instance |
|
or throw an exception. |
|
@param includeQualifiers Boolean |
|
@param includeClassOrigin Boolean |
|
@param propertylist CIMPropertyList |
|
@return CIMInstance with a single built instance of the class |
|
@exception ObjectNotFound exception if a ComputerSystem instance cannot |
|
be retrieved. |
*/ | */ |
Array<CIMInstance> InteropProvider::_getInstancesCIMNamespace(const Boolean& includeQualifiers, |
CIMInstance InteropProvider::getComputerSystemInstance( |
const Boolean& includeClassOrigin, |
const CIMObjectPath& objectPath, |
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_getInstancesCIMNamespace()"); |
"InteropProvider::getComputerSystemInstance"); |
| |
CDEBUG("_getinstancesPGNamespace"); |
// Try to get the current object. If true then it is already created. |
Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces(); |
CIMInstance instance; |
CDEBUG("_getInstancesCIMNamespace. count = " << namespaceNames.size()); |
bool found = false; |
Array<CIMInstance> instanceArray; |
|
|
if(objectPath.getKeyBindings().size() == 0) |
|
{ |
|
// If a real object path is not specified (only the class and |
|
// and namespace are present), then we can enumerate and pick |
|
// the first instance (if any) and then set found to true |
|
Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances( |
|
OperationContext(), |
|
PEGASUS_NAMESPACENAME_CIMV2, |
|
PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false, |
|
propertyList); |
|
Uint32 numInstances = tmpInstances.size(); |
|
PEGASUS_ASSERT(numInstances <= 1); |
|
if(numInstances > 0) |
|
{ |
|
instance = tmpInstances[0]; |
|
CIMObjectPath tmpPath = instance.getPath(); |
|
tmpPath.setHost(hostName); |
|
tmpPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
instance.setPath(tmpPath); |
|
} |
|
} |
|
else |
|
{ |
|
CIMObjectPath copyPath(objectPath); |
|
copyPath.setNameSpace(PEGASUS_NAMESPACENAME_CIMV2); |
|
instance = cimomHandle.getInstance( |
|
OperationContext(), |
|
PEGASUS_NAMESPACENAME_CIMV2, |
|
copyPath, false, false, false, propertyList); |
|
copyPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
copyPath.setHost(hostName); |
|
instance.setPath(copyPath); |
|
} |
| |
// We build instances of PG namespace since that is the leaf class |
if(instance.isUninitialized()) |
for (Uint32 i = 0; i < namespaceNames.size(); i++) |
|
{ | { |
instanceArray.append( _buildInstancePGNamespace(namespaceNames[i])); |
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_FOUND, |
|
"Could not find ComputerSystem instance"); |
} | } |
CDEBUG("Build this many PG_Namespace Instances. count= " << instanceArray.size()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instanceArray); |
return instance; |
} | } |
| |
/** get the instance of namespace defined by the input parameter which is the object path |
/** get an instance of the PG_HostedObjectManager class produced by the |
for the instance required. |
ComputerSystem provider in the root/cimv2 namespace. |
ATTN: Note that this is incorrect. We are supplying the namespace name and need to supply |
This function will either return an instance |
the objectpath |
or throw an exception. |
@param TBD |
@param includeQualifiers Boolean |
@return CIMInstance with the found instance or CIMInstance() if nothing found. |
@param includeClassOrigin Boolean |
|
@param propertylist CIMPropertyList |
|
@return CIMInstance with a single built instance of the class |
|
@exception ObjectNotFound exception if a ComputerSystem instance cannot |
|
be retrieved. |
*/ | */ |
CIMInstance InteropProvider::_getInstanceCIMNamespace(const CIMNamespaceName & nameSpace) |
CIMInstance InteropProvider::getHostedObjectManagerInstance( |
|
const CIMObjectPath& objectPath, |
|
const CIMPropertyList& propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_getInstancesCIMNamespace()"); |
"InteropProvider::getHostedObjectManagerInstance"); |
|
|
|
// Try to get the current object. If true then it is already created. |
|
CIMInstance instance; |
|
bool found = false; |
| |
Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList()); |
CIMObjectPath csPath = getComputerSystemInstance().getPath(); |
|
CIMObjectPath omPath = getObjectManagerInstance().getPath(); |
|
String csPathString = csPath.toString(); |
|
String omPathString = omPath.toString(); |
| |
// search the instances for one with the name property value = input parameter. |
Array<CIMKeyBinding> objectPathBindings = objectPath.getKeyBindings(); |
for (Uint32 i = 0 ; i < instances.size() ; i++) |
for(Uint32 i = 0, n = objectPathBindings.size(); i < n; ++i) |
{ | { |
if (_getPropertyValue(instances[i], CIMName("name"), String::EMPTY) == nameSpace.getString()) |
const String & currentBinding = objectPathBindings[i].getValue(); |
|
if(currentBinding != csPathString && currentBinding != omPathString) |
{ | { |
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_FOUND, |
|
"Could not find HostedObjectManager instance " + |
|
objectPath.toString()); |
|
} |
|
} |
|
|
|
CIMClass hostedOMClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER, |
|
false, true, false); |
|
|
|
instance = hostedOMClass.buildInstance(false, false, CIMPropertyList()); |
|
|
|
setPropertyValue(instance, PROPERTY_ANTECEDENT, |
|
CIMValue(csPath)); |
|
setPropertyValue(instance, PROPERTY_DEPENDENT, |
|
CIMValue(omPath)); |
|
|
|
instance.setPath(instance.buildPath(hostedOMClass)); |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instances[i]); |
return instance; |
} | } |
|
|
|
Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances() |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::enumHostedAccessPointInstance"); |
|
Array<CIMInstance> instances; |
|
|
|
CIMObjectPath csPath = getComputerSystemInstance().getPath(); |
|
Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances(); |
|
CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false); |
|
for(Uint32 i = 0, n = commMechs.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentCommMech = commMechs[i]; |
|
CIMInstance hapInstance = hapClass.buildInstance(false, false, |
|
CIMPropertyList()); |
|
setPropertyValue(hapInstance, PROPERTY_ANTECEDENT, csPath); |
|
setPropertyValue(hapInstance, PROPERTY_DEPENDENT, |
|
currentCommMech.getPath()); |
|
hapInstance.setPath(hapInstance.buildPath(hapClass)); |
|
instances.append(hapInstance); |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
CIMInstance nullInstance; |
return instances; |
return(nullInstance); |
|
} | } |
| |
CIMObjectPath InteropProvider::_buildReference(const CIMInstance& instance, const CIMName& className) |
/** Get the instances of CIM_Namespace. Gets all instances of the namespace from |
|
the repository namespace management functions. Builds instances that |
|
match all of the request attributes. |
|
*/ |
|
Array<CIMInstance> InteropProvider::enumNamespaceInstances() |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_getInstancesCIMNamespace()"); |
|
|
|
Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces(); |
|
Array<CIMInstance> instanceArray; |
|
|
|
// Build instances of PG namespace since that is the leaf class |
|
for (Uint32 i = 0, n = namespaceNames.size(); i < n; i++) |
{ | { |
return(_buildObjectPath(_operationNamespace,className, instance)); |
instanceArray.append( |
|
buildNamespaceInstance(namespaceNames[i].getString())); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
return instanceArray; |
} | } |
| |
Array<CIMInstance> InteropProvider::_buildInstancesNamespaceInManager() |
/* build the full instances set of of the association class NamespacInManager. |
|
|
|
NOTE: THe input object path is not really use at this point. |
|
*/ |
|
Array<CIMInstance> InteropProvider::enumNamespaceInManagerInstances() |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstancesNamespaceInManager"); |
"InteropProvider::buildInstancesNamespaceInManager"); |
| |
Array<CIMInstance> namespaceInstances = _getInstancesCIMNamespace(false, |
Array<CIMInstance> namespaceInstances = enumNamespaceInstances(); |
false, CIMPropertyList()); |
|
|
CIMObjectPath objectManagerPath(hostName, PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER); |
|
CIMInstance instanceObjMgr = getObjectManagerInstance(objectManagerPath, |
|
CIMPropertyList()); |
| |
CIMInstance instanceObjMgr = _getInstanceCIMObjectManager( true, true, CIMPropertyList()); |
objectManagerPath = instanceObjMgr.getPath(); |
| |
CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME); |
|
| |
Array<CIMInstance> assocInstances; | Array<CIMInstance> assocInstances; |
|
CIMClass targetClass; |
| |
|
CIMInstance instanceskel = buildInstanceSkeleton( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_NAMESPACEINMANAGER, targetClass); |
|
// Build and instance for each namespace instance. |
for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++) | for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++) |
{ | { |
CIMInstance instance = _buildInstanceSkeleton(CIM_NAMESPACEINMANAGER_CLASSNAME); |
CIMInstance instance = instanceskel.clone(); |
|
setPropertyValue(instance, PROPERTY_ANTECEDENT, objectManagerPath); |
_setPropertyValue(instance, CIMName("Antecedent"), refObjMgr); |
setPropertyValue(instance, PROPERTY_DEPENDENT, |
//ATTNATTN: this is weak qualifier. |
namespaceInstances[i].getPath()); |
_setPropertyValue(instance, CIMName("Dependent"), _buildReference(namespaceInstances[i], |
|
CIM_NAMESPACEINMANAGER_CLASSNAME)); |
CIMObjectPath objPath = instance.buildPath(targetClass); |
|
objPath.setHost(hostName); |
|
objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
instance.setPath(objPath); |
assocInstances.append(instance); | assocInstances.append(instance); |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(assocInstances); |
return assocInstances; |
} | } |
|
/* build the instances of the defined association. |
Array<CIMInstance> InteropProvider::_buildInstancesCommMechanismForManager() |
*/ |
|
Array<CIMInstance> InteropProvider::enumCommMechanismForManagerInstances() |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstancesCommMechanismForManager"); |
"InteropProvider::enumCommMechanismForManagerInstances"); |
| |
Array<CIMInstance> commInstances = _buildInstancesPGCIMXMLCommunicationMechanism(true, |
Array<CIMInstance> commInstances = enumCIMXMLCommunicationMechanismInstances(); |
true, CIMPropertyList()); |
|
| |
CIMInstance instanceObjMgr = _getInstanceCIMObjectManager( true, true, CIMPropertyList()); |
CIMInstance instanceObjMgr = getObjectManagerInstance(); |
| |
CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME); |
CIMObjectPath refObjMgr = instanceObjMgr.getPath(); |
Array<CIMInstance> assocInstances; |
|
| |
for (Uint32 i = 0 ; i < commInstances.size() ; i++) |
Array<CIMInstance> assocInstances; |
|
CIMClass targetClass; |
|
CIMInstance instanceskel = buildInstanceSkeleton( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, targetClass); |
|
for (Uint32 i = 0, n = commInstances.size(); i < n; ++i) |
{ | { |
|
CIMInstance instance = instanceskel.clone(); |
|
|
|
setPropertyValue(instance, PROPERTY_ANTECEDENT, refObjMgr); |
| |
CIMInstance instance = _buildInstanceSkeleton(CIM_COMMMECHANISMFORMANAGER_CLASSNAME); |
setPropertyValue(instance, PROPERTY_DEPENDENT, |
|
commInstances[i].getPath()); |
| |
_setPropertyValue(instance,CIMName("Antecedent"), refObjMgr); |
instance.setPath(instance.buildPath(targetClass)); |
//ATTNATTN: this is weak qualifier. |
|
_setPropertyValue(instance,CIMName("Dependent"), _buildReference(commInstances[i],CIM_COMMMECHANISMFORMANAGER_CLASSNAME)); |
|
assocInstances.append(instance); | assocInstances.append(instance); |
} | } |
| |
|
|
@exceptions - exceptions carried forward from create instance | @exceptions - exceptions carried forward from create instance |
and addProperty. | and addProperty. |
*/ | */ |
CIMInstance InteropProvider::_buildInstancePGNamespace(const CIMNamespaceName & nameSpace) |
CIMInstance InteropProvider::buildNamespaceInstance( |
|
const String & nameSpace) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_buildInstancePGNamespace"); |
"InteropProvider::buildInstancePGNamespace"); |
| |
// ATTN: KS need to get the real objectManager name from elsewhere. the only place |
CIMClass targetClass; |
// this exists is through the objectmanager object. |
CIMInstance instance = buildInstanceSkeleton( |
// ATTN: Should we be saving the objectmanager name somewhere internally either in |
PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_NAMESPACE, |
// interop or more generally somewhere within the system for common access. |
targetClass); |
String ObjectManagerName = "ObjectManagerNameValue"; |
|
| |
CIMInstance instance = _buildInstanceSkeleton(PG_NAMESPACE_CLASSNAME); |
fixInstanceCommonKeys(instance); |
|
|
_fixInstanceCommonKeys(instance); |
|
| |
//ObjectManagerCreationClassName | //ObjectManagerCreationClassName |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, CIM_OBJECTMANAGER_CLASSNAME.getString()); |
setPropertyValue(instance, |
|
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString()); |
| |
//ObjectManagerName | //ObjectManagerName |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, ObjectManagerName); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
|
objectManagerName); |
| |
//CreationClassName | //CreationClassName |
// Class in which this was created, | // Class in which this was created, |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, CIM_NAMESPACE_CLASSNAME.getString()); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
|
PEGASUS_CLASSNAME_PG_NAMESPACE.getString()); |
//Name | //Name |
// This is the namespace name itself | // This is the namespace name itself |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, nameSpace.getString()); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, |
|
nameSpace); |
| |
//ClassInfo | //ClassInfo |
// Set the classinfo to unknown and the description to namespace. | // Set the classinfo to unknown and the description to namespace. |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0)); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0)); |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO, String("namespace")); |
setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO, |
|
String("namespace")); |
| |
// | // |
// Everything above was commmon to CIM Namespace. The following is PG_Namespace Properties | // Everything above was commmon to CIM Namespace. The following is PG_Namespace Properties |
|
|
// ATTN: KS Get the correct values for these entities from repository interface. | // ATTN: KS Get the correct values for these entities from repository interface. |
| |
CIMRepository::NameSpaceAttributes attributes; | CIMRepository::NameSpaceAttributes attributes; |
_repository->getNameSpaceAttributes(nameSpace.getString(), attributes); |
repository->getNameSpaceAttributes(nameSpace, attributes); |
String parent=""; |
String parent = String::EMPTY; |
String name = ""; |
String name = String::EMPTY; |
Boolean shareable=false; | Boolean shareable=false; |
Boolean updatesAllowed=true; | Boolean updatesAllowed=true; |
for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++) | for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++) |
{ | { |
String key=i.key(); | String key=i.key(); |
String value = i.value(); | String value = i.value(); |
|
|
if (String::equalNoCase(key,"shareable")) | if (String::equalNoCase(key,"shareable")) |
{ | { |
if (String::equalNoCase(value,"true")) | if (String::equalNoCase(value,"true")) |
|
|
// Test to be sure we are returning proper namespace name | // Test to be sure we are returning proper namespace name |
else if (String::equalNoCase(key,"name")) | else if (String::equalNoCase(key,"name")) |
{ | { |
if (!String::equalNoCase(value, nameSpace.getString())) |
if (!String::equalNoCase(value, nameSpace)) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
// This is poor exception since it reflects internal error. Do error log | // This is poor exception since it reflects internal error. Do error log |
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, |
throw CIMNotSupportedException( |
"Namespace attribute rtnd error for key " + key + "expected " + | "Namespace attribute rtnd error for key " + key + "expected " + |
nameSpace.getString()+ value + " in " + String(thisProvider)); |
nameSpace + value + " in " + String(thisProvider)); |
} | } |
| |
name = value; | name = value; |
|
|
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
// Poor error definition since it reflects internal error. do error log | // Poor error definition since it reflects internal error. do error log |
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace.getString()+ |
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace + |
" namespace attribute " + key + " option not supported in"+ String(thisProvider)); |
" namespace attribute " + key + " option not supported in" + |
|
String(thisProvider)); |
} | } |
} | } |
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, updatesAllowed); |
setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, updatesAllowed); |
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable); |
setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable); |
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent); |
setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent); |
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name); |
setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name); |
| |
|
CIMObjectPath objPath = instance.buildPath(targetClass); |
|
objPath.setHost(hostName); |
|
objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
instance.setPath(objPath); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instance); |
return instance; |
} | } |
void _validateCIMNamespaceKeys(const CIMObjectPath& objectPath) |
|
|
void validatePGNamespaceKeys(const CIMObjectPath& objectPath) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_validateCIMNamespaceKeys"); |
"InteropProvider::validatePGNamespaceKeys"); |
| |
Boolean valid = true; | Boolean valid = true; |
CIMName propertyName; | CIMName propertyName; |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
System::getSystemCreationClassName ())) | System::getSystemCreationClassName ())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getFullyQualifiedHostName())) | System::getFullyQualifiedHostName())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
valid = false; | valid = false; |
} | } |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
| |
// ATTN: This one still a problem. We have to get the name first | // ATTN: This one still a problem. We have to get the name first |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
valid = false; | valid = false; |
} | } |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
System::getHostName())) | System::getHostName())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_validateRequiredProperty(objectPath, |
if (!validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_NAME, | CIM_NAMESPACE_PROPERTY_NAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
|
|
} | } |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
/** completes a property in the defined instance either | /** completes a property in the defined instance either |
by adding the complete property if it does not exist | by adding the complete property if it does not exist |
or by adding the value if the property does exist. | or by adding the value if the property does exist. |
|
|
creation of new instances and that the | creation of new instances and that the |
values are logical for the CIMOM. | values are logical for the CIMOM. |
*/ | */ |
Boolean _completeProperty(CIMInstance& instance, |
Boolean completeProperty(CIMInstance& instance, |
const CIMName& propertyName, | const CIMName& propertyName, |
const String& value) | const String& value) |
{ | { |
| |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_completeProperty()"); |
"InteropProvider::completeProperty()"); |
| |
Uint32 pos; | Uint32 pos; |
| |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
propertyName, | propertyName, |
value)) | value)) |
{ | { |
|
|
} | } |
else | else |
{ | { |
// |
setPropertyValue(instance, propertyName, value); |
_setPropertyValue(instance, propertyName, value); |
|
} | } |
} | } |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(true); | return(true); |
} | } |
Boolean _completeCIMNamespaceKeys(CIMInstance& instance) |
Boolean completeCIMNamespaceKeys(CIMInstance& instance) |
{ | { |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_completeCIMNamespaceKeys"); | "InteropProvider::_completeCIMNamespaceKeys"); |
| |
Boolean valid = true; | Boolean valid = true; |
CIMName propertyName; | CIMName propertyName; |
| |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
System::getSystemCreationClassName ())) | System::getSystemCreationClassName ())) |
{ | { |
|
|
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
| |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getFullyQualifiedHostName())) | System::getFullyQualifiedHostName())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
| |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
valid = false; | valid = false; |
} | } |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
System::getHostName())) | System::getHostName())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_completeProperty(instance, |
if (!completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_NAME, | CIM_NAMESPACE_PROPERTY_NAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
|
|
} | } |
| |
| |
void _validateCIMNamespaceKeys(const CIMInstance& instance) |
void validateCIMNamespaceKeys(const CIMInstance& instance) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_validateCIMNamespaceKeys"); |
"InteropProvider::validateCIMNamespaceKeys"); |
Boolean valid = true; | Boolean valid = true; |
CIMName propertyName; | CIMName propertyName; |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
System::getSystemCreationClassName ())) | System::getSystemCreationClassName ())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getFullyQualifiedHostName ())) | System::getFullyQualifiedHostName ())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
| |
// ATTN: This one still a problem. We have to get the name first | // ATTN: This one still a problem. We have to get the name first |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, | CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; | propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
valid = false; | valid = false; |
} | } |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
System::getHostName())) | System::getHostName())) |
{ | { |
|
|
valid = false; | valid = false; |
} | } |
| |
if (!_validateRequiredProperty(instance, |
if (!validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_NAME, | CIM_NAMESPACE_PROPERTY_NAME, |
String::EMPTY)) | String::EMPTY)) |
{ | { |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
/** builds complete object path from instance and classinfo by building the full path |
|
with host and namespace names included. |
|
*/ |
|
CIMObjectPath InteropProvider::_buildObjectPath(const CIMNamespaceName& name, |
|
const CIMName& className, |
|
const CIMInstance& instance) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_buildObjectPath"); |
|
|
|
CIMObjectPath objectPath; |
|
objectPath = _buildInstancePath(name,className,instance); |
|
|
|
objectPath.setHost(System::getHostName()); |
|
|
|
objectPath.setNameSpace(name); |
|
|
|
PEG_METHOD_EXIT(); |
|
return(objectPath); |
|
} |
|
|
|
/* Given a class and instance build the instance path for a |
|
the object. This builds all components of the path |
|
@param namespace name to build |
|
@return CIMObjectPath containing namespace, class and keybinding |
|
components of path |
|
@exceptions - Passes repository exceptions. |
|
*/ |
|
|
|
CIMObjectPath InteropProvider::_buildInstancePath(const CIMNamespaceName& name, |
|
const CIMName& className, |
|
const CIMInstance& instance) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_buildInstancePath"); |
|
|
|
// get the class CIM_Namespace class to use in building path |
|
// Exception out if Class does not exist in this namespace |
|
CIMClass thisClass = _getClass(name, className); |
|
|
|
CIMObjectPath ref = instance.buildPath(thisClass); |
|
|
|
PEG_METHOD_EXIT(); |
|
return(ref); |
|
} |
|
|
|
//************************************************************** | //************************************************************** |
// Overloaded functions to get key value with different params | // Overloaded functions to get key value with different params |
//************************************************************** | //************************************************************** |
|
|
@return value of name property | @return value of name property |
@exceptions CIMInvalidParameterException | @exceptions CIMInvalidParameterException |
*/ | */ |
String _getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName) |
String getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName) |
{ | { |
Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); | Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); |
| |
|
|
throw CIMInvalidParameterException("Invalid key property: " + keyName.getString()); | throw CIMInvalidParameterException("Invalid key property: " + keyName.getString()); |
} | } |
| |
String _getKeyValue(const CIMInstance& instance, const CIMName& keyName) |
String getKeyValue(const CIMInstance& instance, const CIMName& keyName) |
{ | { |
Uint32 pos; | Uint32 pos; |
CIMValue propertyValue; | CIMValue propertyValue; |
|
|
String name; | String name; |
propertyValue.get(name); | propertyValue.get(name); |
return(name); | return(name); |
//ATTN: KS Returns String whereas below returns CIMNamespaceName. |
|
} | } |
| |
|
/** Test for valid CIMReferences from an association instance. If there is a role |
|
property, tests if there is a match for this role and the target object. |
|
Confirms that this role and this reference exist in the target instance. |
|
|
|
@param target - The target path for the association. Localization assumed. |
|
@param instance - The association class instance we are searching for references |
|
@param role - The role we require. I there is no role, this is String::EMPTY |
|
@return - returns Boolean true if target is found in a reference that is |
|
the same role |
|
*/ |
|
Boolean isInstanceValidReference(const CIMObjectPath& target, |
|
const CIMInstance& instance, |
|
const String& role) |
|
{ |
|
// Test if role parameter is valid property. |
|
Uint32 pos; |
|
if (role != String::EMPTY) |
|
{ |
|
// Test if property with this role exists. |
|
if ((pos = instance.findProperty(role)) == PEG_NOT_FOUND) |
|
throw CIMException(CIM_ERR_INVALID_PARAMETER); |
|
|
|
// Check to be sure this is a reference property |
|
// This test may not be necessary. Combine it into the loop. |
|
if (instance.getProperty(pos).getType() != CIMTYPE_REFERENCE) |
|
throw CIMException(CIM_ERR_INVALID_PARAMETER); |
|
} |
|
//Search instance for all reference properties |
|
for (Uint32 j = 0; j < instance.getPropertyCount() ; j++) |
|
{ |
|
const CIMConstProperty p = instance.getProperty(j); |
|
if (p.getType() == CIMTYPE_REFERENCE) |
|
{ |
|
// If there is no role or the role is the same as this property name |
|
CIMValue v = p.getValue(); |
|
CIMObjectPath path; |
|
v.get(path); |
|
|
|
// if no role or role ==this role and target = this path, rtn true. |
|
if ((role == String::EMPTY) || (CIMName(role) == p.getName())) |
|
{ |
|
// and if target is identical to reference path |
|
if (target.identical(path)) |
|
return(true); |
|
} |
|
} |
|
} |
|
return( false ); |
|
} |
|
/** Filters the input of instances (which contain path info) |
|
using the assocClassName, assocRole, ResultClassName and |
|
resultRole. Removes any instances from the list that |
|
do not match the filters. |
|
@instances Array<CIMInstance to filter. |
|
@ |
|
* TODO - Shouldn't we remove rather than copy??? faster. |
|
* TODO - why extra check for no resultClass?? |
|
*/ |
|
Array<CIMObject> filterReferenceInstances(Array<CIMInstance>& instances, |
|
const CIMObjectPath& targetobjectName, |
|
const CIMName& resultClass, |
|
const String& resultRole) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"filterReferenceInstances()"); |
|
|
|
CIMObjectPath targetReference = CIMObjectPath( |
|
String(), |
|
CIMNamespaceName(), |
|
targetobjectName.getClassName(), |
|
targetobjectName.getKeyBindings()); |
|
Array<CIMObject> rtnObjects; |
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
|
{ |
|
if (resultClass.isNull() || resultClass.equal(instances[i].getClassName())) |
|
{ |
|
// if this association instance has this role in targetReference, true |
|
if (isInstanceValidReference(targetobjectName, instances[i], resultRole)) |
|
{ |
|
rtnObjects.append(instances[i]); |
|
} |
|
} |
|
} |
|
PEG_METHOD_EXIT(); |
|
return( rtnObjects ); |
|
} |
//*************************************************************************** | //*************************************************************************** |
// The following section is the Instance Operation processors | // The following section is the Instance Operation processors |
//*************************************************************************** | //*************************************************************************** |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()"); |
| |
|
AutoMutex autoMut(changeControlMutex); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s createInstance. InstanceReference= %s", | "%s createInstance. InstanceReference= %s", |
thisProvider, | thisProvider, |
(const char *) instanceReference.toString().getCString()); | (const char *) instanceReference.toString().getCString()); |
| |
|
// test for legal namespace for this provider. Exception if not |
|
namespaceSupported(instanceReference); |
|
|
handler.processing(); | handler.processing(); |
CIMNamespaceName newNamespaceName; |
|
| |
CDEBUG("CreateInstance " << instanceReference.toString()); |
CIMInstance localInstance; |
// operation namespace needed internally to get class. |
const CIMName & instClassName = instanceReference.getClassName(); |
_operationNamespace = instanceReference.getNameSpace(); |
TARGET_CLASS classEnum = PG_NAMESPACE; |
|
if(instClassName.equal(PEGASUS_CLASSNAME_CIM_NAMESPACE)) |
|
{ |
|
localInstance = CIMInstance(PEGASUS_CLASSNAME_PG_NAMESPACE); |
|
// Copy the properties of the source instance |
|
for (Uint32 i = 0 ; i < myInstance.getQualifierCount() ; i++) |
|
{ |
|
localInstance.addQualifier(myInstance.getQualifier(i).clone()); |
|
} |
| |
// Verify that ClassName is correct and get value |
for (Uint32 i = 0 ; i < myInstance.getPropertyCount() ; i++) |
targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName()); |
{ |
|
localInstance.addProperty(myInstance.getProperty(i).clone()); |
|
} |
|
} |
|
else |
|
{ |
|
classEnum = translateClassInput(instanceReference.getClassName()); |
|
} |
| |
String userName = _validateUserID(context); |
|
CIMObjectPath newInstanceReference; |
|
| |
if ((classEnum == CIM_OBJECTMANAGER) || |
CIMObjectPath newInstanceReference; |
(classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)) |
CIMNamespaceName newNamespaceName; |
throw CIMNotSupportedException("InteropProvider, Create Not allowed"); |
|
| |
if (classEnum == PG_NAMESPACE) | if (classEnum == PG_NAMESPACE) |
{ | { |
#ifdef PEGASUS_OS_OS400 | #ifdef PEGASUS_OS_OS400 |
MessageLoaderParms mparms("ControlProviders.InteropProvider.CREATE_INSTANCE_NOT_ALLOWED", |
MessageLoaderParms mparms( |
|
"ControlProviders.InteropProvider.CREATE_INSTANCE_NOT_ALLOWED", |
"Create instance operation not allowed by Interop Provider for class $0.", | "Create instance operation not allowed by Interop Provider for class $0.", |
PG_NAMESPACE_CLASSNAME.getString()); |
PEGASUS_CLASSNAME_PG_NAMESPACE.getString()); |
throw CIMNotSupportedException(mparms); | throw CIMNotSupportedException(mparms); |
#else | #else |
// Create local instance to complete any keys. |
// Create local instance to complete any keys if not created above. |
CIMInstance localInstance = myInstance.clone(); |
if (localInstance.isUninitialized()) |
|
{ |
|
localInstance = myInstance.clone(); |
|
} |
| |
_completeCIMNamespaceKeys(localInstance); |
completeCIMNamespaceKeys(localInstance); |
// Validate that keys are as required. Does its own exception. | // Validate that keys are as required. Does its own exception. |
newNamespaceName = _getKeyValue(myInstance, CIM_NAMESPACE_PROPERTY_NAME); |
newNamespaceName = getKeyValue(myInstance, |
|
CIM_NAMESPACE_PROPERTY_NAME); |
| |
newInstanceReference = _buildInstancePath(_operationNamespace, |
CIMNamespaceName opNameSpace = instanceReference.getNameSpace(); |
PG_NAMESPACE_CLASSNAME, localInstance); |
newInstanceReference = buildInstancePath( |
|
repository->getClass(opNameSpace, PEGASUS_CLASSNAME_PG_NAMESPACE, |
|
false, true, false), |
|
instanceReference.getHost(), opNameSpace, |
|
localInstance); |
#endif | #endif |
} | } |
|
|
else // Invalid class for the create functions. | else // Invalid class for the create functions. |
{ | { |
PEGASUS_ASSERT(false); |
PEG_METHOD_EXIT(); |
|
throw CIMNotSupportedException( |
|
"InteropProvider::CreateInstance Not allowed for class " + |
|
instanceReference.getClassName().getString()); |
} | } |
| |
// Create the new namespace | // Create the new namespace |
|
|
CIMRepository::NameSpaceAttributes attributes; | CIMRepository::NameSpaceAttributes attributes; |
// optional property. Set false if not found. | // optional property. Set false if not found. |
// ATTN: Should set to class default. | // ATTN: Should set to class default. |
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_ISSHAREABLE) != PEG_NOT_FOUND) |
if(localInstance.findProperty( |
|
PG_NAMESPACE_PROPERTY_ISSHAREABLE) != PEG_NOT_FOUND) |
{ | { |
if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, false)) |
if(getPropertyValue(myInstance, |
|
PG_NAMESPACE_PROPERTY_ISSHAREABLE, false)) |
{ | { |
attributes.insert("shareable","true"); | attributes.insert("shareable","true"); |
shareable = true; | shareable = true; |
} | } |
else | else |
|
{ |
attributes.insert("shareable", "false"); | attributes.insert("shareable", "false"); |
} | } |
|
} |
else | else |
|
{ |
attributes.insert("shareable", "false"); | attributes.insert("shareable", "false"); |
|
} |
| |
// Optional property. Set false if not found. | // Optional property. Set false if not found. |
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED) != PEG_NOT_FOUND) |
if(localInstance.findProperty( |
|
PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED) != PEG_NOT_FOUND) |
{ | { |
if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false)) |
if (getPropertyValue(myInstance, |
|
PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false)) |
{ | { |
attributes.insert("updatesAllowed","true"); | attributes.insert("updatesAllowed","true"); |
updatesAllowed = true; | updatesAllowed = true; |
} | } |
else | else |
|
{ |
attributes.insert("updatesAllowed", "false"); | attributes.insert("updatesAllowed", "false"); |
} | } |
|
} |
else | else |
|
{ |
attributes.insert("updatesAllowed", "false"); | attributes.insert("updatesAllowed", "false"); |
|
} |
| |
// ATTN: Need to reflect and dependencies between these properties. Right now | // ATTN: Need to reflect and dependencies between these properties. Right now |
// this lets anything happen. | // this lets anything happen. |
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_PARENTNAMESPACE) != PEG_NOT_FOUND) |
if (localInstance.findProperty( |
|
PG_NAMESPACE_PROPERTY_PARENTNAMESPACE) != PEG_NOT_FOUND) |
{ | { |
String parent = _getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY); |
String parent = getPropertyValue(myInstance, |
|
PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY); |
if (parent != String::EMPTY) | if (parent != String::EMPTY) |
attributes.insert("parent",parent); | attributes.insert("parent",parent); |
} | } |
_repository->createNameSpace(newNamespaceName, attributes); |
repository->createNameSpace(newNamespaceName, attributes); |
| |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"Namespace = " + newNamespaceName.getString() + | "Namespace = " + newNamespaceName.getString() + |
" successfully created."); | " successfully created."); |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
"Create Namespace: Shareable = $0, Updates allows: $1, Parent: $2", |
"Create Namespace: Shareable = $0, Updates allowed: $1, Parent: $2", |
newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent ); |
newNamespaceName.getString(), shareable? |
|
"true" : "false", shareable? "true" : "false", parent ); |
| |
} | } |
catch(const CIMException&) | catch(const CIMException&) |
|
|
ResponseHandler & handler) | ResponseHandler & handler) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance"); |
|
const CIMName instClassName = instanceName.getClassName(); |
|
#ifndef PEGASUS_OS_OS400 |
|
AutoMutex autoMut(changeControlMutex); |
| |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s deleteInstance. instanceName= %s", | "%s deleteInstance. instanceName= %s", |
thisProvider, | thisProvider, |
(const char *) instanceName.toString().getCString()); | (const char *) instanceName.toString().getCString()); |
| |
_operationNamespace = instanceName.getNameSpace(); |
if(instClassName == PEGASUS_CLASSNAME_PG_NAMESPACE) |
handler.processing(); |
|
// Verify that ClassName is correct and get value |
|
targetClass classEnum = _verifyValidClassInput(instanceName.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
|
|
// Delete the instance since it may be in persistent storage |
|
if ((classEnum == CIM_OBJECTMANAGER)) |
|
{ |
|
try |
|
{ |
|
_repository->deleteInstance(_operationNamespace,instanceName); |
|
} |
|
catch(const CIMException&) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw; |
|
} |
|
} |
|
else if (classEnum == PG_NAMESPACE) |
|
{ | { |
|
handler.processing(); |
CIMNamespaceName deleteNamespaceName; | CIMNamespaceName deleteNamespaceName; |
#ifdef PEGASUS_OS_OS400 |
|
MessageLoaderParms mparms("ControlProviders.InteropProvider.DELETE_INSTANCE_NOT_ALLOWED", |
|
"Delete instance operation not allowed by Interop Provider for class $0.", |
|
PG_NAMESPACE_CLASSNAME.getString()); |
|
throw CIMNotSupportedException(mparms); |
|
#else |
|
// validate requred keys. Exception out if not valid | // validate requred keys. Exception out if not valid |
_validateCIMNamespaceKeys(instanceName); |
validatePGNamespaceKeys(instanceName); |
| |
deleteNamespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); |
deleteNamespaceName = getKeyValue(instanceName, PG_NAMESPACE_PROPERTY_NAME); |
#endif |
|
|
|
Array<CIMNamespaceName> namespaceNames; |
|
namespaceNames = _enumerateNameSpaces(); |
|
| |
if (deleteNamespaceName.equal (ROOTNS)) | if (deleteNamespaceName.equal (ROOTNS)) |
{ | { |
throw CIMNotSupportedException("root namespace cannot be deleted."); | throw CIMNotSupportedException("root namespace cannot be deleted."); |
} | } |
| |
_repository->deleteNameSpace(deleteNamespaceName); |
repository->deleteNameSpace(deleteNamespaceName); |
| |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"Namespace = " + deleteNamespaceName.getString() + | "Namespace = " + deleteNamespaceName.getString() + |
|
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
"Interop Provider Delete Namespace: $0", | "Interop Provider Delete Namespace: $0", |
deleteNamespaceName.getString()); | deleteNamespaceName.getString()); |
|
handler.complete(); |
|
|
|
PEG_METHOD_EXIT(); |
|
return; |
} | } |
else |
|
{ |
#endif |
throw CIMNotSupportedException("Delete Not allowed for " + instanceName.getClassName().getString()); |
MessageLoaderParms mparms( |
|
"ControlProviders.InteropProvider.DELETE_INSTANCE_NOT_ALLOWED", |
|
"Delete instance operation not allowed by Interop Provider for class $0.", |
|
instClassName.getString()); |
|
throw CIMNotSupportedException(mparms); |
} | } |
| |
handler.processing(); |
/** 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 unitinialitized. |
|
*/ |
|
CIMInstance InteropProvider::localGetInstance( |
|
const OperationContext & context, |
|
const CIMObjectPath & instanceName, |
|
const CIMPropertyList & propertyList) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance"); |
| |
handler.complete(); |
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) |
|
{ |
|
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 rtnInstance; |
|
|
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
|
{ |
|
if (instanceName == instances[i].getPath()) |
|
{ |
|
/* DEBUG SUPPORT |
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"%s getInstance return instance number %u\npath: %s\n %s\n",thisProvider, i, |
|
(instances[i].getPath().toString().getCString()), |
|
( ( CIMObject) instances[i]).toString().getCString()); |
|
*****/ |
|
rtnInstance = instances[i]; |
|
break; |
|
// TODO Add test for duplicates somewhere. |
|
} |
|
} |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return ; |
return rtnInstance; |
} | } |
|
|
//*************************************************************************** | //*************************************************************************** |
// getInstance | // getInstance |
//*************************************************************************** | //*************************************************************************** |
|
|
const CIMPropertyList & propertyList, | const CIMPropertyList & propertyList, |
InstanceResponseHandler & handler) | InstanceResponseHandler & handler) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::getInstance"); |
// test for legal namespace for this provider. Exception if not |
|
namespaceSupported(instanceName); |
|
|
|
handler.processing(); |
|
|
|
CIMInstance myInstance = localGetInstance( |
|
context, |
|
instanceName, |
|
propertyList); |
|
|
|
if (!myInstance.isUninitialized()) |
|
handler.deliver(myInstance); |
|
else |
|
throw CIMObjectNotFoundException(instanceName.toString()); |
|
|
|
handler.complete(); |
|
} |
| |
|
//***************************************************************************************** |
|
// localEnumerateInstances |
|
// EnumerateInstances equivalent to external but returns instances |
|
// Used by other operations to build instances for processing |
|
// Note that this delivers instances as a group rather than incrementally. |
|
// This technique should only be used for small groups of instances. |
|
//**************************************************************************************** |
|
|
|
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, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s getInstance. instanceName= %s , includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", |
"%s enumerateInstances. referenc= %s , PropertyList= %s", |
thisProvider, | thisProvider, |
(const char *)instanceName.toString().getCString(), |
(const char *)className.getString().getCString(), |
(const char *)_showBool(includeQualifiers).getCString(), |
(const char *)propertyListToString(propertyList).getCString()); |
(const char*) _showBool(includeClassOrigin).getCString(), |
|
(const char *)_showPropertyList(propertyList).getCString()); |
|
// Verify that ClassName is correct and get value | // Verify that ClassName is correct and get value |
targetClass classEnum = _verifyValidClassInput(instanceName.getClassName()); |
TARGET_CLASS classEnum = translateClassInput(className); |
| |
_operationNamespace = instanceName.getNameSpace(); |
Array<CIMInstance> instances; |
String userName = _validateUserID(context); |
switch(classEnum) |
// begin processing the request |
|
handler.processing(); |
|
if (classEnum == CIM_OBJECTMANAGER) |
|
{ | { |
CIMInstance instance = _getInstanceCIMObjectManager(includeQualifiers, |
case PG_OBJECTMANAGER: |
includeClassOrigin, propertyList); |
{ |
handler.deliver(instance); |
instances.append(getObjectManagerInstance(ref, propertyList)); |
handler.complete(); |
break; |
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
|
case PG_CIMXMLCOMMUNICATIONMECHANISM: |
if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ | { |
// ATTN: test for correct instance KS: Priority 1 |
instances = enumCIMXMLCommunicationMechanismInstances(); |
Array <CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism( |
break; |
includeQualifiers, |
|
includeClassOrigin, propertyList); |
|
handler.deliver(instances[0]); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
|
case PG_NAMESPACEINMANAGER: |
if (classEnum == CIM_NAMESPACEINMANAGER) |
|
{ | { |
handler.complete(); |
instances = enumNamespaceInManagerInstances(); |
PEG_METHOD_EXIT(); |
break; |
return; |
|
} | } |
|
case PG_COMMMECHANISMFORMANAGER: |
// Get List of namespaces |
|
Array<CIMNamespaceName> namespaceNames; |
|
namespaceNames = _enumerateNameSpaces(); |
|
CIMInstance instance; |
|
|
|
if (classEnum == PG_NAMESPACE) |
|
{ | { |
// Not clear what we have to take into account here. |
instances = enumCommMechanismForManagerInstances(); |
// get the namespace from the name value. |
break; |
// should check the other keys to see if valid. |
} |
CIMNamespaceName namespaceName; |
case PG_NAMESPACE: |
namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); |
|
|
|
// ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); |
|
if (!Contains(namespaceNames, namespaceName)) |
|
{ | { |
throw CIMObjectNotFoundException("Namespace does not exist: " |
instances = enumNamespaceInstances(); |
+ namespaceName.getString()); |
break; |
} | } |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
case PG_REGISTEREDPROFILE: |
"Namespace = " + namespaceName.getString() + " successfully found."); |
{ |
|
instances = enumRegisteredProfileInstances(); |
instance = _getInstanceCIMNamespace(namespaceName); |
break; |
} | } |
else // processing for __Namespace |
case PG_REGISTEREDSUBPROFILE: |
{ | { |
PEGASUS_ASSERT(false); |
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_COMPUTERSYSTEM: |
|
{ |
|
instances.append(getComputerSystemInstance(ref, propertyList)); |
|
break; |
|
} |
|
case PG_HOSTEDOBJECTMANAGER: |
|
{ |
|
instances.append(getHostedObjectManagerInstance(ref, propertyList)); |
|
break; |
|
} |
|
case PG_HOSTEDACCESSPOINT: |
|
{ |
|
instances = enumHostedAccessPointInstances(); |
|
break; |
|
} |
|
default: |
|
PEG_METHOD_EXIT(); |
|
throw CIMNotSupportedException(className.getString() + |
|
" not supported by Interop Provider enumerate"); |
} | } |
| |
handler.deliver(instance); |
// Filter and deliver the resulting instances |
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
// complete processing the request |
{ |
handler.complete(); |
normalizeInstance(instances[i], ref, false, |
|
false, propertyList); |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return ; |
return instances; |
} | } |
| |
//*************************************************************************** | //*************************************************************************** |
// enumerateInstances |
// EnumerateInstances - External Operation call |
|
// Delivers instances back through response handler. |
//*************************************************************************** | //*************************************************************************** |
void InteropProvider::enumerateInstances( | void InteropProvider::enumerateInstances( |
const OperationContext & context, | const OperationContext & context, |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()"); |
| |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
// test for legal namespace for this provider. Exception if not |
"%s enumerateInstances. ref= %s, includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", |
namespaceSupported(ref); |
thisProvider, |
handler.processing(); |
(const char *) ref.toString().getCString(), |
// Call the internal enumerateInstances to generate instances of defined |
(const char *) _showBool(includeQualifiers).getCString(), |
// class. This expects the instances to be returned complete including |
(const char *) _showBool(includeClassOrigin).getCString(), |
// complete path. |
(const char *) _showPropertyList(propertyList).getCString()); |
handler.deliver(localEnumerateInstances(context, ref, propertyList)); |
|
handler.complete(); |
// Verify that ClassName is correct and get value |
PEG_METHOD_EXIT(); |
targetClass classEnum = _verifyValidClassInput(ref.getClassName()); |
|
|
|
// operation namespace needed internally to get class. |
|
_operationNamespace = ref.getNameSpace(); |
|
CDEBUG("Namespace = " << _operationNamespace.getString()); |
|
//String userName = _validateUserID(context); |
|
|
|
// The following 3 classes deliver a single instance because |
|
// that is all there is today. |
|
if (classEnum == CIM_OBJECTMANAGER) |
|
{ |
|
CIMInstance instance = _getInstanceCIMObjectManager(includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
|
|
|
//Array<Sint8> tmp; |
|
///XmlWriter::appendInstanceElement(tmp, instance); |
|
//tmp.append('\0'); |
|
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
// "Instance - XML content: $0", tmp.getData()); |
|
///XmlWriter::printInstanceElement(instance); |
|
handler.deliver(instance); |
|
//handler.complete(); |
|
//PEG_METHOD_EXIT(); |
|
//return; |
|
} | } |
| |
else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
/** Modify the existing object Manager Object. Only a single property modification |
|
is allowed, the statistical data setting. Any other change is rejected |
|
with an exception |
|
@param instanceReference - Reference for the instance to be modified. |
|
@param modifiedIns CIMInstance defining the change. If this includes more than |
|
a single property, the propertyList must specify modification only of the |
|
statisticaldata property. |
|
@includeQualifiers Boolean which must be false unless there are no qualifiers |
|
in the modifiedIns. |
|
@propertyList CIMPropertyList defining the property to be modified if there |
|
is more than one property in the modifiedIns. |
|
@Exceptions CIMInvalidParameterException if the parameters are not valid for |
|
the modification. |
|
*/ |
|
void InteropProvider::modifyObjectManagerInstance( |
|
const OperationContext & context, |
|
const CIMObjectPath & instanceReference, |
|
const CIMInstance& modifiedIns, |
|
const Boolean includeQualifiers, |
|
const CIMPropertyList& propertyList) |
{ | { |
Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(includeQualifiers, |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
includeClassOrigin, propertyList); |
"InteropProvider::modifyObjectManagerInstance"); |
CDEBUG("Build instances of PGCIMXML. count= " << instances.size()); |
|
handler.deliver(instances); |
|
//handler.complete(); |
|
//PEG_METHOD_EXIT(); |
|
//return; |
|
} |
|
| |
else if (classEnum == CIM_NAMESPACEINMANAGER) |
// Modification only allowed when Performance staticistics are active |
|
#ifndef PEGASUS_DISABLE_PERFINST |
|
// the only allowed modification is one property, statistical data |
|
Uint32 propListSize = propertyList.size(); |
|
for(Uint32 i = 0, n = propertyList.size(); i < n; ++i) |
{ | { |
//handler.complete(); |
if(propertyList[0] != OM_GATHERSTATISTICALDATA) |
//PEG_METHOD_EXIT(); |
|
//return; |
|
} |
|
|
|
else if (classEnum == PG_NAMESPACE) |
|
{ | { |
Array<CIMInstance> instances = _getInstancesCIMNamespace(includeQualifiers, |
throw CIMNotSupportedException(String("Only modification of ") + |
includeClassOrigin, propertyList); |
OM_GATHERSTATISTICALDATA.getString() + " allowed"); |
|
|
handler.deliver(instances); |
|
//handler.complete(); |
|
//PEG_METHOD_EXIT(); |
|
//return; |
|
} | } |
else |
|
{ |
|
throw CIMNotSupportedException |
|
("EnumerateInstance for " + ref.getClassName().getString() + " not supported"); |
|
} | } |
| |
handler.complete(); |
/* |
|
Array<CIMName> plA; |
|
plA.append(CIMName(OM_GATHERSTATISTICALDATA)); |
|
CIMPropertyList allowedModifyPropertyList(plA); |
| |
PEG_METHOD_EXIT(); |
// returns only if no exception and there is property to modify. |
|
String errorMessage; |
|
if(!isModifyAllowed(context, instanceReference, modifiedIns, |
|
includeQualifiers, propertyList, allowedModifyPropertyList, |
|
errorMessage)) |
|
{ |
|
if(errorMessage.size() > 0) |
|
{ |
|
throw CIMInvalidParameterException(errorMessage); |
} | } |
|
return; |
|
}*/ |
| |
void InteropProvider::modifyObjectManagerInstance(const OperationContext & context, |
Boolean statisticsFlag; |
const CIMObjectPath & instanceReference, |
CIMInstance myInstance; |
const CIMInstance& modifiedIns, |
|
const Boolean includeQualifiers, |
// We modify only if this property exists. |
const CIMPropertyList& propertyList, |
// could either use the property from modifiedIns or simply replace |
ResponseHandler & handler) |
// value in property from object manager. |
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::modifyInstanceManagerInstance"); |
|
// the only allowed modification is this one property, statistical data |
|
if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) | if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) |
{ | { |
// the following is a temporary hack to set the value of the statistics |
myInstance = getObjectManagerInstance(instanceReference, propertyList); |
// gathering function dynamically. We simply get the value from input |
if(myInstance.isUninitialized()) |
// and call the internal method to set it each time this object is |
{ |
// built. |
throw CIMObjectNotFoundException(instanceReference.toString()); |
#ifndef PEGASUS_DISABLE_PERFINST |
} |
Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); |
statisticsFlag = getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); |
CIMInstance instance; |
// set the changed property into the instance |
instance = _getInstanceCIMObjectManager(true, true, CIMPropertyList()); |
setPropertyValue(myInstance, OM_GATHERSTATISTICALDATA, statisticsFlag); |
|
} |
if (statisticsFlag != _getPropertyValue(instance, OM_GATHERSTATISTICALDATA, false)) |
else |
{ | { |
// set the changed property into the |
// if statistics property not in place, simply exit. Nothing to do |
_setPropertyValue(instance, OM_GATHERSTATISTICALDATA, statisticsFlag); |
// not considered an error |
// Modify the object on disk |
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
// Modify the instance on disk |
try | try |
{ | { |
_repository->modifyInstance(_operationNamespace, |
repository->modifyInstance(instanceReference.getNameSpace(), |
instance ); |
myInstance, false, propertyList); |
} | } |
catch(const CIMException&) | catch(const CIMException&) |
{ | { |
// ATTN: KS generate log error if this not possible |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
catch(const Exception&) | catch(const Exception&) |
{ | { |
// ATTN: Generate log error. |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
|
|
(statisticsFlag? "true" : "false")); | (statisticsFlag? "true" : "false")); |
StatisticalData* sd = StatisticalData::current(); | StatisticalData* sd = StatisticalData::current(); |
sd->setCopyGSD(statisticsFlag); | sd->setCopyGSD(statisticsFlag); |
} |
PEG_METHOD_EXIT(); |
return; | return; |
#endif |
|
| |
} |
#else |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
// ATTN Expand this defintion to be more precise since it allows only mod of |
|
// one property and that property MUST be in the instance to be modifiable. |
|
throw CIMNotSupportedException | throw CIMNotSupportedException |
(OM_GATHERSTATISTICALDATA.getString() + " modify operation not supported by Interop Provider"); |
(OM_GATHERSTATISTICALDATA.getString() + |
|
" modify operation not supported by Interop Provider"); |
|
#endif |
} | } |
//*************************************************************************** | //*************************************************************************** |
|
//*************************************************************************** |
// modifyInstance | // modifyInstance |
//*************************************************************************** | //*************************************************************************** |
|
//*************************************************************************** |
void InteropProvider::modifyInstance(const OperationContext & context, | void InteropProvider::modifyInstance(const OperationContext & context, |
const CIMObjectPath & instanceReference, | const CIMObjectPath & instanceReference, |
const CIMInstance& modifiedIns, | const CIMInstance& modifiedIns, |
|
|
const CIMPropertyList& propertyList, | const CIMPropertyList& propertyList, |
ResponseHandler & handler) | ResponseHandler & handler) |
{ | { |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::modifyInstance"); | "InteropProvider::modifyInstance"); |
| |
|
AutoMutex autoMut(changeControlMutex); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s modifyInstance. instanceReference= %s, includeQualifiers= %s, PropertyList= %s", | "%s modifyInstance. instanceReference= %s, includeQualifiers= %s, PropertyList= %s", |
thisProvider, | thisProvider, |
(const char *) instanceReference.toString().getCString(), | (const char *) instanceReference.toString().getCString(), |
(const char *) _showBool(includeQualifiers).getCString(), |
(const char *) boolToString(includeQualifiers).getCString(), |
(const char *) _showPropertyList(propertyList).getCString()); |
(const char *) propertyListToString(propertyList).getCString()); |
|
|
|
// test for legal namespace for this provider. Exception if not |
|
namespaceSupported(instanceReference); |
| |
// ATTN: KS 31 August 2004. This must test for privileged user. |
|
_operationNamespace = instanceReference.getNameSpace(); |
|
CIMName className = instanceReference.getClassName(); | CIMName className = instanceReference.getClassName(); |
targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName()); |
|
| |
String userName = _validateUserID(context); |
|
// begin processing the request | // begin processing the request |
handler.processing(); | handler.processing(); |
| |
if (classEnum == CIM_OBJECTMANAGER) |
if (className.equal(PEGASUS_CLASSNAME_PG_OBJECTMANAGER)) |
{ | { |
modifyObjectManagerInstance(context, instanceReference,modifiedIns, | modifyObjectManagerInstance(context, instanceReference,modifiedIns, |
includeQualifiers, propertyList, handler); |
includeQualifiers, propertyList); |
// for the moment allow modification of the statistics property only |
|
} |
|
|
|
else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ |
|
|
|
PEG_METHOD_EXIT(); |
|
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
|
} |
|
else if (classEnum == PG_NAMESPACE) |
|
{ |
|
#ifdef PEGASUS_OS_OS400 |
|
MessageLoaderParms mparms("ControlProviders.InteropProvider.MODIFY_INSTANCE_NOT_ALLOWED", |
|
"Modify instance operation not allowed by Interop Provider for class $0.", |
|
PG_NAMESPACE_CLASSNAME.getString()); |
|
throw CIMNotSupportedException(mparms); |
|
#else |
|
// for the moment allow modification of the statistics property only |
|
PEG_METHOD_EXIT(); |
|
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
|
#endif |
|
} | } |
else | else |
{ | { |
PEGASUS_ASSERT(false); // should never get here. |
throw CIMNotSupportedException("Delete instance of class " + |
|
className.getString()); |
} | } |
| |
handler.complete(); | handler.complete(); |
|
|
} | } |
| |
//*************************************************************************** | //*************************************************************************** |
|
//*************************************************************************** |
// enumerateInstanceNames | // enumerateInstanceNames |
//*************************************************************************** | //*************************************************************************** |
|
//*************************************************************************** |
|
|
void InteropProvider::enumerateInstanceNames( | void InteropProvider::enumerateInstanceNames( |
const OperationContext & context, | const OperationContext & context, |
const CIMObjectPath & classReference, | const CIMObjectPath & classReference, |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::enumerateInstanceNames()"); | "InteropProvider::enumerateInstanceNames()"); |
| |
// operation namespace needed internally to get class. |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
_operationNamespace = classReference.getNameSpace(); |
"%s enumerateInstanceNames. classReference= %s", |
|
thisProvider, |
targetClass classEnum = _verifyValidClassInput(classReference.getClassName()); |
(const char *) classReference.toString().getCString()); |
| |
String userName = _validateUserID(context); |
// test for legal namespace for this provider. Exception if not |
|
// namespaceSupported(classReference); |
|
// NOTE: Above is commented out because the routing tables will always |
|
// do the right thing and that's the only way requests get here. |
| |
// begin processing the request | // begin processing the request |
handler.processing(); | handler.processing(); |
| |
// Deliver a single instance because there should only be one instance. |
Array<CIMInstance> instances = localEnumerateInstances( |
if (classEnum == CIM_OBJECTMANAGER) |
context, |
{ |
classReference, |
CIMInstance instance = _getInstanceCIMObjectManager( true, true, CIMPropertyList()); |
CIMPropertyList()); |
CIMObjectPath ref = _buildInstancePath(_operationNamespace, |
|
CIM_OBJECTMANAGER_CLASSNAME, instance); |
|
handler.deliver(ref); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
|
|
// Deliver all possible instances of this class |
|
if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ |
|
Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(true, |
|
true, CIMPropertyList()); |
|
|
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
|
{ |
|
CIMObjectPath ref = _buildInstancePath(_operationNamespace, |
|
PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
|
|
if (classEnum == CIM_NAMESPACEINMANAGER) |
|
{ |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
| |
if (classEnum == PG_NAMESPACE) |
|
{ |
|
Array<CIMInstance> instances = _getInstancesCIMNamespace(false, |
|
false, CIMPropertyList()); |
|
CDEBUG("EvalNames. Found instances. Count= " << instances.size()); |
|
for (Uint32 i = 0 ; i < instances.size() ; i++) | for (Uint32 i = 0 ; i < instances.size() ; i++) |
{ | { |
CIMObjectPath ref = _buildInstancePath(_operationNamespace, |
handler.deliver(instances[i].getPath()); |
CIM_NAMESPACE_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} | } |
| |
handler.complete(); | handler.complete(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return; |
|
} |
|
|
|
if (classEnum == CIM_COMMMECHANISMFORMANAGERINST) |
|
{ |
|
Array<CIMInstance> instances = _buildInstancesCommMechanismForManager(); |
|
for (Uint32 i = 0 ; i < instances.size() ; i++ ) |
|
{ |
|
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
|
CIM_COMMMECHANISMFORMANAGER_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} |
|
} |
|
|
|
if (classEnum == CIM_NAMESPACEINMANAGERINST) |
|
{ |
|
Array<CIMInstance> instances = _buildInstancesNamespaceInManager(); |
|
for (Uint32 i = 0 ; i < instances.size() ; i++ ) |
|
{ |
|
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
|
CIM_NAMESPACEINMANAGER_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} |
|
} |
|
|
|
|
|
// ATTN: Exception response because of error |
|
PEG_METHOD_EXIT(); |
|
} | } |
| |
//************************************************************** | //************************************************************** |
//************************************************************** | //************************************************************** |
// Association Functions |
// Associators Operation Call |
//************************************************************** | //************************************************************** |
//************************************************************** | //************************************************************** |
| |
|
|
ObjectResponseHandler & handler) | ObjectResponseHandler & handler) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::associatorNames()"); |
"InteropProvider::associators()"); |
//throw CIMNotSupportedException("AssociationProvider::associators"); |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"%s associators. objectName= %s , assocClass= %s resultClass= %s role= %s resultRole %includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", |
|
thisProvider, |
|
(const char *)objectName.toString().getCString(), |
|
(const char *)associationClass.getString().getCString(), |
|
(const char *)resultClass.getString().getCString(), |
|
(const char *)role.getCString(), |
|
(const char *)resultRole.getCString(), |
|
(const char *)boolToString(includeQualifiers).getCString(), |
|
(const char *) boolToString(includeClassOrigin).getCString(), |
|
(const char *)propertyListToString(propertyList).getCString()); |
|
|
|
handler.processing(); |
|
String originRole = role; |
|
String targetRole = resultRole; |
|
Array<CIMInstance> refs = localReferences(context, objectName, |
|
associationClass, originRole, CIMPropertyList(), resultClass, |
|
targetRole); |
|
for(Uint32 i = 0, n = refs.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentRef = refs[i]; |
|
CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>( |
|
currentRef, targetRole); |
|
CIMInstance tmpInstance = localGetInstance(context, currentTarget, |
|
propertyList); |
|
tmpInstance.setPath(currentTarget); |
|
handler.deliver(tmpInstance); |
|
} |
|
handler.complete(); |
|
|
|
PEG_METHOD_EXIT(); |
} | } |
| |
|
//************************************************************** |
|
//************************************************************** |
|
// AssociatorNames Operation Function |
|
//************************************************************** |
|
//************************************************************** |
void InteropProvider::associatorNames( | void InteropProvider::associatorNames( |
const OperationContext & context, | const OperationContext & context, |
const CIMObjectPath & objectName, | const CIMObjectPath & objectName, |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::associatorNames()"); | "InteropProvider::associatorNames()"); |
//throw CIMNotSupportedException("AssociationProvider::associatorNames"); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"%s associatorNames. objectName= %s , assocClass= %s resultClass= %s role= %s resultRole", |
|
thisProvider, |
|
(const char *)objectName.toString().getCString(), |
|
(const char *)associationClass.getString().getCString(), |
|
(const char *)resultClass.getString().getCString(), |
|
(const char *)role.getCString(), |
|
(const char *)resultRole.getCString()); |
|
|
|
handler.processing(); |
|
String originRole = role; |
|
String targetRole = resultRole; |
|
Array<CIMInstance> refs = localReferences(context, objectName, |
|
associationClass, originRole, CIMPropertyList(), resultClass, |
|
targetRole); |
|
for(Uint32 i = 0, n = refs.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentRef = refs[i]; |
|
CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>( |
|
currentRef, targetRole); |
|
handler.deliver(currentTarget); |
|
} |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
} | } |
| |
|
|
void InteropProvider::references( | void InteropProvider::references( |
const OperationContext & context, | const OperationContext & context, |
const CIMObjectPath & objectName, | const CIMObjectPath & objectName, |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::references()"); | "InteropProvider::references()"); |
//throw CIMNotSupportedException("AssociationProvider::references"); |
|
} |
|
| |
void _filterAssocInstances(Array<CIMInstance>& instances, |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
CIMName assocClassName, |
"%s references. objectName= %s , resultClass= %s role= %s includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", |
String assocRole, |
thisProvider, |
CIMName resultClassName = CIMName(), |
(const char *)objectName.toString().getCString(), |
String resultRole = String::EMPTY) |
(const char *)resultClass.getString().getCString(), |
{ |
(const char *)role.getCString(), |
return; |
(const char *)boolToString(includeQualifiers).getCString(), |
} |
(const char*) boolToString(includeClassOrigin).getCString(), |
|
(const char *)propertyListToString(propertyList).getCString()); |
| |
|
handler.processing(); |
|
String tmpRole = role; |
|
Array<CIMInstance> refs = |
|
localReferences(context, objectName, resultClass, tmpRole); |
|
for(Uint32 i = 0, n = refs.size(); i < n; ++i) |
|
handler.deliver((CIMObject)refs[i]); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
} |
void InteropProvider::referenceNames( | void InteropProvider::referenceNames( |
const OperationContext & context, | const OperationContext & context, |
const CIMObjectPath & objectName, | const CIMObjectPath & objectName, |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::referenceNames()"); | "InteropProvider::referenceNames()"); |
CDEBUG("::referenceNames(): object= " << objectName.toString() << " result Class= " << resultClass.getString()); |
|
| |
// operation namespace needed internally to get class. |
|
_operationNamespace = objectName.getNameSpace(); |
|
String userName = _validateUserID(context); |
|
// begin processing the request |
|
handler.processing(); | handler.processing(); |
| |
// determine if valid class result class |
String tmpRole = role; |
|
Array<CIMInstance> refs = |
|
localReferences(context, objectName, resultClass, tmpRole); |
|
for(Uint32 i = 0, n = refs.size(); i < n; ++i) |
|
{ |
|
handler.deliver(refs[i].getPath()); |
|
} |
| |
CIMName targetAssocClassName = resultClass; |
handler.complete(); |
| |
CIMName targetClassName = objectName.getClassName(); |
PEG_METHOD_EXIT(); |
|
} |
| |
targetAssocClass classEnum = _verifyValidAssocClassInput(targetAssocClassName); |
bool validAssocClassForObject( |
|
const CIMName & assocClass, const CIMName & originClass, |
|
String & originProperty, String & targetProperty) |
|
{ |
|
TARGET_CLASS assocClassEnum = translateClassInput(assocClass); |
|
TARGET_CLASS originClassEnum; |
|
if(assocClassEnum != PG_ELEMENTCONFORMSTOPROFILE) |
|
{ |
|
originClassEnum = translateClassInput(originClass); |
|
} |
| |
Array<CIMInstance> assocInstances; |
CIMName expectedTargetRole; |
|
CIMName expectedOriginRole; |
| |
if (classEnum == CIM_COMMMECHANISMFORMANAGERASSOC) |
switch(assocClassEnum) |
assocInstances = _buildInstancesCommMechanismForManager(); |
{ |
|
case PG_NAMESPACEINMANAGER: |
|
if(originClassEnum == PG_OBJECTMANAGER) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_NAMESPACE) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
break; |
|
case PG_COMMMECHANISMFORMANAGER: |
|
if(originClassEnum == PG_OBJECTMANAGER) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
break; |
|
case PG_ELEMENTCONFORMSTOPROFILE: |
|
if(originClass.equal(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE)) |
|
{ |
|
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
|
} |
|
else |
|
{ |
|
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
|
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
} |
|
break; |
|
case PG_SUBPROFILEREQUIRESPROFILE: |
|
if(originClassEnum == PG_REGISTEREDPROFILE) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_REGISTEREDSUBPROFILE) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
break; |
|
case PG_ELEMENTSOFTWAREIDENTITY: |
|
if(originClassEnum == PG_SOFTWAREIDENTITY) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_REGISTEREDPROFILE || |
|
originClassEnum == PG_REGISTEREDSUBPROFILE) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
break; |
|
case PG_HOSTEDACCESSPOINT: |
|
if(originClassEnum == PG_COMPUTERSYSTEM) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
case PG_HOSTEDOBJECTMANAGER: |
|
if(originClassEnum == PG_COMPUTERSYSTEM) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
|
} |
|
else if(originClassEnum == PG_OBJECTMANAGER) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
break; |
|
default: |
|
break; |
|
} |
| |
if (classEnum == CIM_NAMESPACEINMANAGERASSOC) |
if(expectedTargetRole.isNull() || |
assocInstances = _buildInstancesNamespaceInManager(); |
expectedOriginRole.isNull()) |
|
{ |
|
return false; |
|
} |
| |
_filterAssocInstances(assocInstances, resultClass, role); |
if(targetProperty.size() == 0) |
|
{ |
|
targetProperty = expectedTargetRole.getString(); |
|
} |
|
else if(!expectedTargetRole.equal(targetProperty)) |
|
{ |
|
return false; |
|
} |
| |
for (Uint32 i = 0 ; i < assocInstances.size() ; i++ ) |
if(originProperty.size() == 0) |
|
{ |
|
originProperty = expectedOriginRole.getString(); |
|
} |
|
else if(!expectedOriginRole.equal(originProperty)) |
{ | { |
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
return false; |
targetAssocClassName, assocInstances[i]); |
} |
CDEBUG("referenceNames returns: " << ref.toString()); |
return true; |
handler.deliver(ref); |
|
} | } |
| |
handler.complete(); |
Array<CIMInstance> InteropProvider::localReferences( |
|
const OperationContext & context, |
|
const CIMObjectPath & objectName, |
|
const CIMName & assocClass, |
|
String & originProperty, |
|
const CIMPropertyList & propertyList, |
|
const CIMName & targetClass, |
|
String & targetProperty) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::localReferences()"); |
| |
PEG_METHOD_EXIT(); |
Array<CIMInstance> instances; |
// Convert the instances to referenceNames response |
CIMName originClass = objectName.getClassName(); |
|
|
|
Array<CIMName> targetSubclasses; |
|
CIMNamespaceName originNamespace(objectName.getNameSpace()); |
|
if(!targetClass.isNull()) |
|
{ |
|
targetSubclasses = repository->enumerateClassNames( |
|
originNamespace, targetClass, true); |
|
} |
|
|
|
if(validAssocClassForObject(assocClass, objectName.getClassName(), |
|
originProperty, targetProperty)) |
|
{ |
|
Array<CIMInstance> localInstances = localEnumerateInstances(context, |
|
CIMObjectPath(hostName, PEGASUS_NAMESPACENAME_INTEROP, |
|
assocClass)); |
|
for(Uint32 i = 0, n = localInstances.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentInstance = localInstances[i]; |
|
//std::cout << "OriginProperty: " << (const char *)originProperty.getCString() << std::endl; |
|
//std::cout << "ObjectName: " << (const char *)objectName.toString().getCString() << std::endl; |
|
//std::cout << "Reference Name: " << (const char *)currentInstance.getPath().toString().getCString() << std::endl; |
|
CIMObjectPath originPath = getRequiredValue<CIMObjectPath>( |
|
currentInstance, originProperty); |
|
originPath.setNameSpace(objectName.getNameSpace()); |
|
originPath.setHost(objectName.getHost()); |
|
if(originPath.identical(objectName)) |
|
{ |
|
if(!targetClass.isNull()) |
|
{ |
|
// Have to check if the target reference is of the |
|
// targetClass type. We first must determine all the |
|
// possible subclasses of the targetClass in the target |
|
// namespace. |
|
CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>( |
|
currentInstance, targetProperty); |
|
Array<CIMName> searchClasses; |
|
CIMNamespaceName targetNamespace( |
|
targetPath.getNameSpace()); |
|
if(targetNamespace.isNull()) |
|
{ |
|
targetNamespace = originNamespace; |
|
searchClasses = targetSubclasses; |
|
} |
|
else if(targetNamespace == originNamespace) |
|
{ |
|
searchClasses = targetSubclasses; |
|
} |
|
else |
|
{ |
|
searchClasses = repository->enumerateClassNames( |
|
targetNamespace, targetClass, true); |
|
} |
|
|
|
// Try to find the targetPath's class in the search space |
|
CIMName targetPathClass = targetPath.getClassName(); |
|
for(Uint32 j = 0, m = searchClasses.size(); j < m; ++j) |
|
{ |
|
if(targetPathClass == searchClasses[j]) |
|
{ |
|
instances.append(currentInstance); |
|
break; |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
instances.append(currentInstance); |
|
} |
|
} |
|
} |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
return instances; |
|
} |
|
|
|
|
|
CIMInstance InteropProvider::buildRegisteredProfile( |
|
const String & instanceId, |
|
const String & profileName, |
|
const String & profileVersion, |
|
Uint16 profileOrganization, |
|
const String & otherProfileOrganization, |
|
const CIMClass & profileClass) |
|
{ |
|
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 this instance is a PG_RegisteredProfile and if SLP is |
|
// enabled in the configuration. If so, specify SLP as the advertise type. |
|
Array<Uint16> advertiseTypes; |
|
if(profileClass.getClassName() == PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE) |
|
{ |
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
if (String::equal(configManager->getCurrentValue("slp"), "true")) |
|
{ |
|
advertiseTypes.append(3); // Advertised via SLP |
|
} |
|
else |
|
{ |
|
advertiseTypes.append(2); // Not advertised |
|
} |
|
} |
|
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; |
|
} |
|
|
|
String translateValue(const String & value, const CIMName & propName, |
|
const CIMName & sourceQualifier, |
|
const CIMName & targetQualifier, |
|
const CIMClass & classDef) |
|
{ |
|
String mappedValue(String::EMPTY); |
|
Uint32 index = classDef.findProperty(propName); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
CIMConstProperty prop = classDef.getProperty(index); |
|
index = prop.findQualifier(sourceQualifier); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
Array<String> valueMapQual; |
|
prop.getQualifier(index).getValue().get(valueMapQual); |
|
for(Uint32 i = 0, n = valueMapQual.size(); i < n; ++i) |
|
{ |
|
// If we have a match in the ValueMap qualifier, then get the |
|
// related string from the Values qualifier |
|
if(valueMapQual[i] == value) |
|
{ |
|
index = prop.findQualifier(targetQualifier); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
Array<String> valuesQual; |
|
prop.getQualifier(index).getValue().get( |
|
valuesQual); |
|
mappedValue = valuesQual[i]; |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
return mappedValue; |
|
} |
|
|
|
inline String translateValue(Uint16 value, const CIMName & propName, |
|
const CIMName & sourceQualifier, const CIMName & targetQualifier, |
|
const CIMClass & classDef) |
|
{ |
|
return translateValue(CIMValue(value).toString(), propName, |
|
sourceQualifier, targetQualifier, classDef); |
|
} |
|
|
|
inline String buildProfileInstanceId(const String & organization, |
|
const String & name, |
|
const String & version) |
|
{ |
|
return organization + "+" + name + "+" + version; |
|
} |
|
|
|
String extractProfileInfo(const CIMInstance & profileCapabilities, |
|
const CIMClass & capabilitiesClass, |
|
const CIMClass & profileClass, |
|
String & name, |
|
String & version, |
|
Uint16 & organization, |
|
String & otherOrganization, |
|
String & organizationName, |
|
Array<String> & subprofileNames = Array<String>(), |
|
bool noSubProfileInfo = true) |
|
{ |
|
Uint16 registeredProfile = getRequiredValue<Uint16>(profileCapabilities, |
|
PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE); |
|
|
|
if(registeredProfile == 0) // Other |
|
{ |
|
name = getRequiredValue<String>(profileCapabilities, |
|
PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDPROFILE); |
|
organizationName = getRequiredValue<String>(profileCapabilities, |
|
PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDORGANIZATION); |
|
} |
|
else |
|
{ |
|
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); |
|
|
|
if(!noSubProfileInfo) |
|
{ |
|
Array<Uint16> registeredSubprofiles = |
|
getRequiredValue<Array<Uint16> >(profileCapabilities, |
|
PROFILECAPABILITIES_PROPERTY_REGISTEREDSUBPROFILES); |
|
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(); |
|
} |
|
otherSubprofileIndex = 0; |
|
|
|
for(Uint32 k = 0, x = registeredSubprofiles.size(); k < x; ++k) |
|
{ |
|
Uint16 subprofileMapping = registeredSubprofiles[k]; |
|
String subprofileName; |
|
if(subprofileMapping == 0) // "Other" |
|
{ |
|
if(otherSubprofileIndex == numOtherSubprofiles) |
|
{ |
|
throw CIMOperationFailedException( |
|
profileCapabilities.getPath().toString() + |
|
" does not contain enough entries in property " + |
|
PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDSUBPROFILES |
|
.getString()); |
|
} |
|
subprofileName = |
|
otherRegisteredSubprofiles[otherSubprofileIndex++]; |
|
} |
|
else |
|
{ |
|
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) |
|
subprofileName = subprofileName.subString(orgIndex+1); |
|
} |
|
|
|
subprofileNames.append(subprofileName); |
|
} |
|
} |
|
|
|
String organizationMapping = translateValue(organizationName, |
|
REGISTEREDPROFILE_PROPERTY_REGISTEREDORGANIZATION, |
|
VALUES_QUALIFIERNAME, VALUEMAP_QUALIFIERNAME, profileClass); |
|
if(organizationMapping.size() == 0) |
|
{ |
|
organization = 1; |
|
otherOrganization = organizationName; |
|
} |
|
else |
|
{ |
|
organization = atoi((const char *)organizationMapping.getCString()); |
|
if(organization == 1) |
|
otherOrganization = organizationName; |
|
} |
|
|
|
return buildProfileInstanceId(organizationName, name, version); |
|
} |
|
|
|
CIMInstance InteropProvider::buildDependencyInstance( |
|
const String & antecedentId, |
|
const CIMName & antecedentClass, |
|
const String & dependentId, |
|
const CIMName & dependentClass, |
|
const CIMClass & depClass) |
|
{ |
|
Array<CIMKeyBinding> antecedentKeys; |
|
Array<CIMKeyBinding> dependentKeys; |
|
|
|
antecedentKeys.append(CIMKeyBinding( |
|
REGISTEREDPROFILE_PROPERTY_INSTANCEID, |
|
antecedentId,CIMKeyBinding::STRING)); |
|
|
|
dependentKeys.append(CIMKeyBinding( |
|
REGISTEREDPROFILE_PROPERTY_INSTANCEID, |
|
dependentId,CIMKeyBinding::STRING)); |
|
|
|
CIMInstance dependencyInst = depClass.buildInstance(false, false, |
|
CIMPropertyList()); |
|
setPropertyValue(dependencyInst, PROPERTY_ANTECEDENT, |
|
CIMValue(CIMObjectPath(hostName, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
antecedentClass, |
|
antecedentKeys))); |
|
setPropertyValue(dependencyInst, PROPERTY_DEPENDENT, |
|
CIMValue(CIMObjectPath(hostName, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
dependentClass, |
|
dependentKeys))); |
|
dependencyInst.setPath(dependencyInst.buildPath(depClass)); |
|
return dependencyInst; |
|
} |
|
|
|
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->enumerateInstances( |
|
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); |
|
} |
|
|
|
Uint32 i = 0; |
|
Uint32 n = profileCapabilities.size(); |
|
for(; i < n; ++i) |
|
{ |
|
// Extract the useful properties |
|
String profileName; |
|
Uint16 profileOrganization = 0; |
|
String otherOrganization; |
|
String profileVersion; |
|
String organizationName; |
|
bool justRegisteredProfileInfo = profileType.equal( |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); |
|
CIMInstance & currentCapabilities = profileCapabilities[i]; |
|
Array<String> profileNames; |
|
String profileId = extractProfileInfo(currentCapabilities, |
|
profileCapabilitiesClass, registeredProfileClass, profileName, |
|
profileVersion, profileOrganization, otherOrganization, |
|
organizationName, profileNames, justRegisteredProfileInfo); |
|
Array<String> tmpInstanceIds; |
|
|
|
|
|
if(justRegisteredProfileInfo) |
|
{ |
|
tmpInstanceIds.append(profileId); |
|
profileNames.append(profileName); |
|
} |
|
else |
|
{ |
|
for(Uint32 j = 0, m = profileNames.size(); j < m; ++j) |
|
{ |
|
tmpInstanceIds.append(buildProfileInstanceId(organizationName, |
|
profileNames[j], profileVersion)); |
|
} |
|
} |
|
|
|
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 |
|
{ |
|
instances.append(buildRegisteredProfile(tmpId, |
|
profileNames[j], profileVersion, profileOrganization, |
|
otherOrganization, registeredProfileClass)); |
|
} |
|
instanceIDs.append(tmpId); |
|
} |
|
} |
|
} |
|
|
|
if(isRequiresProfileOperation) |
|
{ |
|
String serverProfileId = buildProfileInstanceId( |
|
SNIA_NAME, "Server", SNIA_VER_110); |
|
String indicationSubprofileId = buildProfileInstanceId( |
|
SNIA_NAME, "Indication", SNIA_VER_110); |
|
String compoundId = serverProfileId + ":" + indicationSubprofileId; |
|
bool unique = true; |
|
for(Uint32 k = 0, x = instanceIDs.size(); k < x; ++k) |
|
{ |
|
if(instanceIDs[k] == compoundId) |
|
{ |
|
unique = false; |
|
break; |
|
} |
|
} |
|
|
|
if(unique) |
|
{ |
|
instances.append(buildDependencyInstance( |
|
serverProfileId, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
indicationSubprofileId, PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE, |
|
subprofileReqProfileClass)); |
|
} |
|
} |
|
else |
|
{ |
|
for(i = 0, n = defaultSniaProfiles.size(); i < n; ++i) |
|
{ |
|
// We always have the Indication Subprofile |
|
const String & currentProfile = defaultSniaProfiles[i]; |
|
String instanceId = buildProfileInstanceId(SNIA_NAME, |
|
defaultSniaProfiles[i], SNIA_VER_110); |
|
bool defaultProfileUnique = true; |
|
for(Uint32 j = 0, m = instanceIDs.size(); j < m; ++j) |
|
{ |
|
if(instanceIDs[j] == instanceId) |
|
{ |
|
defaultProfileUnique = false; |
|
break; |
|
} |
|
} |
|
|
|
if(defaultProfileUnique) |
|
{ |
|
instances.append(buildRegisteredProfile(instanceId, |
|
currentProfile, SNIA_VER_110, 11 /*"SNIA"*/, String::EMPTY, |
|
registeredProfileClass)); |
|
instanceIDs.append(instanceId); |
|
} |
|
} |
|
} |
|
|
|
return instances; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumRegisteredProfileInstances() |
|
{ |
|
static String serverProfileName("Server"); |
|
Array<String> defaultSubprofiles; |
|
defaultSubprofiles.append(serverProfileName); |
|
|
|
return getProfileInstances(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
defaultSubprofiles); |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumRegisteredSubProfileInstances() |
|
{ |
|
static String indicationProfileName("Indication"); |
|
Array<String> defaultSubprofiles; |
|
defaultSubprofiles.append(indicationProfileName); |
|
return getProfileInstances(PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE, |
|
defaultSubprofiles); |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumSubProfileRequiresProfileInstances() |
|
{ |
|
return getProfileInstances(PEGASUS_CLASSNAME_PG_SUBPROFILEREQUIRESPROFILE, |
|
Array<String>()); |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumReferencedProfileInstances() |
|
{ |
|
Array<CIMInstance> instances; |
|
|
|
// We have to collect all the Registered Profiles and Subprofiles in |
|
// separate lists since the ProviderReferencedProfile instance does not |
|
// have information telling us whether its entries are subprofiles or |
|
// profiles. |
|
Array<String> allRegisteredProfileIds; |
|
Array<String> allSubprofileIds; |
|
Array<CIMInstance> allRegisteredProfiles = enumRegisteredProfileInstances(); |
|
Array<CIMInstance> allSubprofiles = enumRegisteredSubProfileInstances(); |
|
Uint32 i = 0; |
|
Uint32 n = allRegisteredProfiles.size(); |
|
for(; i < n; ++i) |
|
{ |
|
allRegisteredProfileIds.append(getRequiredValue<String>( |
|
allRegisteredProfiles[i], REGISTEREDPROFILE_PROPERTY_INSTANCEID)); |
|
} |
|
|
|
for(i = 0, n = allSubprofiles.size(); i < n; ++i) |
|
{ |
|
allSubprofileIds.append(getRequiredValue<String>( |
|
allSubprofiles[i], REGISTEREDPROFILE_PROPERTY_INSTANCEID)); |
|
} |
|
|
|
|
|
Array<CIMInstance> referencedProfiles = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_PROVIDERREFERENCEDPROFILES); |
|
|
|
CIMClass providerRefProfileClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_PROVIDERREFERENCEDPROFILES, |
|
false, true, false); |
|
CIMClass referencedProfileClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE, |
|
false, true, false); |
|
|
|
Array<String> instanceIds; |
|
for(i = 0, n = referencedProfiles.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentReferencedProfile = referencedProfiles[i]; |
|
Array<Uint16> registeredProfiles = getRequiredValue<Array<Uint16> >( |
|
currentReferencedProfile, |
|
REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILES); |
|
Array<Uint16> dependentProfiles = getRequiredValue<Array<Uint16> >( |
|
currentReferencedProfile, |
|
REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILES); |
|
Array<String> profileVersions = getRequiredValue<Array<String> >( |
|
currentReferencedProfile, |
|
REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILEVERSIONS); |
|
Array<String> dependentVersions = getRequiredValue<Array<String> >( |
|
currentReferencedProfile, |
|
REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILEVERSIONS); |
|
|
|
Uint32 m = registeredProfiles.size(); |
|
if(m != dependentProfiles.size() || m != profileVersions.size() || |
|
m != dependentVersions.size()) |
|
{ |
|
throw CIMOperationFailedException( |
|
currentReferencedProfile.getPath().toString() + |
|
" mismatch in num values between corresponding properties"); |
|
} |
|
|
|
Uint32 otherProfilesIndex = 0; |
|
Uint32 otherDependentsIndex = 0; |
|
Uint32 numOtherProfiles = 0; |
|
Uint32 numOtherDependents = 0; |
|
Array<String> otherProfiles; |
|
Array<String> otherDependentProfiles; |
|
Array<String> otherProfileOrganizations; |
|
Array<String> otherDependentOrganizations; |
|
Uint32 index = currentReferencedProfile.findProperty( |
|
REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILES); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
currentReferencedProfile.getProperty(index).getValue().get( |
|
otherProfiles); |
|
numOtherProfiles = otherProfiles.size(); |
|
} |
|
|
|
index = currentReferencedProfile.findProperty( |
|
REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILES); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
currentReferencedProfile.getProperty(index).getValue().get( |
|
otherDependentProfiles); |
|
numOtherDependents = otherDependentProfiles.size(); |
|
} |
|
|
|
index = currentReferencedProfile.findProperty( |
|
REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILEORGANIZATIONS); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
currentReferencedProfile.getProperty(index).getValue().get( |
|
otherProfileOrganizations); |
|
} |
|
|
|
index = currentReferencedProfile.findProperty( |
|
REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILEORGANIZATIONS); |
|
if(index != PEG_NOT_FOUND) |
|
{ |
|
currentReferencedProfile.getProperty(index).getValue().get( |
|
otherDependentOrganizations); |
|
} |
|
|
|
if(otherDependentOrganizations.size() != numOtherDependents || |
|
otherProfileOrganizations.size() != numOtherProfiles) |
|
{ |
|
throw CIMOperationFailedException( |
|
currentReferencedProfile.getPath().toString() + |
|
" mismatch in num values between corresponding properties"); |
|
} |
|
|
|
for(Uint32 j = 0; j < m; ++j) |
|
{ |
|
Uint16 currentProfile = registeredProfiles[j]; |
|
Uint16 currentDependent = dependentProfiles[j]; |
|
String profileName; |
|
String dependentName; |
|
String profileOrgName; |
|
String dependentOrgName; |
|
if(currentProfile == 1) // Other |
|
{ |
|
if(otherProfilesIndex == numOtherProfiles) |
|
{ |
|
throw CIMOperationFailedException( |
|
currentReferencedProfile.getPath().toString() + |
|
" not enough entries in property " + |
|
REFERENCEDPROFILES_PROPERTY_OTHERREGISTEREDPROFILES. |
|
getString()); |
|
} |
|
|
|
profileName = otherProfiles[otherProfilesIndex]; |
|
profileOrgName = otherProfileOrganizations[otherProfilesIndex++]; |
|
} |
|
else |
|
{ |
|
/* |
|
translateValue(const String & value, const CIMName & propName, |
|
const CIMName & sourceQualifier, |
|
const CIMName & targetQualifier, |
|
const CIMClass & classDef) |
|
*/ |
|
profileName = translateValue(currentProfile, |
|
REFERENCEDPROFILES_PROPERTY_REGISTEREDPROFILES, |
|
VALUEMAP_QUALIFIERNAME, VALUES_QUALIFIERNAME, |
|
providerRefProfileClass); |
|
Uint32 index = profileName.find(Char16(':')); |
|
PEGASUS_ASSERT(index != PEG_NOT_FOUND); |
|
profileOrgName = profileName.subString(0, index); |
|
profileName = profileName.subString(index+1); |
|
} |
|
|
|
if(currentDependent == 1) // Other |
|
{ |
|
if(otherDependentsIndex == numOtherDependents) |
|
{ |
|
throw CIMOperationFailedException( |
|
currentReferencedProfile.getPath().toString() + |
|
" not enough entries in property " + |
|
REFERENCEDPROFILES_PROPERTY_OTHERDEPENDENTPROFILES. |
|
getString()); |
|
} |
|
|
|
dependentName = otherDependentProfiles[otherProfilesIndex]; |
|
dependentOrgName = otherDependentOrganizations[otherProfilesIndex++]; |
|
} |
|
else |
|
{ |
|
dependentName = translateValue(currentProfile, |
|
REFERENCEDPROFILES_PROPERTY_DEPENDENTPROFILES, |
|
VALUEMAP_QUALIFIERNAME, VALUES_QUALIFIERNAME, |
|
providerRefProfileClass); |
|
Uint32 index = dependentName.find(Char16(':')); |
|
PEGASUS_ASSERT(index != PEG_NOT_FOUND); |
|
dependentOrgName = dependentName.subString(0, index); |
|
dependentName = dependentName.subString(index+1); |
|
} |
|
|
|
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) |
|
{ |
|
// Now find out whether it is a Profile or Subprofile |
|
const CIMName * profileType = 0; |
|
const CIMName * dependentType = 0; |
|
for(Uint32 k = 0, x = allRegisteredProfileIds.size(); |
|
k < x; ++k) |
|
{ |
|
if(allRegisteredProfileIds[k] == profileId) |
|
{ |
|
profileType = |
|
&PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE; |
|
if(dependentType != 0) |
|
break; |
|
} |
|
else if(allRegisteredProfileIds[k] == dependentId) |
|
{ |
|
dependentType = |
|
&PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE; |
|
if(profileType != 0) |
|
break; |
|
} |
|
} |
|
|
|
instanceIds.append(instanceId); |
|
if(profileType == 0) |
|
profileType = &PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE; |
|
if(dependentType == 0) |
|
dependentType = &PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE; |
|
instances.append(buildDependencyInstance(profileId, |
|
*profileType, dependentId, *dependentType, |
|
referencedProfileClass)); |
|
} |
|
} |
|
} |
|
return instances; |
|
} |
|
|
|
Array<String> findProviderNamespacesForElement( |
|
const String & moduleName, const String & providerName, |
|
const CIMName & elementClass, CIMRepository * repository, |
|
Array<CIMInstance> & providerCapabilitiesInstances) |
|
{ |
|
Array<CIMInstance> capabilities; |
|
if(providerCapabilitiesInstances.size() == 0) |
|
{ |
|
Array<CIMName> propList; |
|
propList.append(PROVIDERCAPABILITIES_PROPERTY_PROVIDERMODULENAME); |
|
propList.append(PROVIDERCAPABILITIES_PROPERTY_PROVIDERNAME); |
|
propList.append(PROVIDERCAPABILITIES_PROPERTY_NAMESPACES); |
|
propList.append(PROVIDERCAPABILITIES_PROPERTY_CLASSNAME); |
|
capabilities = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PROVIDERCAPABILITIES, true, true, false, false); |
|
} |
|
else |
|
{ |
|
capabilities = providerCapabilitiesInstances; |
|
} |
|
|
|
for(Uint32 i = 0, n = capabilities.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentCapabilities = capabilities[i]; |
|
Uint32 propIndex = currentCapabilities.findProperty( |
|
PROVIDERCAPABILITIES_PROPERTY_PROVIDERMODULENAME); |
|
PEGASUS_ASSERT(propIndex != PEG_NOT_FOUND); |
|
String currentName; |
|
currentCapabilities.getProperty(propIndex).getValue().get( |
|
currentName); |
|
if(currentName == moduleName) |
|
{ |
|
propIndex = currentCapabilities.findProperty( |
|
PROVIDERCAPABILITIES_PROPERTY_PROVIDERNAME); |
|
PEGASUS_ASSERT(propIndex != PEG_NOT_FOUND); |
|
currentCapabilities.getProperty(propIndex).getValue().get( |
|
currentName); |
|
if(currentName == providerName) |
|
{ |
|
propIndex = currentCapabilities.findProperty( |
|
PROVIDERCAPABILITIES_PROPERTY_CLASSNAME); |
|
PEGASUS_ASSERT(propIndex != PEG_NOT_FOUND); |
|
currentCapabilities.getProperty(propIndex).getValue().get( |
|
currentName); |
|
if(elementClass.equal(CIMName(currentName))) |
|
{ |
|
propIndex = currentCapabilities.findProperty( |
|
PROVIDERCAPABILITIES_PROPERTY_NAMESPACES); |
|
PEGASUS_ASSERT(propIndex != PEG_NOT_FOUND); |
|
Array<String> namespaces; |
|
currentCapabilities.getProperty(propIndex).getValue().get( |
|
namespaces); |
|
return namespaces; |
|
} |
|
} |
|
} |
|
} |
|
|
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, |
|
"Could not find provider capabilities registered for module " + |
|
moduleName + ", provider " + providerName + ", and class " + |
|
elementClass.getString()); |
|
} |
|
|
|
CIMInstance buildElementConformsToProfile( |
|
const CIMObjectPath & currentProfile, |
|
const CIMObjectPath & currentElement, |
|
const CIMClass & elementConformsClass) |
|
{ |
|
Array<CIMName> elementPropArray; |
|
elementPropArray.append( |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD); |
|
elementPropArray.append( |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT); |
|
CIMPropertyList elementPropList(elementPropArray); |
|
|
|
CIMInstance tmpInstance = |
|
elementConformsClass.buildInstance(false, false, |
|
elementPropList); |
|
setPropertyValue(tmpInstance, |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD, |
|
currentProfile); |
|
setPropertyValue(tmpInstance, |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT, |
|
currentElement); |
|
tmpInstance.setPath(tmpInstance.buildPath( |
|
elementConformsClass)); |
|
return tmpInstance; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumElementConformsToProfileInstances( |
|
const OperationContext & opContext, const CIMNamespaceName & opNamespace) |
|
{ |
|
Array<CIMInstance> instances; |
|
Array<CIMInstance> providerCapabilitiesInstances; |
|
// Retrieve all of the provider profile registration info |
|
Array<CIMName> propList; |
|
propList.append(CAPABILITIES_PROPERTY_PROVIDERMODULENAME); |
|
propList.append(CAPABILITIES_PROPERTY_PROVIDERNAME); |
|
propList.append(PROFILECAPABILITIES_PROPERTY_PROFILEVERSION); |
|
propList.append(PROFILECAPABILITIES_PROPERTY_REGISTEREDPROFILE); |
|
propList.append(PROFILECAPABILITIES_PROPERTY_OTHERREGISTEREDPROFILE); |
|
propList.append(PROFILECAPABILITIES_PROPERTY_CONFORMINGELEMENTS); |
|
Array<CIMInstance> providerProfileInstances = |
|
repository->enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES, true, true, |
|
false, false, CIMPropertyList(propList)); |
|
CIMClass elementConformsClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE, |
|
false, true, false); |
|
CIMClass registeredProfileClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
false, true, false); |
|
|
|
// Loop through the provider profile info to determine what profiles are |
|
// supported by what providers, and to build the ElementConformsToProfile |
|
// associations. |
|
for(Uint32 i = 0, n = providerProfileInstances.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentProfileInstance = providerProfileInstances[i]; |
|
String moduleName = getRequiredValue<String>(currentProfileInstance, |
|
CAPABILITIES_PROPERTY_PROVIDERMODULENAME); |
|
String providerName = getRequiredValue<String>(currentProfileInstance, |
|
CAPABILITIES_PROPERTY_PROVIDERNAME); |
|
String profileName; |
|
Uint16 profileOrganization = 0; |
|
String otherOrganization; |
|
String profileVersion; |
|
String organizationName; |
|
Array<String> profileNames; |
|
String profileId = extractProfileInfo(currentProfileInstance, |
|
profileCapabilitiesClass, registeredProfileClass, profileName, |
|
profileVersion, profileOrganization, otherOrganization, |
|
organizationName, profileNames, true); |
|
Uint32 propIndex = currentProfileInstance.findProperty( |
|
PROFILECAPABILITIES_PROPERTY_CONFORMINGELEMENTS); |
|
|
|
Array<CIMName> elementPropArray; |
|
elementPropArray.append( |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD); |
|
elementPropArray.append( |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT); |
|
CIMPropertyList elementPropList(elementPropArray); |
|
|
|
// There are two cases: |
|
// 1. The provider profile info supplies a list of classes, all |
|
// instances of which are associated to the given RegisteredProfile |
|
// via the ElementConformsToProfile Association. If so, then the |
|
// Interop Provider will find the namespaces in which that provider |
|
// supports the given class and perform an enumerateInstanceNames |
|
// in that namespace to retrieve ObjectPaths that will be used to |
|
// create the Dependency reference an instance of the |
|
// ElementConformsToProfile association. |
|
// |
|
// 2. The provider profile info does not contain a list of classes in |
|
// the ConformingElements property. This might be the case if there |
|
// is no single class where all the elements of that class are |
|
// Conforming Elements to a given Registered Profile. In this case, |
|
// a provider is required to supply the association instance between |
|
// a RegisteredProfile supplied instance in the root/PG_InterOp |
|
// namespace and the Conforming Element. The provider must supply |
|
// that instance at least in the namespace of the Conforming |
|
// Element. If it does so, then the Interop Provider will detect |
|
// this and generate an equivilent instance for the root/PG_InterOp |
|
// namespace. If the provider also supplies the instance for the |
|
// root/PG_InterOp namespace, then the Interop Provider will simply |
|
// pass through those associations. |
|
if(propIndex == PEG_NOT_FOUND) |
|
{ |
|
// If there is no ConformingElements property, then we look for |
|
// instances in other namespaces and translate those into instances |
|
// from the Interop namespace. |
|
if(!opNamespace.equal(PEGASUS_NAMESPACENAME_INTEROP)) |
|
continue; |
|
Array<CIMName> elementConformsSubClasses = |
|
repository->enumerateClassNames(opNamespace, |
|
PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE, |
|
true); |
|
|
|
for(Uint32 j = 0, m = elementConformsSubClasses.size(); j < m; ++j) |
|
{ |
|
CIMName & subClass = elementConformsSubClasses[j]; |
|
if(subClass.equal(PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE)) |
|
continue; |
|
|
|
Array<String> searchNamespaces = |
|
findProviderNamespacesForElement( |
|
moduleName, providerName, subClass, repository, |
|
providerCapabilitiesInstances); |
|
|
|
Array<CIMInstance> elementConformsInstances; |
|
bool interopNamespaceFound = false; |
|
for(Uint32 j = 0, m = searchNamespaces.size(); j < m; ++j) |
|
{ |
|
CIMNamespaceName currentNamespace(searchNamespaces[j]); |
|
if(currentNamespace.equal(PEGASUS_NAMESPACENAME_INTEROP)) |
|
{ |
|
interopNamespaceFound = true; |
|
break; |
|
} |
|
|
|
elementConformsInstances.appendArray( |
|
cimomHandle.enumerateInstances(opContext, |
|
currentNamespace, |
|
PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE, |
|
true, true, false, false, elementPropList)); |
|
} |
|
|
|
if(!interopNamespaceFound) |
|
{ |
|
// Translate the instances found into instances of |
|
// PG_ElementConformsToNamespace |
|
for(Uint32 j = 0, m = elementConformsInstances.size(); |
|
j < m; ++j) |
|
{ |
|
instances.append(buildElementConformsToProfile( |
|
getRequiredValue<CIMObjectPath>( |
|
elementConformsInstances[j], |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT), |
|
getRequiredValue<CIMObjectPath>( |
|
elementConformsInstances[j], |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD), |
|
elementConformsClass)); |
|
} |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
// Build up the Object Path for the current profile |
|
Array<CIMKeyBinding> profileKeys; |
|
profileKeys.append(CIMKeyBinding( |
|
REGISTEREDPROFILE_PROPERTY_INSTANCEID, |
|
profileId,CIMKeyBinding::STRING)); |
|
|
|
CIMObjectPath currentProfile(hostName, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
profileKeys); |
|
|
|
Array<String> elementClasses; |
|
currentProfileInstance.getProperty(propIndex).getValue().get( |
|
elementClasses); |
|
Array<CIMObjectPath> conformingElements; |
|
for(Uint32 j = 0, m = elementClasses.size(); j < m; ++j) |
|
{ |
|
CIMName elementClass(elementClasses[j]); |
|
Array<String> searchNamespaces = |
|
findProviderNamespacesForElement( |
|
moduleName, providerName, |
|
elementClass, |
|
repository, |
|
providerCapabilitiesInstances); |
|
Uint32 k = 0; |
|
Uint32 x = searchNamespaces.size(); |
|
for(; k < x; ++k) |
|
{ |
|
CIMNamespaceName currentNamespace(searchNamespaces[k]); |
|
Array<CIMObjectPath> elements = |
|
cimomHandle.enumerateInstanceNames(opContext, |
|
currentNamespace, elementClass); |
|
for(Uint32 y = 0, z = elements.size(); y < z; ++y) |
|
{ |
|
// Normalize the reference object path |
|
CIMObjectPath & currentElement = elements[y]; |
|
currentElement.setNameSpace(currentNamespace); |
|
currentElement.setHost(hostName); |
|
} |
|
|
|
conformingElements.appendArray(elements); |
|
} |
|
} |
|
|
|
for(Uint32 k = 0, x = conformingElements.size(); k < x; ++k) |
|
{ |
|
CIMObjectPath & currentElement = conformingElements[k]; |
|
instances.append(buildElementConformsToProfile( |
|
currentProfile, currentElement, elementConformsClass)); |
|
} |
|
} |
|
} |
|
|
|
// Now add the default instance: the association between the Server Profile |
|
// and the ObjectManager (if we're in the Interop namespace) |
|
if(opNamespace == PEGASUS_NAMESPACENAME_INTEROP) |
|
{ |
|
// Build up the Object Path for the server profile |
|
Array<CIMKeyBinding> profileKeys; |
|
profileKeys.append(CIMKeyBinding( |
|
REGISTEREDPROFILE_PROPERTY_INSTANCEID, |
|
buildProfileInstanceId(SNIA_NAME, "Server", SNIA_VER_110), |
|
CIMKeyBinding::STRING)); |
|
CIMObjectPath serverProfile(hostName, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
profileKeys); |
|
// Retrieve the Object Manager instance |
|
CIMInstance objManager = getObjectManagerInstance(); |
|
|
|
instances.append(buildElementConformsToProfile(serverProfile, |
|
objManager.getPath(), elementConformsClass)); |
|
} |
|
|
|
return instances; |
|
} |
|
|
|
CIMInstance InteropProvider::buildSoftwareIdentity( |
|
const String & module, const String & provider, const String & version, |
|
const String & vendor, const String & interfaceType) |
|
{ |
|
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); |
|
|
|
softwareIdentity.setPath(softwareIdentity.buildPath(softwareIdentityClass)); |
|
|
|
return softwareIdentity; |
|
} |
|
|
|
void InteropProvider::extractSoftwareIdentityInfo(const CIMInstance & providerInstance, |
|
String & moduleName, String & providerName, String & version, |
|
String & vendor, String & interfaceType) |
|
{ |
|
// 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); |
|
Array<CIMInstance> providerModules = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDERMODULE, |
|
true, 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); |
|
|
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumSoftwareIdentityInstances() |
|
{ |
|
Array<CIMInstance> instances; |
|
|
|
Array<CIMInstance> registeredProviders = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER); |
|
for(Uint32 i = 0, n = registeredProviders.size(); i < n; ++i) |
|
{ |
|
String moduleName; |
|
String providerName; |
|
String version; |
|
String vendor; |
|
String interfaceType; |
|
extractSoftwareIdentityInfo(registeredProviders[i], moduleName, |
|
providerName, version, vendor, interfaceType); |
|
|
|
instances.append(buildSoftwareIdentity(moduleName, providerName, |
|
version, vendor, interfaceType)); |
|
} |
|
|
|
// Always have the default Pegasus |
|
instances.append(buildSoftwareIdentity(PEGASUS_MODULE_NAME, |
|
INTEROP_PROVIDER_NAME, PEGASUS_PRODUCT_VERSION, |
|
PEGASUS_CIMOM_GENERIC_NAME, PEGASUS_INTERNAL_PROVIDER_TYPE)); |
|
return instances; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumElementSoftwareIdentityInstances() |
|
{ |
|
Array<CIMInstance> instances; |
|
|
|
Array<CIMInstance> profileCapabilities = repository->enumerateInstances( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES); |
|
|
|
CIMClass elementSoftwareIdentityClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_ELEMENTSOFTWAREIDENTITY, false, true, false); |
|
|
|
for(Uint32 i = 0, n = profileCapabilities.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentCapabilities = profileCapabilities[i]; |
|
String version; |
|
String organizationName; |
|
Array<String> subprofiles; |
|
String dummyStr; |
|
Uint16 dummyInt = 0; |
|
String profileId = extractProfileInfo(currentCapabilities, |
|
profileCapabilitiesClass, |
|
repository->getClass(PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, false, true, false), |
|
dummyStr, // Throw away profile name |
|
version, |
|
dummyInt, // Throw away organization enum |
|
dummyStr, // Throw away otherOrganization, we get it below |
|
organizationName, |
|
subprofiles, |
|
false); // Get subprofile information |
|
String moduleName = getRequiredValue<String>(currentCapabilities, |
|
CAPABILITIES_PROPERTY_PROVIDERMODULENAME); |
|
String providerName = getRequiredValue<String>(currentCapabilities, |
|
CAPABILITIES_PROPERTY_PROVIDERNAME); |
|
|
|
String softwareInstanceId = moduleName + "+" + providerName; |
|
instances.append(buildDependencyInstance( |
|
softwareInstanceId, |
|
PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, |
|
profileId, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
elementSoftwareIdentityClass)); |
|
|
|
for(Uint32 j = 0, m = subprofiles.size(); j < m; ++j) |
|
{ |
|
instances.append(buildDependencyInstance( |
|
softwareInstanceId, |
|
PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, |
|
buildProfileInstanceId(organizationName, subprofiles[j], |
|
version), |
|
PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE, |
|
elementSoftwareIdentityClass)); |
|
} |
|
} |
|
|
|
// Create default association between Server profile, Indications |
|
// subprofile, and the Pegasus Interoperability provider software identity |
|
String interopSoftwareIdentity = PEGASUS_MODULE_NAME + "+" + |
|
INTEROP_PROVIDER_NAME; |
|
String serverProfileId = buildProfileInstanceId(SNIA_NAME, "Server", |
|
SNIA_VER_110); |
|
String indicationProfileId = buildProfileInstanceId(SNIA_NAME, |
|
"Indication", SNIA_VER_110); |
|
|
|
instances.append(buildDependencyInstance(interopSoftwareIdentity, |
|
PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, serverProfileId, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
elementSoftwareIdentityClass)); |
|
|
|
instances.append(buildDependencyInstance(interopSoftwareIdentity, |
|
PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, indicationProfileId, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE, |
|
elementSoftwareIdentityClass)); |
|
|
|
return instances; |
} | } |
| |
PEGASUS_NAMESPACE_END |
|
// END_OF_FILE | // END_OF_FILE |