version 1.11, 2004/09/29 19:46:20
|
version 1.88.2.1, 2011/10/11 18:18:16
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// |
// Source License; you may not use this file except in compliance with the |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// License. |
// of this software and associated documentation files (the "Software"), to |
// |
// deal in the Software without restriction, including without limitation the |
// Permission is hereby granted, free of charge, to any person obtaining a |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// copy of this software and associated documentation files (the "Software"), |
// sell copies of the Software, and to permit persons to whom the Software is |
// to deal in the Software without restriction, including without limitation |
// furnished to do so, subject to the following conditions: |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// |
// and/or sell copies of the Software, and to permit persons to whom the |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// Software is furnished to do so, subject to the following conditions: |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// The above copyright notice and this permission notice shall be included |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// in all copies or substantial portions of the Software. |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
// |
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
//============================================================================== |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
// |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
// Author: Karl Schopmeyer (k.schopmeyer@opengroup.org) |
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// |
// |
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
////////////////////////////////////////////////////////////////////////// |
// (carolann_graves@hp.com) |
|
// Karl Schopmeyer - Created Cim_Namespace capabilities. |
|
// Karl Schopmeyer - added objectmanager and communication classes |
|
// | // |
//%//////////////////////////////////////////////////////////////////////////// | //%//////////////////////////////////////////////////////////////////////////// |
| |
|
|
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
// Interop Provider - This provider services those classes from the | // Interop Provider - This provider services those classes from the |
// DMTF Interop schema association with the CIMOM itself |
// DMTF Interop schema in an implementation compliant with the SMI-S v1.1 |
|
// Server Profile |
// | // |
// This provider services the following classes: |
// Please see PG_ServerProfile20.mof in the directory |
// CIMObjectManager |
// $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the |
// CIM_ObjectManagerCommunicationMechanism |
// classes supported by this control provider. |
// CIM_CIMXMLCommunicationMechanism |
// |
// CIM_ProtocolAdapter |
// Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP |
// CIM_Namespace (Effective Pegasus 2.4 we use PG_Namespace which |
// namespace. There is a test on each operation that returns |
// is a subclass of CIM_Namespace with additional properties for |
// the Invalid Class CIMDError |
// shared namespaces. |
|
// |
|
// It also services the Interop associations tied to these classes |
|
// including: |
|
// CIM_NamespaceInManager |
|
// ... |
|
// 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. |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
/* TODO LIST: |
|
1. Finish the association functions |
|
|
|
2. UUID generation should become a system function since it will be used |
|
by many providers, etc. as part of id generation. |
|
|
|
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 |
|
much of the user right now. |
|
*/ |
|
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/PegasusVersion.h> | #include <Pegasus/Common/PegasusVersion.h> |
|
|
#include <iostream> | #include <iostream> |
| |
#include "InteropProvider.h" | #include "InteropProvider.h" |
#include "Guid.h" |
#include "InteropProviderUtils.h" |
#include <Pegasus/Common/String.h> |
#include "InteropConstants.h" |
#include <Pegasus/Common/System.h> |
|
#include <Pegasus/Common/ArrayInternal.h> |
|
#include <Pegasus/Common/CIMName.h> |
|
#include <Pegasus/Common/CIMType.h> |
|
#include <Pegasus/Common/CIMInstance.h> |
|
#include <Pegasus/Common/CIMObjectPath.h> |
|
#include <Pegasus/Common/InternalException.h> |
|
#include <Pegasus/Common/CIMStatusCode.h> |
|
#include <Pegasus/Common/Tracer.h> |
|
#include <Pegasus/Common/OperationContext.h> |
|
#include <Pegasus/Config/ConfigManager.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/StringConversion.h> |
|
#include <Pegasus/Common/ArrayIterator.h> |
| |
|
PEGASUS_USING_STD; |
|
PEGASUS_NAMESPACE_BEGIN |
| |
#include <stdlib.h> |
/***************************************************************************** |
|
* |
|
* The following are constants representing property names for the classes |
|
* managed by the Interop Provider. Where multiple classes have properties of |
|
* the same name, there will be a common CIMName object defined, and a macro |
|
* defined that points to the common CIMName object, but whose macro name |
|
* reflects the class in which the property is used. |
|
* |
|
*****************************************************************************/ |
|
|
|
// |
|
// Constructor for the InteropProvider control provider |
|
// |
|
InteropProvider::InteropProvider( |
|
CIMRepository * rep, |
|
ProviderRegistrationManager *provRegManager): |
|
repository(rep), |
|
providerRegistrationManager(provRegManager), |
|
hostName(System::getHostName()), |
|
providerInitialized(false), |
|
updateProfileCache(0), |
|
profileIds(Array<String>()), |
|
conformingElements(Array<CIMNameArray>()), |
|
elementNamespaces(Array<CIMNamespaceArray>()) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); |
| |
//The following include is needed for gethostbyname |
ConfigManager *configManager = ConfigManager::getInstance(); |
#if defined(PEGASUS_OS_TYPE_WINDOWS) |
#ifdef PEGASUS_ENABLE_SLP |
#include <objbase.h> |
enableSLP = ConfigManager::parseBooleanValue( |
|
configManager->getCurrentValue("slp")); |
#else | #else |
#include <netdb.h> |
enableSLP = false; |
#include <arpa/inet.h> |
|
#endif | #endif |
| |
PEGASUS_USING_STD; |
httpPort = configManager->getCurrentValue("httpPort"); |
|
if (httpPort.size() == 0) |
PEGASUS_NAMESPACE_BEGIN |
|
|
|
#define CDEBUG(X) |
|
#define LDEBUG() |
|
//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl) |
|
//#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::INFORMATION, "$0", X) |
|
// The following is attempt to use the tracer for CDEBUG. Not working. 1 sept 2004 |
|
//#include <cstring> |
|
//#include <stdcxx/stream/strstream> |
|
// This one sucks because not applicable to separate executables. |
|
// looks like we use trace for the externals. |
|
// requires using PEGASUS_USING_PEGASUS |
|
//#define CDEBUG(X) {ostrstream os; os << X; char* tmp = os.str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp));delete tmp;} |
|
//#define CDEBUG(X) {stringstream os; os << X;string os_str = os.str(); const char* tmp = os_str.c_str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp); } |
|
|
|
//************************************************************************** |
|
// |
|
// Constants representing the class names processed |
|
// |
|
//************************************************************************** |
|
|
|
const char * thisProvider = "InteropProvider"; |
|
// The following should be moved to somewhere like constants. |
|
static const String PegasusInstanceIDGlobalPrefix = "PEG"; |
|
|
|
/** |
|
The constants representing the class names we process |
|
*/ |
|
// ATTN DELETE: static const CIMName __NAMESPACE_CLASSNAME = CIMName ("__Namespace"); |
|
static const CIMName CIM_NAMESPACE_CLASSNAME = CIMName ("CIM_Namespace"); |
|
static const CIMName PG_NAMESPACE_CLASSNAME = CIMName ("PG_Namespace"); |
|
|
|
static const CIMName CIM_OBJECTMANAGER_CLASSNAME = CIMName ("CIM_ObjectManager"); |
|
static const CIMName CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME = |
|
CIMName ("CIM_ObjectManagerCommunicationMechanism"); |
|
static const CIMName PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME = |
|
CIMName ("PG_CIMXMLCommunicationMechanism"); |
|
static const CIMName CIM_COMMMECHANISMFORMANAGER_CLASSNAME = |
|
CIMName ("CIM_CommMechanismForManager"); |
|
static const CIMName CIM_NAMESPACEINMANAGER_CLASSNAME = |
|
CIMName ("CIM_NamespaceInManager"); |
|
|
|
// Property Names for __Namespace Class |
|
static const CIMName NAMESPACE_PROPERTYNAME = CIMName ("Name"); |
|
static const CIMNamespaceName ROOTNS = CIMNamespaceName ("root"); |
|
|
|
|
|
// Property names for CIM_ObjectManager Class |
|
static const CIMName OM_GATHERSTATISTICALDATA = |
|
CIMName ("GatherStatisticalData"); |
|
// Property for the slp template. |
|
static const CIMName OM_DESCRIPTIONPROPERTY = |
|
CIMName("Description"); |
|
|
|
// Property Names for ObjectManagerCommunicationMechanism Class |
|
static const CIMName OM_COMMUNICATIONMECHANISM = |
|
CIMName ("CommunicationMechanism"); |
|
static const CIMName OM_FUNCTIONALPROFILESSUPPORTED = |
|
CIMName ("FunctionalProfilesSupported"); |
|
static const CIMName OM_FUNCTIONALPROFILEDESCRIPTIONS = |
|
CIMName ("FunctionalProfileDescriptions"); |
|
static const CIMName OM_AUTHENTICATIONMECHANISMSSUPPORTED = |
|
CIMName ("AuthenticationMechanismsSupported"); |
|
static const CIMName OM_AUTHENTICATIONMECHANISMDESCRIPTIONS = |
|
CIMName ("AuthenticationMechanismDescriptions"); |
|
static const CIMName OM_MULTIPLEOPERATIONSSUPPORTED = |
|
CIMName ("MultipleOperationsSupported"); |
|
static const CIMName OM_VERSION = |
|
CIMName ("Version"); |
|
|
|
// Property Names for CIMXML CommunicationMechanism |
|
|
|
static const CIMName CIMVALIDATED = |
|
CIMName ("CIMValidated"); |
|
|
|
static const String CIMXMLProtocolVersion = "1.0"; |
|
|
|
// Property names for CIM_Namespace Class |
|
|
|
static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME = |
|
CIMName ("SystemCreationClassName"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMNAME = |
|
CIMName ("SystemName"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME = |
|
CIMName ("ObjectManagerCreationClassName"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME = |
|
CIMName ("ObjectManagerName"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME = |
|
CIMName ("CreationClassName"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_NAME = CIMName ("Name"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO = |
|
CIMName ("ClassInfo"); |
|
static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO = |
|
CIMName ("DescriptionOfClassInfo"); |
|
|
|
// Additional Property names for PG_Namespace Class |
|
|
|
static const CIMName PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED = |
|
CIMName ("SchemaUpdatesAllowed"); |
|
static const CIMName PG_NAMESPACE_PROPERTY_ISSHAREABLE = |
|
CIMName ("IsShareable"); |
|
static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE = |
|
CIMName ("ParentNamespace"); |
|
static const CIMName PG_NAMESPACE_PROPERTY_NAME = |
|
CIMName ("Name"); |
|
|
|
// Defines to serve as the ENUM for class selection for instance |
|
// operations. |
|
|
|
enum targetClass{ |
|
//__NAMESPACE = 1, |
|
PG_NAMESPACE = 1, |
|
CIM_OBJECTMANAGER = 2, |
|
PG_CIMXMLCOMMUNICATIONMECHANISM = 3, |
|
CIM_NAMESPACEINMANAGERINST =4, |
|
CIM_COMMMECHANISMFORMANAGERINST=5 |
|
}; |
|
|
|
enum targetAssocClass{ |
|
CIM_NAMESPACEINMANAGER =1, |
|
CIM_COMMMECHANISMFORMANAGER=2 |
|
}; |
|
|
|
//*************************************************************** |
|
// Provider Utility Functions |
|
//*************************************************************** |
|
|
|
/** get one string property from an instance. Note that these functions simply |
|
return the default value if the property cannot be found or is of the wrong |
|
type thus, in reality being a maintenance problem since there is no |
|
error indication. |
|
@param instance CIMInstance from which we get property value |
|
@param propertyName String name of the property containing the value |
|
@param default String optional parameter that is substituted if the property does |
|
not exist, is Null, or is not a string type. The substitute is String::EMPTY |
|
@return String value found or defaultValue. |
|
*/ |
|
String _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const String& defaultValue) |
|
{ |
|
String output = defaultValue; |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
{ |
|
CIMConstProperty p1 = instance.getProperty(pos); |
|
if (p1.getType() == CIMTYPE_STRING) |
|
{ |
|
CIMValue v1 = p1.getValue(); |
|
|
|
if (!v1.isNull()) |
|
v1.get(output); |
|
} |
|
} |
|
return(output); |
|
} |
|
|
|
// Overload of _getPropertyValue for boolean type |
|
Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const Boolean defaultValue) |
|
{ |
|
Boolean output = defaultValue; |
|
Uint32 pos; |
|
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
|
{ |
|
CIMConstProperty p1 = instance.getProperty(pos); |
|
if (p1.getType() == CIMTYPE_BOOLEAN) |
|
{ |
|
CIMValue v1 = p1.getValue(); |
|
|
|
if (!v1.isNull()) |
|
v1.get(output); |
|
} |
|
} |
|
return(output); |
|
} |
|
|
|
/** get Host IP address from host name. If the |
|
host name is not provided, uses internal function. |
|
If everything fails, gets the definition normally |
|
used for localhost (127.0.0.1). |
|
|
|
@param hostName String with the name of the host |
|
@return String with the IP address to be used |
|
NOTE: This code should not be in slpprovider. This |
|
should be in the Interop classes but for the moment |
|
it is not. |
|
*/ |
|
String _getHostAddress(String hostName) |
|
{ |
|
// set default address |
|
String ipAddress("127.0.0.1"); |
|
|
|
if (hostName == String::EMPTY) |
|
hostName = System::getHostName(); |
|
|
|
struct hostent * phostent; |
|
struct in_addr inaddr; |
|
|
|
if ((phostent = ::gethostbyname((const char *)hostName.getCString())) != NULL) |
|
{ |
|
::memcpy( &inaddr, phostent->h_addr,4); |
|
ipAddress = ::inet_ntoa( inaddr ); |
|
} |
|
return ipAddress; |
|
} |
|
|
|
Array<String> _getFunctionalProfiles(Array<Uint16> profiles) |
|
{ |
|
Array<String> profileDescriptions; |
|
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 |
|
This can be either the default PEG or if the environment |
|
variable PEGASUS_TRADEMARK_PREFIX is defined this is used. |
|
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() |
|
{ |
|
|
|
char * trademark; |
|
trademark = getenv("PEGASUS_TRADEMARK_PREFIX"); |
|
return((trademark)? trademark : PegasusInstanceIDGlobalPrefix); |
|
} |
|
/** Builds the UUID string for this CIMOM. |
|
**/ |
|
String getUUIDString() |
|
{ |
|
return(Guid::getGuid()); |
|
} |
|
|
|
/* Test the keys in the CIM_Namespace for valid values |
|
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; |
Uint32 portNumberHttp = System::lookupPort( |
|
WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT); |
|
char buffer[32]; |
|
Uint32 n; |
|
const char *output = Uint32ToString(buffer, portNumberHttp, n); |
|
httpPort.assign(output, n); |
} | } |
Boolean _validateProperties(const CIMInstance& instance) |
|
|
httpsPort = configManager->getCurrentValue("httpsPort"); |
|
if (httpsPort.size() == 0) |
{ | { |
return true; |
Uint32 portNumberHttps = System::lookupPort( |
|
WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT); |
|
char buffer[32]; |
|
Uint32 n; |
|
const char *output = Uint32ToString(buffer, portNumberHttps, n); |
|
httpsPort.assign(output, n); |
} | } |
| |
/* Validate that the property exists, is string type and |
|
optionally the value itself. Note processes only String |
|
properties. |
|
@param Instance to search for property. |
|
@param CIMName containing property Name |
|
@value String containing value. If not String::EMPTY, compare to |
|
value in the property |
|
@return True if passes all tests |
|
*/ |
|
Boolean _validateRequiredProperty(const CIMInstance& instance, |
|
const CIMName& propertyName, |
|
const String& value) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_validateRequiredProperty()"); |
|
Uint32 pos; |
|
| |
if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND) |
#ifndef PEGASUS_DISABLE_PERFINST |
|
try |
{ | { |
PEG_METHOD_EXIT(); |
initProvider(); |
return(false); |
|
} | } |
// |
catch(const Exception &) |
// Get the property |
|
// |
|
CIMConstProperty theProperty = instance.getProperty(pos); |
|
const CIMValue theValue = theProperty.getValue (); |
|
// |
|
// ATTN: Required property must have a non-null value |
|
// |
|
if ((theValue.getType() != CIMTYPE_STRING) || (theValue.isNull())) |
|
{ | { |
PEG_METHOD_EXIT(); |
// Provider initialization may fail if the repository is not |
return(false); |
// populated |
} | } |
|
#endif |
| |
String valueField; |
|
theValue.get(valueField); |
|
if ((value == String::EMPTY) || (valueField == value)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
return(true); |
|
} |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(false); |
|
} | } |
| |
Boolean _validateRequiredProperty(const CIMInstance& instance, |
// |
const CIMName& propertyName, |
// Local version of getInstance to be used by other functions in the the |
const Uint16& value) |
// provider. Returns a single instance. Note that it always returns an |
|
// instance. If none was found, it is uninialitized. |
|
// |
|
CIMInstance InteropProvider::localGetInstance( |
|
const OperationContext & context, |
|
const CIMObjectPath & instanceName, |
|
const CIMPropertyList & propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance"); |
"InteropProvider::_validateRequiredProperty()"); |
|
|
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Validate " |
|
+ propertyName.getString()); |
|
| |
Uint32 pos; |
PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND) |
"%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) |
|
// Get CIM_IndicationService instance from IndicationService. |
|
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT |
|
|| opClass == PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE |
|
#endif |
|
) |
{ | { |
|
AutoMutex mut(interopMut); |
|
CIMInstance gotInstance = cimomHandle.getInstance( |
|
context, |
|
opNamespace, |
|
instanceName, |
|
false, |
|
false, |
|
false, |
|
propertyList); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(false); |
return gotInstance; |
} | } |
// |
|
// Get the property |
TARGET_CLASS classEnum = translateClassInput(opClass); |
// |
CIMInstance retInstance; |
CIMConstProperty theProperty = instance.getProperty(pos); |
switch(classEnum) |
CIMValue theValue = theProperty.getValue (); |
{ |
// |
case PG_SOFTWAREIDENTITY: |
// ATTN:Required property must have a non-null value |
{ |
// |
retInstance = getSoftwareIdentityInstance(instanceName); |
if ((theValue.getType() != CIMTYPE_UINT16) |
normalizeInstance( |
|| (theValue.isNull()) ) |
retInstance, instanceName, false, false, propertyList); |
|
} |
|
break; |
|
case PG_NAMESPACE: |
|
{ |
|
retInstance = getNameSpaceInstance(instanceName); |
|
normalizeInstance( |
|
retInstance, instanceName, false, false, propertyList); |
|
} |
|
break; |
|
// ATTN: Implement getIntstance for all other classes. Currently |
|
// this method calls localEnumerateInstances() to select instance |
|
// which is too expensive. |
|
default: |
|
{ |
|
// 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); |
|
ConstArrayIterator<CIMInstance> instancesIter(instances); |
|
|
|
// deliver a single instance if found. |
|
bool found = false; |
|
for(Uint32 i = 0; i < instancesIter.size(); i++) |
{ | { |
PEG_METHOD_EXIT(); |
CIMObjectPath currentInstRef = instancesIter[i].getPath(); |
return(false); |
currentInstRef.setHost(instanceName.getHost()); |
|
currentInstRef.setNameSpace(instanceName.getNameSpace()); |
|
if(instanceName == currentInstRef) |
|
{ |
|
retInstance = instancesIter[i]; |
|
found = true; |
|
break; |
|
} |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(true); |
if (!found) |
|
{ |
|
throw CIMObjectNotFoundException(instanceName.toString()); |
|
} |
|
} |
} | } |
Boolean _validateRequiredProperty(const CIMObjectPath& objectPath, |
|
const CIMName& propertyName, |
return retInstance; |
const String value) |
} |
|
|
|
Array<CIMInstance> InteropProvider::getReferencedInstances( |
|
const Array<CIMInstance> &refs, |
|
const String targetRole, |
|
const OperationContext & context, |
|
const CIMPropertyList & propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_validateRequiedProperty()"); |
"InteropProvider::getReferencedObjects"); |
Array<CIMKeyBinding> kbArray = objectPath.getKeyBindings(); |
|
| |
// find the correct key binding |
Array<CIMInstance> referencedInstances; |
for (Uint32 i = 0; i < kbArray.size(); i++) |
Array<CIMInstance> classInstances; |
|
CIMName prevClassName; |
|
|
|
ConstArrayIterator<CIMInstance> refsIter(refs); |
|
for(Uint32 i = 0; i < refsIter.size(); i++) |
|
{ |
|
CIMInstance thisRef = refsIter[i]; |
|
CIMObjectPath thisTarget = getRequiredValue<CIMObjectPath>( |
|
thisRef, |
|
targetRole); |
|
|
|
// 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 = thisTarget.getNameSpace(); |
|
CIMName opClass = thisTarget.getClassName(); |
|
|
|
if((opNamespace != PEGASUS_NAMESPACENAME_INTEROP && |
|
opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE) |
|
// Get CIM_IndicationService instance from IndicationService. |
|
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT |
|
|| opClass == PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE |
|
#endif |
|
) |
{ | { |
if (kbArray[i].getName() == propertyName) |
AutoMutex mut(interopMut); |
|
CIMInstance gotInstance = cimomHandle.getInstance( |
|
context, |
|
opNamespace, |
|
thisTarget, |
|
false, |
|
false, |
|
false, |
|
propertyList); |
|
referencedInstances.append(gotInstance); |
|
continue; |
|
} |
|
|
|
TARGET_CLASS classEnum = translateClassInput(opClass); |
|
CIMInstance retInstance; |
|
switch(classEnum) |
|
{ |
|
case PG_SOFTWAREIDENTITY: |
|
{ |
|
CIMInstance retInstance = |
|
getSoftwareIdentityInstance(thisTarget); |
|
normalizeInstance( |
|
retInstance, thisTarget, false, false, propertyList); |
|
retInstance.setPath(thisTarget); |
|
referencedInstances.append(retInstance); |
|
} |
|
break; |
|
case PG_NAMESPACE: |
|
{ |
|
CIMInstance retInstance = getNameSpaceInstance(thisTarget); |
|
normalizeInstance( |
|
retInstance, thisTarget, false, false, propertyList); |
|
retInstance.setPath(thisTarget); |
|
referencedInstances.append(retInstance); |
|
} |
|
break; |
|
default: |
|
{ |
|
if( opClass != prevClassName ) |
|
{ |
|
CIMObjectPath ref; |
|
ref.setHost(thisTarget.getHost()); |
|
ref.setClassName(thisTarget.getClassName()); |
|
ref.setNameSpace(thisTarget.getNameSpace()); |
|
classInstances = localEnumerateInstances( |
|
context, |
|
ref, |
|
propertyList); |
|
ArrayIterator<CIMInstance> instsIter(classInstances); |
|
for(Uint32 n = 0; n < instsIter.size(); n++) |
{ | { |
if (value != String::EMPTY) |
CIMObjectPath tmpInst = instsIter[n].getPath(); |
|
tmpInst.setHost(thisTarget.getHost()); |
|
tmpInst.setNameSpace(thisTarget.getNameSpace()); |
|
instsIter[n].setPath(tmpInst); |
|
} |
|
prevClassName = opClass; |
|
} |
|
ConstArrayIterator<CIMInstance> instsConstIter(classInstances); |
|
for(Uint32 j = 0; j < instsConstIter.size(); j++) |
{ | { |
if (value !=kbArray[i].getValue()) |
if(thisTarget == instsConstIter[j].getPath()) |
{ | { |
PEG_METHOD_EXIT(); |
referencedInstances.append(instsConstIter[j]); |
return(true); |
break; |
|
} |
} | } |
} | } |
|
break; |
} | } |
} | } |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(true); |
return referencedInstances; |
} | } |
| |
/* Query the repository for array of all namespacenames |
// |
@return Array<CIMNamespaceName> with all namespaces |
// Local version of enumerateInstances to be used by other functions in the |
@exception Passes all exception that repository may generate. |
// provider. Note that this delivers instances as a group rather than one |
*/ |
// at a time. This design point may need to be revisited if this provider |
Array<CIMNamespaceName> InteropProvider::_enumerateNameSpaces() |
// is used in environments such that returning segmented responses would have |
|
// significant performance advantages. For now, that doesn't seem to be the |
|
// case. |
|
// |
|
Array<CIMInstance> InteropProvider::localEnumerateInstances( |
|
const OperationContext & context, |
|
const CIMObjectPath & ref, |
|
const CIMPropertyList& propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_enumerateNameSpaces()"); |
"InteropProvider::localEnumerateInstances()"); |
|
const CIMName & className = ref.getClassName(); |
Array<CIMNamespaceName> namespaceNames; |
PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"%s enumerateInstances. referenc= %s , PropertyList= %s", |
|
thisProvider, |
|
(const char *)className.getString().getCString(), |
|
(const char *)propertyListToString(propertyList).getCString())); |
| |
namespaceNames = _repository->enumerateNameSpaces(); |
// Verify that ClassName is correct and get its enum value |
|
TARGET_CLASS classEnum = translateClassInput(className); |
| |
PEG_METHOD_EXIT(); |
Array<CIMInstance> instances; |
return(namespaceNames); |
switch(classEnum) |
|
{ |
|
case PG_OBJECTMANAGER: |
|
{ |
|
instances.append(getObjectManagerInstance()); |
|
break; |
} | } |
|
case PG_CIMXMLCOMMUNICATIONMECHANISM: |
/* get a class defintion. Gets the class defined by |
|
the parameters. Generates exception of class not defined. |
|
@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, |
instances = enumCIMXMLCommunicationMechanismInstances(); |
"InteropProvider::_getClass"); |
break; |
|
|
CIMClass myClass = _repository->getClass(nameSpace, className, |
|
false,true,true); |
|
PEG_METHOD_EXIT(); |
|
return myClass; |
|
} | } |
|
case PG_NAMESPACEINMANAGER: |
/* Verify that this is one of the legal classnames and |
|
return indicator which. |
|
@param - Classname |
|
@return - Uint32 indicating type |
|
@Exceptions - throws CIMNotSupportedException if invalid class. |
|
*/ |
|
targetClass _verifyValidClassInput(const CIMName& className) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances = enumNamespaceInManagerInstances(); |
"InteropProvider::_verifyValidClassInput"); |
break; |
if (className.equal(CIM_OBJECTMANAGER_CLASSNAME)) |
|
return CIM_OBJECTMANAGER; |
|
|
|
if (className.equal(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME)) |
|
return PG_CIMXMLCOMMUNICATIONMECHANISM; |
|
|
|
// Last entry, reverse test and return OK if PG_Namespace |
|
// Note: Changed to PG_Namespace for CIM 2.4 |
|
if (!className.equal(PG_NAMESPACE_CLASSNAME)) |
|
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
|
|
|
PEG_METHOD_EXIT(); |
|
return PG_NAMESPACE; |
|
} | } |
|
case PG_COMMMECHANISMFORMANAGER: |
targetAssocClass _verifyValidAssocClassInput(const CIMName& className) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances = enumCommMechanismForManagerInstances(); |
"InteropProvider::_verifyValidAssocClassInput"); |
break; |
if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME)) |
|
return CIM_NAMESPACEINMANAGER; |
|
// Last entry, reverse test and return OK if CIM_CommMech.... |
|
if (!className.equal(CIM_COMMMECHANISMFORMANAGER_CLASSNAME)) |
|
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
|
|
|
PEG_METHOD_EXIT(); |
|
return CIM_COMMMECHANISMFORMANAGER; |
|
} | } |
|
case PG_NAMESPACE: |
/* validate the authorization of the user name against the namespace. |
|
*/ |
|
String _validateUserID(const OperationContext & context) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances = enumNamespaceInstances(); |
"InteropProvider::_validateUserID"); |
break; |
//ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER |
} |
String userName; |
case PG_REGISTEREDPROFILE: |
try |
|
{ | { |
IdentityContainer container = context.get(IdentityContainer::NAME); |
instances = enumRegisteredProfileInstances(); |
userName = container.getUserName(); |
break; |
} | } |
|
case PG_REGISTEREDSUBPROFILE: |
catch (...) |
|
{ | { |
userName = String::EMPTY; |
instances = enumRegisteredSubProfileInstances(); |
|
break; |
} | } |
|
case PG_REFERENCEDPROFILE: |
PEG_METHOD_EXIT(); |
{ |
return userName; |
instances = enumReferencedProfileInstances(); |
|
break; |
} | } |
|
case PG_ELEMENTCONFORMSTOPROFILE: |
/** Set the value of a property defined by property name in the instance provided. |
|
Sets a String into the value field unless the property name cannot be found. |
|
If the property cannot be found, it simply returns. |
|
ATTN: This function does not pass an error back if property not found. |
|
@param instance CIMInstance in which to set property value |
|
@param propertyName CIMName of property in which value will be set. |
|
@param value String value to set into property |
|
|
|
*/ |
|
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const String& value) |
|
{ | { |
Uint32 pos; |
instances = enumElementConformsToProfileInstances(context, |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
ref.getNameSpace()); |
instance.getProperty(pos).setValue(CIMValue(value)); |
break; |
} | } |
|
case PG_ELEMENTCONFORMSTOPROFILE_RP_RP: |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Boolean& value) |
|
{ | { |
Uint32 pos; |
instances = enumElementConformsToProfileRPRPInstances( |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
context, |
instance.getProperty(pos).setValue(CIMValue(value)); |
ref.getNameSpace()); |
|
break; |
} | } |
|
case PG_SUBPROFILEREQUIRESPROFILE: |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Uint16& value) |
|
{ | { |
Uint32 pos; |
instances = enumSubProfileRequiresProfileInstances(); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
break; |
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} | } |
|
case PG_SOFTWAREIDENTITY: |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<String>& value) |
|
{ | { |
Uint32 pos; |
instances = enumSoftwareIdentityInstances(); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
break; |
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} | } |
|
case PG_ELEMENTSOFTWAREIDENTITY: |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<Uint16>& value) |
|
{ | { |
Uint32 pos; |
instances = enumElementSoftwareIdentityInstances(); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
break; |
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} | } |
|
case PG_INSTALLEDSOFTWAREIDENTITY: |
void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const CIMObjectPath& value) |
|
{ | { |
Uint32 pos; |
instances = enumInstalledSoftwareIdentityInstances(context); |
if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND) |
break; |
instance.getProperty(pos).setValue(CIMValue(value)); |
|
} | } |
|
case PG_COMPUTERSYSTEM: |
/** add the correct values to the common keys defined for all of the classes. This is |
|
systemcreationclassname and systemname |
|
Note that if the properties do not exist, we simply ignore them. |
|
*/ |
|
void _fixInstanceCommonKeys(CIMInstance& instance) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances.append(getComputerSystemInstance(context)); |
"InteropProvider::_fixInstanceCommonKeys()"); |
break; |
String SystemCreationClassName = System::getSystemCreationClassName (); |
} |
if (SystemCreationClassName == String::EMPTY) |
case PG_HOSTEDOBJECTMANAGER: |
{ | { |
//Attn: Get this globally. For now This in place because global is often Empty |
instances.append(getHostedObjectManagerInstance(context)); |
SystemCreationClassName = "CIM_ComputerSystem"; |
break; |
} | } |
|
case PG_HOSTEDACCESSPOINT: |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName); |
{ |
|
instances = enumHostedAccessPointInstances(context); |
// Add property SystemName |
break; |
|
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getHostName()); |
|
PEG_METHOD_EXIT(); |
|
} | } |
|
//We don't support enumerate CIM_Namespace instances. PG_Namespace is |
/** builds one instance of the class named className. Gets Class defintion and f |
//supported. |
fills in the correct properties from the class. This requires a repository |
case CIM_NAMESPACE: |
getclass request for each instance built. The skeleton is built by |
|
creating the instance and copying qualifiers and properties from |
|
the class. Finally the instance is cloned to separate it from the |
|
original objects. |
|
NOTE: This is very inefficient for anything larger than a few instances. |
|
We should separate the get from the createSkeleton. |
|
@param className CIMName of the class for which the instance is to be built |
|
@return CIMInstance of this class with properties complete. |
|
@exception passes on any exceptions received from the repository request. |
|
*/ |
|
CIMInstance InteropProvider::_buildInstanceSkeleton(const CIMName& className) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
break; |
"InteropProvider::_buildInstanceSkeleton()"); |
|
CIMClass myClass; |
|
|
|
CIMInstance skeleton(className); |
|
myClass = _repository->getClass(_operationNamespace, className, false, true, true); |
|
|
|
// 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(); |
|
return(skeleton.clone()); |
|
} | } |
|
case PG_PROVIDERPROFILECAPABILITIES: |
/* build a single instance of the cimxmlcommunicationmechanism class |
|
using the parameter provided as the name property |
|
@parm name String representing the name to be used for this object. |
|
@return CIMInstance of the class |
|
*/ |
|
CIMInstance InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism( |
|
const String& namespaceType, |
|
const String& IPAddress, |
|
const Boolean& includeQualifiers, |
|
const Boolean& includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances = enumProviderProfileCapabilityInstances(false); |
"InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism()"); |
break; |
|
|
CIMInstance instance = _buildInstanceSkeleton(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME); |
|
|
|
_fixInstanceCommonKeys(instance); |
|
|
|
//CreationClassName |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString()); |
|
|
|
//Name, this CommunicationMechanism. |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString()); |
|
|
|
// CommunicationMechanism Property |
|
_setPropertyValue(instance, OM_COMMUNICATIONMECHANISM, Uint16(2)); |
|
|
|
//Functional Profiles Supported Property. |
|
Array<Uint16> profiles; |
|
Array<String> profileDescriptions = _getFunctionalProfiles(profiles); |
|
|
|
// Set functional profiles in instance |
|
_setPropertyValue(instance, OM_FUNCTIONALPROFILESSUPPORTED, profiles); |
|
|
|
_setPropertyValue(instance, OM_FUNCTIONALPROFILEDESCRIPTIONS, profileDescriptions); |
|
|
|
// Multiple OperationsSupported Property |
|
_setPropertyValue(instance, OM_MULTIPLEOPERATIONSSUPPORTED, false); |
|
|
|
// AuthenticationMechanismsSupported Property |
|
Array<Uint16> authentications; |
|
Array<String> authenticationDescriptions; |
|
|
|
authentications.append(3); authenticationDescriptions.append("Basic"); |
|
|
|
_setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMSSUPPORTED, authentications); |
|
|
|
_setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMDESCRIPTIONS, authenticationDescriptions); |
|
|
|
_setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion); |
|
|
|
_setPropertyValue(instance, "namespaceType", namespaceType); |
|
|
|
_setPropertyValue(instance, "IPAddress", IPAddress); |
|
|
|
PEG_METHOD_EXIT(); |
|
return(instance); |
|
} | } |
| |
Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism( |
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT |
const Boolean includeQualifiers, |
case PG_ELEMENTCAPABILITIES: |
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
instances = enumElementCapabilityInstances(context); |
"InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism"); |
break; |
|
} |
// This is a temporary hack to get the multiple connections. |
case PG_HOSTEDINDICATIONSERVICE: |
ConfigManager* configManager = ConfigManager::getInstance(); |
|
Boolean enableHttpConnection = String::equal( |
|
configManager->getCurrentValue("enableHttpConnection"), "true"); |
|
Boolean enableHttpsConnection = String::equal( |
|
configManager->getCurrentValue("enableHttpsConnection"), "true"); |
|
|
|
String IPAddress = _getHostAddress(System::getHostName()); |
|
Array<CIMInstance> instances; |
|
|
|
if (enableHttpConnection) |
|
{ | { |
CDEBUG("building pgcimxmlinstances 1"); |
instances = enumHostedIndicationServiceInstances(context); |
CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism( |
break; |
"http", IPAddress, |
|
includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
|
instances.append(instance); |
|
} | } |
|
case PG_SERVICEAFFECTSELEMENT: |
if (enableHttpsConnection) |
|
{ | { |
CDEBUG("building pgcimxmlinstances 2"); |
instances = enumServiceAffectsElementInstances(context); |
CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism( |
break; |
"https", IPAddress, |
|
includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
|
instances.append(instance); |
|
} | } |
|
#endif |
|
default: |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instances); |
throw CIMNotSupportedException(className.getString() + |
|
" not supported by Interop Provider enumerate"); |
} | } |
/* 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::_getInstanceCIMObjectManager( |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
| |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
// Filter and deliver the resulting instances |
"InteropProvider::_getInstanceCIMObjectManager"); |
for (Uint32 i = 0 ; i < instances.size() ; i++) |
// If there is already an instance of this class local use it. |
|
if (!instanceOfCIMObjectManager.isUninitialized()) |
|
{ | { |
PEG_METHOD_EXIT(); |
normalizeInstance(instances[i], ref, false, |
return(true); |
false, propertyList); |
} | } |
// Try to get persistent instance from repository |
|
Array<CIMInstance> instances; |
|
try |
|
{ |
|
instances = _repository->enumerateInstances(_operationNamespace, |
|
CIM_OBJECTMANAGER_CLASSNAME, true, false, includeQualifiers, |
|
includeClassOrigin, propertyList); |
|
| |
CDEBUG("_buildInstanceCIMOBJMGR Found Instance in repository " << instances.size() ); |
PEG_METHOD_EXIT(); |
|
return instances; |
|
} |
| |
if (instances.size() >= 1) |
// |
|
// Class that determines whether or not the origin class in an association |
|
// operation is valid for the given association class, and also determines |
|
// the origin and target "roles". These values generally correspond to the |
|
// role and resultRole parameter of an associators/associatorNames operation. |
|
// |
|
bool InteropProvider::validAssocClassForObject( |
|
const OperationContext & context, |
|
const CIMName & assocClass, |
|
const CIMObjectPath & objectName, |
|
const CIMNamespaceName & opNamespace, |
|
String & originProperty, |
|
String & targetProperty) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::validAssocClassForObject()"); |
|
TARGET_CLASS assocClassEnum = translateClassInput(assocClass); |
|
TARGET_CLASS originClassEnum = NOCLASS; |
|
CIMName originClass = objectName.getClassName(); |
|
// If the association class is PG_ElementConformsToProfile, we'll have to |
|
// do some special processing in case the origin instance for the operation |
|
// is managed by another provider. |
|
if(assocClassEnum == PG_ELEMENTCONFORMSTOPROFILE) |
{ | { |
// set this instance into global variable. |
// Test if the origin is an element managed by another provider |
instanceOfCIMObjectManager = instances[0]; |
// that has implemented a registered profile. |
|
if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP || |
|
(originClass != PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE && |
|
originClass != PEGASUS_CLASSNAME_PG_OBJECTMANAGER )) |
|
{ |
|
// |
|
// Search the cached conformingElements list for the originClass, |
|
// returning false if it is not found |
|
// |
|
bool found = false; |
| |
// log entry if there is more than one instance. |
PEGASUS_ASSERT(conformingElements.size() == |
// Some day we may support multiple entries to see other CIMOMs but |
elementNamespaces.size()); |
// for now this should be illegal and represent an internal error. |
for(Uint32 i = 0, n = conformingElements.size(); i < n; ++i) |
// but we will still continue to use the first entry. |
{ |
if (instances.size() > 1) |
CIMNameArray & elementList = conformingElements[i]; |
|
CIMNamespaceArray & namespaceList = elementNamespaces[i]; |
|
PEGASUS_ASSERT(elementList.size() == namespaceList.size()); |
|
for(Uint32 j = 0, m = elementList.size(); j < m; ++j) |
{ | { |
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
CIMName & curElement = elementList[j]; |
"Error. Multiple definitons of : $0", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
if((curElement == originClass || |
|
curElement.getString().find(PEGASUS_DYNAMIC) == 0) && |
|
opNamespace == namespaceList[j]) |
|
{ |
|
found = true; |
|
break; |
} | } |
return(true); |
|
} | } |
else |
if(found) |
return(false); |
break; |
} | } |
catch(CIMException& e) |
|
|
if(!found) |
{ | { |
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 e; |
return false; |
} | } |
catch(Exception& e) |
|
{ |
|
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
|
PEG_METHOD_EXIT(); |
|
throw e; |
|
} | } |
} | } |
|
else |
|
|
/** build an instance of the CIM_ObjectManager class filling out |
|
the required properties |
|
@param includeQualifiers Boolean |
|
@param includeClassOrigin Boolean |
|
@param propertylist CIMPropertyList |
|
@return CIMInstance with a single built instance of the class |
|
@exception repository instances if exception to enumerateInstances |
|
for this class. |
|
*/ |
|
CIMInstance InteropProvider::_buildInstanceCIMObjectManager( |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_buildInstanceCIMObjectManager"); |
|
|
|
// Try to get the current object. If true then it is already created. |
|
if (_getInstanceCIMObjectManager(includeQualifiers,includeClassOrigin,propertyList)) |
|
{ | { |
PEG_METHOD_EXIT(); |
// Otherwise, just get the enum value representing the origin class |
return(instanceOfCIMObjectManager); |
// for this operation |
|
originClassEnum = translateClassInput(originClass); |
} | } |
// |
|
// No instance in the repository. Build new instance and save it. |
|
// |
|
CIMInstance instance = _buildInstanceSkeleton(CIM_OBJECTMANAGER_CLASSNAME); |
|
|
|
_fixInstanceCommonKeys(instance); |
|
| |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,CIM_OBJECTMANAGER_CLASSNAME.getString()); |
CIMName expectedTargetRole; |
|
CIMName expectedOriginRole; |
| |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME,buildObjectManagerName()); |
Array<CIMName> propNames; |
|
String profileName; |
_setPropertyValue(instance, CIMName("ElementName"), String("Pegasus")); |
CIMPropertyList propertyList; |
|
CIMInstance tmpInstance; |
|
Uint32 index; |
|
propNames.clear(); |
| |
// | // |
//Description property this object manager instance |
// Set the target and origin role values. Note that if these values are |
// default is Pegasus CIM_Server Version. |
// not set following the switch block, that implies that the origin class |
// Provided undocumented option to get this from the environment. |
// is not valid for the supplied association class. |
// This should probably be removed or documented. |
|
// | // |
String description; |
switch(assocClassEnum) |
char * envDescription; |
{ |
envDescription = getenv("PEGASUS_CIMOM_DESCRIPTION"); |
case PG_NAMESPACEINMANAGER: |
|
if(originClassEnum == PG_OBJECTMANAGER) |
description = (envDescription) ? |
|
envDescription : |
|
"Pegasus " + String(PEGASUS_NAME) + "Version " + String(PEGASUS_VERSION); |
|
|
|
_setPropertyValue(instance, CIMName("Description"), description); |
|
|
|
//Property GatherStatisticalData. Initially this is set to false |
|
// and can then be modified by a modify instance on the instance. |
|
|
|
Boolean gatherStatDataFlag = false; |
|
|
|
_setPropertyValue(instance, OM_GATHERSTATISTICALDATA, Boolean(gatherStatDataFlag)); |
|
|
|
// ATTN: This one is a problem KS rethink this. |
|
// the following is a temporary hack to set the value of the statistics |
|
// gathering function dynamically. We simply get the correct value |
|
// and call the internal method to set it each time this object is |
|
// built. |
|
#ifdef PEGASUS_HAS_PERFINST |
|
StatisticalData* sd = StatisticalData::current(); |
|
sd->setCopyGSD(gatherStatDataFlag); |
|
#endif |
|
|
|
// write the instance to the repository |
|
CIMObjectPath instancePath; |
|
// Add the instance path to this if necessary ATTN ATTN: |
|
try |
|
{ | { |
instancePath = _repository->createInstance(_operationNamespace, |
expectedTargetRole = PROPERTY_DEPENDENT; |
instance ); |
expectedOriginRole = PROPERTY_ANTECEDENT; |
} | } |
catch(CIMException& e) |
else if(originClassEnum == PG_NAMESPACE) |
{ | { |
// ATTN: KS generate log error if this not possible |
expectedTargetRole = PROPERTY_ANTECEDENT; |
PEG_METHOD_EXIT(); |
expectedOriginRole = PROPERTY_DEPENDENT; |
throw e; |
|
} | } |
catch(Exception& e) |
break; |
|
case PG_COMMMECHANISMFORMANAGER: |
|
if(originClassEnum == PG_OBJECTMANAGER) |
{ | { |
// ATTN: Generate log error. |
expectedTargetRole = PROPERTY_DEPENDENT; |
PEG_METHOD_EXIT(); |
expectedOriginRole = PROPERTY_ANTECEDENT; |
throw e; |
|
} | } |
instance.setPath(instancePath); |
else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
CDEBUG("CIMObjectMgr path = " << instancePath.toString()); |
{ |
// Save this instance for other requests |
expectedTargetRole = PROPERTY_ANTECEDENT; |
instanceOfCIMObjectManager = instance; |
expectedOriginRole = PROPERTY_DEPENDENT; |
PEG_METHOD_EXIT(); |
|
return(instanceOfCIMObjectManager); |
|
} | } |
|
break; |
/** Get the instances of CIM_Namespace. Gets all instances of the namespace from |
case PG_ELEMENTCONFORMSTOPROFILE: |
the repository namespace management functions |
if(originClass.equal(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE)) |
Pegasus 2.4 - This now gets CIM_Namespace and its subclass PG_Namespace |
|
*/ |
|
Array<CIMInstance> InteropProvider::_getInstancesCIMNamespace(const Boolean& includeQualifiers, |
|
const Boolean& includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
expectedTargetRole = |
"InteropProvider::_getInstancesCIMNamespace()"); |
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
expectedOriginRole = |
CDEBUG("_getinstancesPGNamespace"); |
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces(); |
} |
CDEBUG("_getInstancesCIMNamespace. count = " << namespaceNames.size()); |
else |
Array<CIMInstance> instanceArray; |
{ |
|
expectedTargetRole = |
// We build instances of PG namespace since that is the leaf class |
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
for (Uint32 i = 0; i < namespaceNames.size(); i++) |
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
} |
|
break; |
|
case PG_ELEMENTCONFORMSTOPROFILE_RP_RP: |
|
propNames.append(CIMName("RegisteredName")); |
|
propertyList = CIMPropertyList(propNames); |
|
try |
{ | { |
instanceArray.append( _buildInstancePGNamespace(namespaceNames[i])); |
tmpInstance = localGetInstance( |
|
context, |
|
objectName, |
|
propertyList); |
} | } |
CDEBUG("Build this many PG_Namespace Instances. count= " << instanceArray.size()); |
catch (CIMException &e) |
PEG_METHOD_EXIT(); |
{ |
return(instanceArray); |
PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL2, |
|
"CIMException while getting instance of Registered Profile " |
|
": %s", |
|
(const char*)e.getMessage().getCString())); |
} | } |
|
if (!tmpInstance.isUninitialized()) |
/** get the instance of namespace defined by the input parameter which is the object path |
|
for the instance required. |
|
ATTN: Note that this is incorrect. We are supplying the namespace name and need to supply |
|
the objectpath |
|
@param TBD |
|
@return CIMInstance with the found instance or CIMInstance() if nothing found. |
|
*/ |
|
CIMInstance InteropProvider::_getInstanceCIMNamespace(const CIMNamespaceName & nameSpace) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
index = tmpInstance.findProperty("RegisteredName"); |
"InteropProvider::_getInstancesCIMNamespace()"); |
if (index != PEG_NOT_FOUND) |
|
|
CDEBUG("_getinstanceCIMNamespace Gets ONE only from Namespace=" << nameSpace.getString()); |
|
Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList()); |
|
|
|
// search the instances for one with the name property value = input parameter. |
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
|
{ | { |
if (_getPropertyValue(instances[i], CIMName("name"), String::EMPTY) == nameSpace.getString()) |
const CIMValue &tmpVal = |
|
tmpInstance.getProperty(index).getValue(); |
|
if (!tmpVal.isNull()) |
{ | { |
PEG_METHOD_EXIT(); |
tmpVal.get(profileName); |
return(instances[i]); |
|
} | } |
} | } |
PEG_METHOD_EXIT(); |
|
CIMInstance nullInstance; |
|
return(nullInstance); |
|
} | } |
|
if (String::compareNoCase(profileName, String("SMI-S")) == 0) |
CIMObjectPath InteropProvider::_buildReference(const CIMInstance& instance, const CIMName& className) |
|
{ | { |
return(_buildObjectPath(_operationNamespace,className, instance)); |
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
} | } |
|
else |
Array<CIMInstance> InteropProvider::_buildInstancesNamespaceInManager() |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_buildInstancesNamespaceInManager"); |
|
|
|
Array<CIMInstance> namespaceInstances = _getInstancesCIMNamespace(false, |
|
false, CIMPropertyList()); |
|
|
|
CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList()); |
|
|
|
CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME); |
|
|
|
Array<CIMInstance> assocInstances; |
|
|
|
for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++) |
|
{ | { |
CIMInstance instance = _buildInstanceSkeleton(CIM_NAMESPACEINMANAGER_CLASSNAME); |
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
_setPropertyValue(instance, CIMName("Antecdent"), refObjMgr); |
expectedOriginRole = |
//ATTNATTN: this is weak qualifier. |
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
_setPropertyValue(instance, CIMName("Dependent"), _buildReference(namespaceInstances[i], |
|
CIM_NAMESPACEINMANAGER_CLASSNAME)); |
|
assocInstances.append(instance); |
|
} | } |
|
break; |
PEG_METHOD_EXIT(); |
case PG_SUBPROFILEREQUIRESPROFILE: |
return(assocInstances); |
if(originClassEnum == PG_REGISTEREDPROFILE) |
|
{ |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
|
expectedOriginRole = PROPERTY_ANTECEDENT; |
} | } |
|
else if(originClassEnum == PG_REGISTEREDSUBPROFILE) |
Array<CIMInstance> InteropProvider::_buildInstancesCommMechanismForManager() |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
expectedTargetRole = PROPERTY_ANTECEDENT; |
"InteropProvider::_buildInstancesCommMechanismForManager"); |
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
Array<CIMInstance> commInstances = _buildInstancesPGCIMXMLCommunicationMechanism(true, |
break; |
true, CIMPropertyList()); |
case PG_REFERENCEDPROFILE: |
|
if (originClassEnum == PG_REGISTEREDSUBPROFILE) |
CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList()); |
|
|
|
CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME); |
|
Array<CIMInstance> assocInstances; |
|
|
|
for (Uint32 i = 0 ; i < commInstances.size() ; i++) |
|
{ | { |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
CIMInstance instance = _buildInstanceSkeleton(CIM_COMMMECHANISMFORMANAGER_CLASSNAME); |
expectedOriginRole = PROPERTY_DEPENDENT; |
|
|
_setPropertyValue(instance,CIMName("Antecdent"), refObjMgr); |
|
//ATTNATTN: this is weak qualifier. |
|
_setPropertyValue(instance,CIMName("Dependent"), _buildReference(commInstances[i],CIM_COMMMECHANISMFORMANAGER_CLASSNAME)); |
|
assocInstances.append(instance); |
|
} | } |
|
else if (originClassEnum == PG_REGISTEREDPROFILE) |
PEG_METHOD_EXIT(); |
{ |
return(assocInstances); |
if ((targetProperty.size() != 0) && |
|
(originProperty.size() != 0) && |
|
String::equalNoCase(targetProperty, originProperty)) |
|
{ |
|
return false; |
} | } |
|
if (targetProperty.size() != 0) |
/* generate one instance of the CIM_Namespace class with the |
|
properties |
|
NOTE: CIM 2.4 - Changed to build PG namespace |
|
@param namespace name to put into the class |
|
@exceptions - exceptions carried forward from create instance |
|
and addProperty. |
|
*/ |
|
CIMInstance InteropProvider::_buildInstancePGNamespace(const CIMNamespaceName & nameSpace) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
if (!(String::equalNoCase(targetProperty, "Antecedent") || |
"InteropProvider::_buildInstancePGNamespace"); |
String::equalNoCase(targetProperty, "Dependent") )) |
|
|
// ATTN: KS need to get the real objectManager name from elsewhere. the only place |
|
// this exists is through the objectmanager object. |
|
// ATTN: Should we be saving the objectmanager name somewhere internally either in |
|
// interop or more generally somewhere within the system for common access. |
|
String ObjectManagerName = "ObjectManagerNameValue"; |
|
|
|
CIMInstance instance = _buildInstanceSkeleton(PG_NAMESPACE_CLASSNAME); |
|
|
|
_fixInstanceCommonKeys(instance); |
|
|
|
//ObjectManagerCreationClassName |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, CIM_OBJECTMANAGER_CLASSNAME.getString()); |
|
|
|
//ObjectManagerName |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, ObjectManagerName); |
|
|
|
//CreationClassName |
|
// Class in which this was created, |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, CIM_NAMESPACE_CLASSNAME.getString()); |
|
//Name |
|
// This is the namespace name itself |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, nameSpace.getString()); |
|
|
|
//ClassInfo |
|
// Set the classinfo to unknown and the description to namespace. |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0)); |
|
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO, String("namespace")); |
|
|
|
// |
|
// 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. |
|
CDEBUG("_buildPGNS Instance get namespace attributes for namespace= " << nameSpace.getString()); |
|
CIMRepository::NameSpaceAttributes attributes; |
|
_repository->getNameSpaceAttributes(nameSpace.getString(), attributes); |
|
String parent=""; |
|
String name = ""; |
|
Boolean shareable=false; |
|
Boolean updatesAllowed=true; |
|
for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++) |
|
{ |
|
String key=i.key(); |
|
String value = i.value(); |
|
CDEBUG("Show Attributes. key= " << key << " value= " << value); |
|
if (String::equalNoCase(key,"shareable")) |
|
{ | { |
if (String::equalNoCase(value,"true")) |
return false; |
shareable=true; |
|
} |
|
else if (String::equalNoCase(key,"updatesAllowed")) |
|
{ |
|
if (String::equalNoCase(value,"false")) |
|
updatesAllowed=false; |
|
} |
|
// Test to be sure we are returning proper namespace name |
|
else if (String::equalNoCase(key,"name")) |
|
{ |
|
if (!String::equalNoCase(value, nameSpace.getString())) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
// This is poor exception since it reflects internal error. Do error log |
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, |
|
"Namespace attribute rtnd error for key " + key + "expected " + |
|
nameSpace.getString()+ value + " in " + String(thisProvider)); |
|
} | } |
|
|
name = value; |
|
} | } |
else if (String::equalNoCase(key,"parent")) |
if (originProperty.size() != 0) |
{ | { |
parent=value; |
if (!(String::equalNoCase(originProperty, "Antecedent") || |
} |
String::equalNoCase(originProperty, "Dependent") )) |
else |
|
{ | { |
PEG_METHOD_EXIT(); |
return false; |
// Poor error definition since it reflects internal error. do error log |
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace.getString()+ |
|
" namespace attribute " + key + " option not supported in"+ String(thisProvider)); |
|
} |
|
} | } |
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, updatesAllowed); |
|
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable); |
|
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent); |
|
_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name); |
|
|
|
PEG_METHOD_EXIT(); |
|
return(instance); |
|
} | } |
void _validateCIMNamespaceKeys(const CIMObjectPath& objectPath) |
if (String::equalNoCase(originProperty, "Antecedent") && |
{ |
targetProperty.size() == 0) |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_validateCIMNamespaceKeys"); |
|
|
|
Boolean valid = true; |
|
CIMName propertyName; |
|
if (!_validateRequiredProperty(objectPath, |
|
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
|
System::getSystemCreationClassName ())) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
targetProperty = String("Dependent"); |
valid = false; |
|
} | } |
if (!_validateRequiredProperty(objectPath, |
if (String::equalNoCase(originProperty, "Dependent") && |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
targetProperty.size() == 0) |
System::getHostName())) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
targetProperty = String("Antecedent"); |
valid = false; |
|
} | } |
if (!_validateRequiredProperty(objectPath, |
if (String::equalNoCase(targetProperty, "Antecedent") && |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
originProperty.size() == 0) |
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
originProperty = String("Dependent"); |
valid = false; |
|
} | } |
|
if (String::equalNoCase(targetProperty, "Dependent") && |
// ATTN: This one still a problem. We have to get the name first |
originProperty.size() == 0) |
if (!_validateRequiredProperty(objectPath, |
|
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
|
String::EMPTY)) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
originProperty = String("Antecedent"); |
valid = false; |
|
} | } |
if (!_validateRequiredProperty(objectPath, |
return true; |
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
|
System::getHostName())) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME; |
|
valid = false; |
|
} | } |
|
break; |
if (!_validateRequiredProperty(objectPath, |
case PG_ELEMENTSOFTWAREIDENTITY: |
CIM_NAMESPACE_PROPERTY_NAME, |
if(originClassEnum == PG_SOFTWAREIDENTITY) |
String::EMPTY)) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_NAME; |
expectedTargetRole = PROPERTY_DEPENDENT; |
valid = false; |
expectedOriginRole = PROPERTY_ANTECEDENT; |
} | } |
|
else if(originClassEnum == PG_REGISTEREDPROFILE || |
if (false) |
originClassEnum == PG_REGISTEREDSUBPROFILE) |
{ | { |
PEG_METHOD_EXIT(); |
expectedTargetRole = PROPERTY_ANTECEDENT; |
throw CIMInvalidParameterException( |
expectedOriginRole = PROPERTY_DEPENDENT; |
"Invalid key property: " + propertyName.getString()); |
|
} |
|
PEG_METHOD_EXIT(); |
|
} | } |
|
break; |
/** completes a property in the defined instance either |
case PG_INSTALLEDSOFTWAREIDENTITY: |
by adding the complete property if it does not exist |
if(originClassEnum == PG_SOFTWAREIDENTITY) |
or by adding the value if the property does exist. |
|
Used to make sure that key properties for things |
|
like systemcreationclass are included in the |
|
creation of new instances and that the |
|
values are logical for the CIMOM. |
|
*/ |
|
Boolean _completeProperty(CIMInstance& instance, |
|
const CIMName& propertyName, |
|
const String& value) |
|
{ | { |
|
expectedTargetRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM; |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
expectedOriginRole = |
"InteropProvider::_completeProperty()"); |
INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE; |
|
|
Uint32 pos; |
|
|
|
if (!_validateRequiredProperty(instance, |
|
propertyName, |
|
value)) |
|
{ |
|
if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND) |
|
{ |
|
// Add the property. Should be from the class. |
|
PEG_METHOD_EXIT(); |
|
return(false); |
|
} | } |
else |
else if(originClassEnum == PG_COMPUTERSYSTEM) |
{ | { |
// |
expectedTargetRole = |
_setPropertyValue(instance, propertyName, value); |
INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE; |
} |
expectedOriginRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM; |
} |
|
|
|
PEG_METHOD_EXIT(); |
|
return(true); |
|
} | } |
Boolean _completeCIMNamespaceKeys(CIMInstance& instance) |
break; |
|
case PG_HOSTEDACCESSPOINT: |
|
if(originClassEnum == PG_COMPUTERSYSTEM) |
{ | { |
|
expectedTargetRole = PROPERTY_DEPENDENT; |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
expectedOriginRole = PROPERTY_ANTECEDENT; |
"InteropProvider::_completeCIMNamespaceKeys"); |
|
|
|
Boolean valid = true; |
|
CIMName propertyName; |
|
|
|
if (!_completeProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
|
System::getSystemCreationClassName ())) |
|
{ |
|
|
|
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
|
valid = false; |
|
} | } |
|
else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
if (!_completeProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
|
System::getHostName())) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
expectedTargetRole = PROPERTY_ANTECEDENT; |
valid = false; |
expectedOriginRole = PROPERTY_DEPENDENT; |
} | } |
|
case PG_HOSTEDOBJECTMANAGER: |
if (!_completeProperty(instance, |
if(originClassEnum == PG_COMPUTERSYSTEM) |
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
|
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
expectedTargetRole = PROPERTY_DEPENDENT; |
valid = false; |
expectedOriginRole = PROPERTY_ANTECEDENT; |
} | } |
|
else if(originClassEnum == PG_OBJECTMANAGER) |
if (!_completeProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
|
String::EMPTY)) |
|
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
expectedTargetRole = PROPERTY_ANTECEDENT; |
valid = false; |
expectedOriginRole = PROPERTY_DEPENDENT; |
} | } |
if (!_completeProperty(instance, |
break; |
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT |
System::getHostName())) |
case PG_HOSTEDINDICATIONSERVICE: |
|
if(originClassEnum == PG_COMPUTERSYSTEM) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME; |
expectedTargetRole = PROPERTY_DEPENDENT; |
valid = false; |
expectedOriginRole = PROPERTY_ANTECEDENT; |
} | } |
|
break; |
if (!_completeProperty(instance, |
#endif |
CIM_NAMESPACE_PROPERTY_NAME, |
default: |
String::EMPTY)) |
break; |
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_NAME; |
|
valid = false; |
|
} | } |
| |
if (!valid) |
// |
|
// The rest of this method checks to see if target role and origin roles |
|
// were found for the association and origin class combination and, if |
|
// found, checks against the input target and origin roles if provided. |
|
// Failure for any of these tests points to an invalid association |
|
// traversal request. |
|
// |
|
if(expectedTargetRole.isNull() || |
|
expectedOriginRole.isNull()) |
{ | { |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"Invalid CIM_Namespace Key Property " + propertyName.getString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw CIMInvalidParameterException( |
return false; |
"Invalid CIM_Namespace key property: " + propertyName.getString()); |
|
} |
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid"); |
|
PEG_METHOD_EXIT(); |
|
return(valid); |
|
} |
|
|
|
|
|
void _validateCIMNamespaceKeys(const CIMInstance& instance) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_validateCIMNamespaceKeys"); |
|
Boolean valid = true; |
|
CIMName propertyName; |
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
|
System::getSystemCreationClassName ())) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
|
valid = false; |
|
} |
|
|
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
|
System::getHostName())) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
|
valid = false; |
|
} |
|
|
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, |
|
CIM_OBJECTMANAGER_CLASSNAME.getString())) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME; |
|
valid = false; |
|
} |
|
|
|
// ATTN: This one still a problem. We have to get the name first |
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, |
|
String::EMPTY)) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME; |
|
valid = false; |
|
} |
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, |
|
System::getHostName())) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME; |
|
valid = false; |
|
} |
|
|
|
if (!_validateRequiredProperty(instance, |
|
CIM_NAMESPACE_PROPERTY_NAME, |
|
String::EMPTY)) |
|
{ |
|
propertyName = CIM_NAMESPACE_PROPERTY_NAME; |
|
valid = false; |
|
} | } |
| |
if (false) |
if(targetProperty.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
targetProperty = expectedTargetRole.getString(); |
"Invalid CIM_Namespace Key Property " + propertyName.getString()); |
|
PEG_METHOD_EXIT(); |
|
throw CIMInvalidParameterException( |
|
"Invalid CIM_Namespace key property: " + propertyName.getString()); |
|
} |
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid"); |
|
PEG_METHOD_EXIT(); |
|
} | } |
|
else if(!expectedTargetRole.equal(targetProperty)) |
/** 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(); | PEG_METHOD_EXIT(); |
return(objectPath); |
return false; |
} | } |
| |
/* Given a class and instance build the instance path for a |
if(originProperty.size() == 0) |
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, |
originProperty = expectedOriginRole.getString(); |
"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); |
|
} | } |
|
else if(!expectedOriginRole.equal(originProperty)) |
/* _isNamespace determines if the namespace in the second |
|
parameter is in the array in the first parameter. |
|
@param array of possible namespaces |
|
@param canidate namespace |
|
@return - true if found |
|
*/ |
|
Boolean _isNamespace( |
|
Array<CIMNamespaceName>& namespaceNames, |
|
CIMNamespaceName& namespaceName) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_isNamespace"); |
|
|
|
Boolean found = false; |
|
for(Uint32 i = 0; i < namespaceNames.size(); i++) |
|
{ |
|
if(namespaceNames[i].equal ( namespaceName )) |
|
return true; |
|
} |
|
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
| |
//************************************************************** |
PEG_METHOD_EXIT(); |
// Overloaded functions to get key value with different params |
return true; |
//************************************************************** |
|
|
|
/* find the name key in the keybindings and return the value. |
|
Executes exception if the key not found |
|
@param object path we will search |
|
@param keyName - Name of the key to find. |
|
@return value of name property |
|
@exceptions CIMInvalidParameterException |
|
*/ |
|
String _getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName) |
|
{ |
|
Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); |
|
|
|
// find the correct key binding |
|
for (Uint32 i = 0; i < kbArray.size(); i++) |
|
{ |
|
if (kbArray[i].getName() == keyName) |
|
return (kbArray[i].getValue()); |
|
} |
|
|
|
throw CIMInvalidParameterException("Invalid key property: " + keyName.getString()); |
|
} |
|
|
|
String _getKeyValue(const CIMInstance& instance, const CIMName& keyName) |
|
{ |
|
Uint32 pos; |
|
CIMValue propertyValue; |
|
|
|
pos = instance.findProperty(keyName); |
|
if (pos == PEG_NOT_FOUND) |
|
throw CIMPropertyNotFoundException |
|
(NAMESPACE_PROPERTYNAME.getString()); |
|
|
|
propertyValue = instance.getProperty(pos).getValue(); |
|
if (propertyValue.getType() != CIMTYPE_STRING) |
|
throw CIMInvalidParameterException("Invalid type for property: " |
|
+ NAMESPACE_PROPERTYNAME.getString()); |
|
String name; |
|
propertyValue.get(name); |
|
return(name); |
|
//ATTN: KS Returns String whereas below returns CIMNamespaceName. |
|
} | } |
| |
//*************************************************************************** |
// |
// The following section is the Instance Operation processors |
// Local version of the references operation. It validates the input |
//*************************************************************************** |
// parameters, setting the origin and target property values if not set |
// createInstance |
// already, and then performs an enumeration on the association class. It then |
//*************************************************************************** |
// filters the results of that enumeration to see if one of the reference |
void InteropProvider::createInstance( |
// properties matches the objectName parameter passed into the method. If so, |
|
// then it is added to the array of association instances to be returned. |
|
// |
|
Array<CIMInstance> InteropProvider::localReferences( |
const OperationContext & context, | const OperationContext & context, |
const CIMObjectPath & instanceReference, |
const CIMObjectPath & objectName, |
const CIMInstance& myInstance, |
const CIMName & assocClass, |
ObjectPathResponseHandler & handler) |
String & originProperty, |
|
String & targetProperty, |
|
const CIMPropertyList & propertyList, |
|
const CIMName & targetClass) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()"); |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::localReferences()"); |
handler.processing(); |
|
CIMNamespaceName newNamespaceName; |
|
CDEBUG("CreateInstance " << instanceReference.toString()); |
|
// operation namespace needed internally to get class. |
|
_operationNamespace = instanceReference.getNameSpace(); |
|
|
|
// Verify that ClassName is correct and get value |
|
targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
CIMObjectPath newInstanceReference; |
|
| |
if ((classEnum == CIM_OBJECTMANAGER) || |
Array<CIMInstance> instances; |
(classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)) |
CIMName originClass = objectName.getClassName(); |
throw CIMNotSupportedException("InteropProvider, Create Not allowed"); |
|
| |
if (classEnum == PG_NAMESPACE) |
Array<CIMName> targetSubclasses; |
|
CIMNamespaceName lastTargetNamespace; |
|
CIMNamespaceName originNamespace(objectName.getNameSpace()); |
|
|
|
// Check that the association traversal request is valid |
|
if (validAssocClassForObject( |
|
context, |
|
assocClass, |
|
objectName, |
|
originNamespace, |
|
originProperty, |
|
targetProperty)) |
|
{ |
|
// retrieve all of the association class instances |
|
Array<CIMInstance> localInstances = localEnumerateInstances(context, |
|
CIMObjectPath(hostName, originNamespace, |
|
assocClass)); |
|
// Filter the association class instances based on the origin instance |
|
// and other input parameters. |
|
for(Uint32 i = 0, n = localInstances.size(); i < n; ++i) |
|
{ |
|
CIMInstance & currentInstance = localInstances[i]; |
|
CIMObjectPath originPath = getRequiredValue<CIMObjectPath>( |
|
currentInstance, originProperty); |
|
originPath.setNameSpace(objectName.getNameSpace()); |
|
originPath.setHost(objectName.getHost()); |
|
// Only include instances where the origin instance is present in |
|
// the association. |
|
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); |
|
|
|
CIMNamespaceName targetNamespace( |
|
targetPath.getNameSpace()); |
|
if(targetNamespace.isNull()) |
{ | { |
// Create local instance to complete any keys. |
targetNamespace = originNamespace; |
CIMInstance localInstance = myInstance.clone(); |
targetPath.setNameSpace(targetNamespace); |
|
|
_completeCIMNamespaceKeys(localInstance); |
|
// Validate that keys are as required. Does its own exception. |
|
newNamespaceName = _getKeyValue(myInstance, CIM_NAMESPACE_PROPERTY_NAME); |
|
|
|
newInstanceReference = _buildInstancePath(_operationNamespace, |
|
PG_NAMESPACE_CLASSNAME, localInstance); |
|
} | } |
|
if(targetNamespace != lastTargetNamespace) |
else // Invalid class for the create functions. |
|
{ | { |
PEGASUS_ASSERT(false); |
|
} |
|
|
|
// Create the new namespace |
|
try | try |
{ | { |
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
targetSubclasses = repository->enumerateClassNames( |
"Namespace = " + newNamespaceName.getString() + |
targetNamespace, targetClass, true); |
" to be created."); |
|
Boolean updatesAllowed = false; |
|
Boolean shareable = false; |
|
String parent = String::EMPTY; |
|
|
|
CIMRepository::NameSpaceAttributes attributes; |
|
// optional property. Set false if not found. |
|
// ATTN: Should set to class default. |
|
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_ISSHAREABLE) != PEG_NOT_FOUND) |
|
{ |
|
if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, false)) |
|
{ |
|
attributes.insert("shareable","true"); |
|
shareable = true; |
|
} |
|
else |
|
attributes.insert("shareable", "false"); |
|
} |
|
else |
|
attributes.insert("shareable", "false"); |
|
|
|
// Optional property. Set false if not found. |
|
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED) != PEG_NOT_FOUND) |
|
{ |
|
if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false)) |
|
{ |
|
attributes.insert("updatesAllowed","true"); |
|
updatesAllowed = true; |
|
} | } |
else |
catch(...) |
attributes.insert("updatesAllowed", "false"); |
|
} |
|
else |
|
attributes.insert("updatesAllowed", "false"); |
|
|
|
// ATTN: Need to reflect and dependencies between these properties. Right now |
|
// this lets anything happen. |
|
if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_PARENTNAMESPACE) != PEG_NOT_FOUND) |
|
{ |
|
String parent = _getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY); |
|
if (parent != String::EMPTY) |
|
attributes.insert("parent",parent); |
|
} |
|
_repository->createNameSpace(newNamespaceName, attributes); |
|
|
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"Namespace = " + newNamespaceName.getString() + |
|
" successfully created."); |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Create Namespace: Shareable = $0, Updates allows: $1, Parent: $2", |
|
newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent ); |
|
|
|
} |
|
catch(CIMException& e) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw e; |
|
} |
|
catch(Exception& e) |
|
{ | { |
PEG_METHOD_EXIT(); |
// If an exception was thrown during enumeration, |
throw e; |
// then the base class didn't exist in the |
|
// namespace, so the target instance retrieved |
|
// must not match the targetClass parameter. |
|
continue; |
} | } |
|
targetSubclasses.append(targetClass); |
// begin processing the request |
lastTargetNamespace = targetNamespace; |
|
|
handler.deliver(newInstanceReference); |
|
|
|
// complete processing the request |
|
handler.complete(); |
|
|
|
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
| |
//*************************************************************************** |
// Try to find the targetPath's class in the search space |
// deleteInstance |
CIMName targetPathClass = targetPath.getClassName(); |
//*************************************************************************** |
for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j) |
void InteropProvider::deleteInstance( |
|
const OperationContext & context, |
|
const CIMObjectPath & instanceName, |
|
ResponseHandler & handler) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance"); |
if(targetPathClass == targetSubclasses[j]) |
|
|
CIMNamespaceName childNamespaceName; |
|
CIMNamespaceName deleteNamespaceName; |
|
|
|
_operationNamespace = instanceName.getNameSpace(); |
|
handler.processing(); |
|
// Verify that ClassName is correct and get value |
|
targetClass classEnum = _verifyValidClassInput(instanceName.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
|
|
|
|
if ((classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)) |
|
throw CIMNotSupportedException("Delete Not allowed"); |
|
|
|
// Delete the instance since it may be in persistent storage |
|
if ((classEnum == CIM_OBJECTMANAGER)) |
|
{ | { |
CIMInstance instance; |
instances.append(currentInstance); |
try |
break; |
{ |
|
instance = _repository->getInstance(_operationNamespace, instanceName); |
|
|
|
// If instance found, then delete it. |
|
_repository->deleteInstance(_operationNamespace,instanceName); |
|
|
|
PEG_METHOD_EXIT(); |
|
handler.complete(); |
|
return; |
|
} | } |
catch(CIMException& e) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw e; |
|
} | } |
} | } |
|
else |
Array<CIMNamespaceName> namespaceNames; |
|
namespaceNames = _enumerateNameSpaces(); |
|
if (classEnum == PG_NAMESPACE) |
|
{ | { |
// validate requred keys. Exception out if not valid |
instances.append(currentInstance); |
_validateCIMNamespaceKeys(instanceName); |
|
|
|
deleteNamespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); |
|
CDEBUG("Delete namespace = " << deleteNamespaceName ); |
|
} | } |
|
|
// ATTN: KS Why THis??? |
|
if (deleteNamespaceName.equal (ROOTNS)) |
|
{ |
|
throw CIMNotSupportedException("root namespace cannot be deleted."); |
|
} | } |
|
|
_repository->deleteNameSpace(deleteNamespaceName); |
|
|
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"Namespace = " + deleteNamespaceName.getString() + |
|
" successfully deleted."); |
|
|
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Interop Provider Delete Namespace: $0", |
|
deleteNamespaceName.getString()); |
|
|
|
handler.processing(); |
|
|
|
// complete processing the request |
|
handler.complete(); |
|
|
|
PEG_METHOD_EXIT(); |
|
return ; |
|
} | } |
|
|
//*************************************************************************** |
|
// getInstance |
|
//*************************************************************************** |
|
void InteropProvider::getInstance( |
|
const OperationContext & context, |
|
const CIMObjectPath & instanceName, |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList & propertyList, |
|
InstanceResponseHandler & handler) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::getInstance"); |
|
|
|
// Verify that ClassName is correct and get value |
|
targetClass classEnum = _verifyValidClassInput(instanceName.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
|
|
// begin processing the request |
|
handler.processing(); |
|
if (classEnum == CIM_OBJECTMANAGER) |
|
{ |
|
CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers, |
|
includeClassOrigin, propertyList); |
|
handler.deliver(instance); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
| |
if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ |
|
// ATTN: test for correct instance KS: Priority 1 |
|
Array <CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism( |
|
includeQualifiers, |
|
includeClassOrigin, propertyList); |
|
handler.deliver(instances[0]); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return; |
return instances; |
} | } |
| |
// 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. |
|
// get the namespace from the name value. |
|
// should check the other keys to see if valid. |
|
CIMNamespaceName namespaceName; |
|
namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); |
|
|
|
// ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); |
|
if (!_isNamespace(namespaceNames, namespaceName)) |
|
{ |
|
throw CIMObjectNotFoundException("Namespace does not exist: " |
|
+ namespaceName.getString()); |
|
} |
|
PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
|
"Namespace = " + namespaceName.getString() + " successfully found."); |
|
| |
instance = _getInstanceCIMNamespace(namespaceName); |
// |
} |
// Builds an instance of the class named className. Gets Class defintion and |
else // processing for __Namespace |
// fills in the correct properties from the class. This requires a repository |
|
// getClass request for each instance built. The skeleton is built by |
|
// creating the instance and copying qualifiers and properties from |
|
// the class. Finally the instance is cloned to separate it from the |
|
// original objects. |
|
// NOTE: This is very inefficient for anything larger than a few instances. |
|
// We should separate the get from the createSkeleton. |
|
// @param className CIMName of the class for which the instance is to be built |
|
// @return CIMInstance of this class with properties complete. |
|
// @exception passes on any exceptions received from the repository request. |
|
// |
|
CIMInstance InteropProvider::buildInstanceSkeleton( |
|
const CIMNamespaceName & nameSpace, |
|
const CIMName& className, |
|
Boolean includeQualifiers, |
|
CIMClass& returnedClass) |
{ | { |
PEGASUS_ASSERT(false); |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
} |
"InteropProvider::_buildInstanceSkeleton()"); |
|
// get class with lo = false, qualifier = true classorig = true |
handler.deliver(instance); |
returnedClass = repository->getClass(nameSpace, |
|
className, false, true, true); |
// complete processing the request |
CIMInstance skeleton = returnedClass.buildInstance( |
handler.complete(); |
includeQualifiers, true, CIMPropertyList()); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return ; |
return skeleton; |
} | } |
| |
//*************************************************************************** |
|
// enumerateInstances |
|
//*************************************************************************** |
|
void InteropProvider::enumerateInstances( |
|
const OperationContext & context, |
|
const CIMObjectPath & ref, |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList, |
|
InstanceResponseHandler & handler) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()"); |
|
// Verify that ClassName is correct and get value |
|
|
|
targetClass classEnum = _verifyValidClassInput(ref.getClassName()); |
|
|
|
// operation namespace needed internally to get class. |
|
_operationNamespace = ref.getNameSpace(); |
|
//String userName = _validateUserID(context); |
|
| |
// The following 3 classes deliver a single instance because |
CIMInstance InteropProvider::buildDependencyInstance( |
// that is all there is today. |
const String & antecedentId, |
if (classEnum == CIM_OBJECTMANAGER) |
const CIMName & antecedentClass, |
|
const String & dependentId, |
|
const CIMName & dependentClass, |
|
const CIMClass & dependencyClass) |
{ | { |
CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers, |
Array<CIMKeyBinding> dependentKeys; |
includeClassOrigin, |
|
propertyList); |
|
| |
//Array<Sint8> tmp; |
dependentKeys.append(CIMKeyBinding( |
///XmlWriter::appendInstanceElement(tmp, instance); |
COMMON_PROPERTY_INSTANCEID, |
//tmp.append('\0'); |
dependentId,CIMKeyBinding::STRING)); |
//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; |
|
} |
|
| |
if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
return buildDependencyInstanceFromPaths( |
{ |
buildDependencyReference(hostName, antecedentId, antecedentClass), |
Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(includeQualifiers, |
buildDependencyReference(hostName, dependentId, dependentClass), |
includeClassOrigin, propertyList); |
dependencyClass); |
CDEBUG("Build instances of PGCIMXML. count= " << instances.size()); |
|
handler.deliver(instances); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
| |
|
void InteropProvider::initProvider() |
if (classEnum == PG_NAMESPACE) |
|
{ | { |
Array<CIMInstance> instances = _getInstancesCIMNamespace(includeQualifiers, |
if(providerInitialized) |
includeClassOrigin, propertyList); |
|
|
|
handler.deliver(instances); |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; | return; |
} |
// Placed METHOD_ENTER trace statement after checking whether the |
|
// provider is initialized because this method will be called for every |
handler.complete(); |
// operation through the InteropProvider, and this method is only |
|
// interesting the first time it is successfully run. |
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void InteropProvider::modifyObjectManagerInstance(const OperationContext & context, |
|
const CIMObjectPath & instanceReference, |
|
const CIMInstance& modifiedIns, |
|
const Boolean includeQualifiers, |
|
const CIMPropertyList& propertyList, |
|
ResponseHandler & handler) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::modifyInstanceManagerInstance"); |
"InteropProvider::initProvider()"); |
// the only allowed modification is this one property, statistical data |
|
if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) |
|
{ |
|
// ATTN: This function is a design problem. |
|
// ATTN: Should the ifdef include everything???? |
|
// the following is a temporary hack to set the value of the statistics |
|
// gathering function dynamically. We simply get the value from input |
|
// and call the internal method to set it each time this object is |
|
// built. |
|
#ifdef PEGASUS_HAS_PERFINST |
|
StatisticalData* sd = StatisticalData::current(); |
|
Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); |
|
sd->setCopyGSD(statisticsFlag); |
|
if ( ! _getInstanceCIMObjectManager(false, false, CIMPropertyList())) |
|
{ |
|
_buildInstanceCIMObjectManager(true, true, CIMPropertyList()); |
|
} |
|
| |
// ATTN: Think we need to clone here to avoid any issues of overwriting. |
AutoMutex lock(interopMut); |
_setPropertyValue(instanceOfCIMObjectManager, OM_GATHERSTATISTICALDATA, statisticsFlag); |
if(!providerInitialized) |
CIMObjectPath instancePath; |
|
|
|
// Modify the object on disk |
|
try |
|
{ |
|
_repository->modifyInstance(_operationNamespace, |
|
instanceOfCIMObjectManager ); |
|
} |
|
catch(CIMException& e) |
|
{ |
|
// ATTN: KS generate log error if this not possible |
|
PEG_METHOD_EXIT(); |
|
throw e; |
|
} |
|
catch(Exception& e) |
|
{ | { |
// ATTN: Generate log error. |
// |
PEG_METHOD_EXIT(); |
// Initialize the object manager instance for the CIM Server, and |
throw e; |
// retrieve the object manager's name property. This is retrieved once |
} |
// and stored for use in constructing other instances requiring its |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
// value. |
"Interop Provider Set Statistics gathering in CIM_ObjectManager: $0", |
// |
(statisticsFlag? "true" : "false")); |
CIMInstance objectManager = getObjectManagerInstance(); |
// modify returns nothing normally. |
objectManager.getProperty(objectManager.findProperty( |
return; |
OM_PROPERTY_NAME)).getValue().get(objectManagerName); |
#endif |
|
| |
} |
// |
PEG_METHOD_EXIT(); |
// Determine whether the CIMOM should be gathering statistical data |
// ATTN Expand this defintion to be more precise since it allows only mod of |
// based on the GatherStatisticalData property in the object manager. |
// one property and that property MUST be in the instance to be modifiable. |
// |
throw CIMNotSupportedException |
Uint32 gatherDataIndex = objectManager.findProperty( |
(OM_GATHERSTATISTICALDATA.getString() + " modify operation not supported by Interop Provider"); |
OM_PROPERTY_GATHERSTATISTICALDATA); |
} |
if(gatherDataIndex != PEG_NOT_FOUND) |
//*************************************************************************** |
|
// modifyInstance |
|
//*************************************************************************** |
|
void InteropProvider::modifyInstance(const OperationContext & context, |
|
const CIMObjectPath & instanceReference, |
|
const CIMInstance& modifiedIns, |
|
const Boolean includeQualifiers, |
|
const CIMPropertyList& propertyList, |
|
ResponseHandler & handler) |
|
{ | { |
|
CIMConstProperty gatherDataProp = |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
objectManager.getProperty(gatherDataIndex); |
"InteropProvider::modifyInstance"); |
if (gatherDataProp.getType() == CIMTYPE_BOOLEAN) |
|
|
// operation namespace needed internally to get class. |
|
|
|
// ATTN: KS 31 August 2004. This must test for privileged user. |
|
_operationNamespace = instanceReference.getNameSpace(); |
|
CIMName className = instanceReference.getClassName(); |
|
targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
// begin processing the request |
|
handler.processing(); |
|
|
|
if (classEnum == CIM_OBJECTMANAGER) |
|
{ | { |
modifyObjectManagerInstance(context, instanceReference,modifiedIns, |
CIMValue gatherDataVal = gatherDataProp.getValue(); |
includeQualifiers, propertyList, handler); |
if (!gatherDataVal.isNull()) |
// for the moment allow modification of the statistics property only |
|
} |
|
|
|
else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
|
{ | { |
|
Boolean gatherData; |
PEG_METHOD_EXIT(); |
gatherDataVal.get(gatherData); |
throw CIMNotSupportedException |
if (gatherData == true) |
(className.getString() + " not supported by Interop Provider"); |
|
} |
|
else if (classEnum == PG_NAMESPACE) |
|
{ | { |
// for the moment allow modification of the statistics property only |
StatisticalData* sd = StatisticalData::current(); |
PEG_METHOD_EXIT(); |
sd->setCopyGSD(true); |
throw CIMNotSupportedException |
|
(className.getString() + " not supported by Interop Provider"); |
|
} | } |
else |
|
{ |
|
PEGASUS_ASSERT(false); // should never get here. |
|
} | } |
|
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} | } |
|
|
//*************************************************************************** |
|
// enumerateInstanceNames |
|
//*************************************************************************** |
|
void InteropProvider::enumerateInstanceNames( |
|
const OperationContext & context, |
|
const CIMObjectPath & classReference, |
|
ObjectPathResponseHandler & handler) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::enumerateInstanceNames()"); |
|
|
|
// operation namespace needed internally to get class. |
|
_operationNamespace = classReference.getNameSpace(); |
|
|
|
targetClass classEnum = _verifyValidClassInput(classReference.getClassName()); |
|
|
|
String userName = _validateUserID(context); |
|
|
|
// begin processing the request |
|
handler.processing(); |
|
|
|
// Deliver a single instance because there should only be one instance. |
|
if (classEnum == CIM_OBJECTMANAGER) |
|
{ |
|
CIMInstance instance = _buildInstanceCIMObjectManager( true, true, 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 |
// Cache this class definition for use later. |
if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
profileCapabilitiesClass = repository->getClass( |
{ |
PEGASUS_NAMESPACENAME_INTEROP, |
Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(true, |
PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES, |
true, CIMPropertyList()); |
false, |
|
true, |
|
false); |
| |
for (Uint32 i = 0 ; i < instances.size() ; i++) |
providerClassifications.append(Uint16(5)); // "Instrumentation" |
{ |
|
CIMObjectPath ref = _buildInstancePath(_operationNamespace, |
|
PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} |
|
handler.complete(); |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
| |
if (classEnum == PG_NAMESPACE) |
// initialize namespaces. |
{ |
initializeNamespaces(); |
Array<CIMInstance> instances = _getInstancesCIMNamespace(false, |
|
false, CIMPropertyList()); |
|
CDEBUG("EvalNames. Found instances. Count= " << instances.size()); |
|
for (Uint32 i = 0 ; i < instances.size() ; i++) |
|
{ |
|
CIMObjectPath ref = _buildInstancePath(_operationNamespace, |
|
CIM_NAMESPACE_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} |
|
| |
handler.complete(); |
// Now cache the Registration info used for ElementConformsToProfile |
PEG_METHOD_EXIT(); |
cacheProfileRegistrationInfo(); |
return; |
|
} |
|
| |
if (classEnum == CIM_COMMMECHANISMFORMANAGERINST) |
providerInitialized = true; |
{ |
|
Array<CIMInstance> instances = _buildInstancesCommMechanismForManager(); |
|
for (Uint32 i = 0 ; i < instances.size() ; i++ ) |
|
{ |
|
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
|
CIM_COMMMECHANISMFORMANAGER_CLASSNAME, instances[i]); |
|
handler.deliver(ref); |
|
} | } |
|
PEG_METHOD_EXIT(); |
} | } |
| |
if (classEnum == CIM_NAMESPACEINMANAGERINST) |
// |
|
// Initialize the namespaces so that all namespaces with the |
|
// CIM_ElementConformsToProfile class also have the |
|
// PG_ElementConformsToProfile class. Needed in order to implement |
|
// the cross-namespace ElementConformsToProfile association in both |
|
// directions. |
|
// |
|
void InteropProvider::initializeNamespaces() |
{ | { |
Array<CIMInstance> instances = _buildInstancesNamespaceInManager(); |
Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces(); |
for (Uint32 i = 0 ; i < instances.size() ; i++ ) |
// get the PG_ElementConformstoProfile class without the qualifiers |
|
// and then add just the required ASSOCIATION qualifier, so that |
|
// resolveclass doesn't fail for the test/EmbeddedInstance/Dynamic |
|
// namespace, which uses the CIM25 schema that doesn't include any |
|
// of the new qualifiers added to this class in later versions of |
|
// the CIMSchema. |
|
CIMClass conformsClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE, |
|
true, |
|
false); |
|
conformsClass.addQualifier( |
|
CIMQualifier(CIMName("ASSOCIATION"), CIMValue(true))); |
|
CIMClass profileClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, |
|
true, |
|
false); |
|
for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i) |
{ | { |
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
// Check if the PG_ElementConformsToProfile class is present |
CIM_NAMESPACEINMANAGER_CLASSNAME, instances[i]); |
CIMNamespaceName & currentNamespace = namespaceNames[i]; |
handler.deliver(ref); |
CIMClass tmpCimClass; |
} |
CIMClass tmpPgClass; |
} |
CIMClass tmpPgProfileClass; |
|
try |
|
|
// ATTN: Exception response because of error |
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//************************************************************** |
|
//************************************************************** |
|
// Association Functions |
|
//************************************************************** |
|
//************************************************************** |
|
|
|
void InteropProvider::associators( |
|
const OperationContext & context, |
|
const CIMObjectPath & objectName, |
|
const CIMName & associationClass, |
|
const CIMName & resultClass, |
|
const String & role, |
|
const String & resultRole, |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList & propertyList, |
|
ObjectResponseHandler & handler) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
// Look for these classes in the same try-block since the |
"InteropProvider::associatorNames()"); |
// second depends on the first |
throw CIMNotSupportedException("AssociationProvider::associators"); |
tmpCimClass = repository->getClass( |
|
currentNamespace, |
|
PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE); |
|
tmpPgClass = repository->getClass( |
|
currentNamespace, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE); |
} | } |
|
catch(const Exception &) |
void InteropProvider::associatorNames( |
|
const OperationContext & context, |
|
const CIMObjectPath & objectName, |
|
const CIMName & associationClass, |
|
const CIMName & resultClass, |
|
const String & role, |
|
const String & resultRole, |
|
ObjectPathResponseHandler & handler) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::associatorNames()"); |
|
throw CIMNotSupportedException("AssociationProvider::associatorNames"); |
|
} | } |
|
try |
void InteropProvider::references( |
|
const OperationContext & context, |
|
const CIMObjectPath & objectName, |
|
const CIMName & resultClass, |
|
const String & role, |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList & propertyList, |
|
ObjectResponseHandler & handler) |
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
tmpPgProfileClass = repository->getClass( |
"InteropProvider::references()"); |
currentNamespace, |
throw CIMNotSupportedException("AssociationProvider::references"); |
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); |
|
} |
|
catch(const Exception &) |
|
{ |
|
// Note: if any of the above three classes aren't found, |
|
// an exception will be thrown, which we can ignore since it's |
|
// an expected case |
|
// TBD: Log trace message? |
|
} |
|
|
|
// If the CIM_ElementConformsToProfile class is present, but |
|
// the PG_ElementConformsToProfile or PG_RegisteredProfile |
|
// class is not, then add it to that namespace. |
|
// |
|
// Note that we don't have to check for the |
|
// CIM_RegisteredProfile class because if the |
|
// CIM_ElementConformsToProfile class is present, the |
|
// CIM_RegisteredProfile class must also be present. |
|
if(!tmpCimClass.isUninitialized()) |
|
{ |
|
if(tmpPgClass.isUninitialized()) |
|
{ |
|
CIMClass newclass = conformsClass.clone(); |
|
CIMObjectPath newPath = conformsClass.getPath(); |
|
newPath.setNameSpace(currentNamespace); |
|
newclass.setPath(newPath); |
|
repository->createClass( |
|
currentNamespace, |
|
newclass); |
|
} |
|
if(tmpPgProfileClass.isUninitialized()) |
|
{ |
|
CIMClass newclass = profileClass.clone(); |
|
CIMObjectPath newPath = profileClass.getPath(); |
|
newPath.setNameSpace(currentNamespace); |
|
newclass.setPath(newPath); |
|
repository->createClass( |
|
currentNamespace, |
|
newclass); |
} | } |
|
|
void _filterAssocInstances(Array<CIMInstance>& instances, |
|
CIMName assocClassName, |
|
String assocRole, |
|
CIMName resultClassName = CIMName(), |
|
String resultRole = String::EMPTY) |
|
{ |
|
return; |
|
} | } |
|
|
void InteropProvider::referenceNames( |
|
const OperationContext & context, |
|
const CIMObjectPath & objectName, |
|
const CIMName & resultClass, |
|
const String & role, |
|
ObjectPathResponseHandler & handler) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"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(); |
|
|
|
// determine if valid class result class |
|
|
|
CIMName targetAssocClassName = resultClass; |
|
|
|
CIMName targetClassName = objectName.getClassName(); |
|
|
|
targetAssocClass classEnum = _verifyValidAssocClassInput(targetAssocClassName); |
|
|
|
Array<CIMInstance> assocInstances; |
|
|
|
if (classEnum == CIM_COMMMECHANISMFORMANAGER) |
|
assocInstances = _buildInstancesCommMechanismForManager(); |
|
|
|
if (classEnum == CIM_NAMESPACEINMANAGER) |
|
assocInstances = _buildInstancesNamespaceInManager(); |
|
|
|
_filterAssocInstances(assocInstances, resultClass, role); |
|
|
|
for (Uint32 i = 0 ; i < assocInstances.size() ; i++ ) |
|
{ |
|
CIMObjectPath ref = _buildObjectPath(_operationNamespace, |
|
targetAssocClassName, assocInstances[i]); |
|
CDEBUG("referenceNames returns: " << ref.toString()); |
|
handler.deliver(ref); |
|
} | } |
|
|
handler.complete(); |
|
|
|
PEG_METHOD_EXIT(); |
|
// Convert the instances to referenceNames response |
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
// END_OF_FILE |
// END OF FILE |