void PG_TestPropertyTypes::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& classReference, ObjectPathResponseHandler& handler) { // ensure the Namespace is valid if (!classReference.getNameSpace().equal ("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!classReference.getClassName().equal ("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // begin processing the request handler.processing(); Array<CIMObjectPath> instanceNames; instanceNames = _enumerateInstanceNames(context, classReference); handler.deliver(instanceNames); // complete processing the request handler.complete(); }
void PG_TestPropertyTypes::deleteInstance( const OperationContext& context, const CIMObjectPath& instanceReference, ResponseHandler& handler) { // synchronously get references Array<CIMObjectPath> references = _enumerateInstanceNames(context, instanceReference); // ensure the Namespace is valid if (!instanceReference.getNameSpace().equal("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!instanceReference.getClassName().equal("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // ensure the requested object exists Uint32 index = findObjectPath(references, instanceReference); if (index == PEG_NOT_FOUND) { throw CIMException(CIM_ERR_NOT_FOUND); } // begin processing the request handler.processing(); // we do not remove instance // complete processing the request handler.complete(); }
//async request handler method invoked on a seperate thread per provider //through the async request executor. CIMException DefaultProviderManager::_asyncRequestCallback( void *callbackPtr, AsyncRequestExecutor::AsyncRequestMsg* request) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_asyncRequestCallback"); CIMException responseException; //extract the parameters UnloadProviderRequest* my_request = dynamic_cast<UnloadProviderRequest*>(request); if(my_request != NULL) { PEGASUS_ASSERT(0 != callbackPtr); DefaultProviderManager *dpmPtr = static_cast<DefaultProviderManager*>(callbackPtr); ProviderMessageHandler* provider = dynamic_cast<ProviderMessageHandler*>(my_request->_provider); try { AutoMutex lock(provider->status.getStatusMutex()); //unload the provider if (provider->status.isInitialized()) { dpmPtr->_unloadProvider(provider); } else { PEGASUS_ASSERT(0); } } catch (CIMException& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s", (const char*)e.getMessage().getCString())); responseException = e; } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s", (const char*)e.getMessage().getCString())); responseException = CIMException(CIM_ERR_FAILED, e.getMessage()); } catch (PEGASUS_STD(exception)& e) { responseException = CIMException(CIM_ERR_FAILED, e.what()); } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Exception: Unknown"); responseException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, "Unknown error."); } }
void CIMError::setInstance(const CIMInstance& instance) { for (Uint32 i = 0; i < instance.getPropertyCount(); i++) { CIMConstProperty p = instance.getProperty(i); _Check("ErrorType", p, (Uint16*)0); _Check("OtherErrorType", p, (String*)0); _Check("OwningEntity", p, (String*)0); _Check("MessageID", p, (String*)0); _Check("Message", p, (String*)0); _Check("MessageArguments", p, (Array<String>*)0); _Check("PerceivedSeverity", p, (Uint16*)0); _Check("ProbableCause", p, (Uint16*)0); _Check("ProbableCauseDescription", p, (String*)0); _Check("RecommendedActions", p, (Array<String>*)0); _Check("ErrorSource", p, (String*)0); _Check("ErrorSourceFormat", p, (Uint16*)0); _Check("OtherErrorSourceFormat", p, (String*)0); _Check("CIMStatusCode", p, (Uint32*)0); _Check("CIMStatusCodeDescription", p, (String*)0); } // Verify that the instance contains all of the required properties. for (Uint32 i = 0; i < _numRequiredProperties; i++) { // Does inst have this property? Uint32 pos = instance.findProperty(_requiredProperties[i]); if (pos == PEG_NOT_FOUND) { char buffer[80]; sprintf(buffer, "required property does not exist: %s", _requiredProperties[i]); throw CIMException(CIM_ERR_NO_SUCH_PROPERTY, buffer); } // is required property non-null? CIMConstProperty p = instance.getProperty(pos); CIMValue v = p.getValue(); if (v.isNull()) { char buffer[80]; sprintf(buffer, "required property MUST NOT be Null: %s", _requiredProperties[i]); throw CIMException(CIM_ERR_FAILED, buffer); } } _inst = instance; }
///////////////////////////////////////////////////////////////////////////// // WMIInstanceProvider::getProperty // // /////////////////////////////////////////////////////////////////////////// CIMValue WMIInstanceProvider::getProperty( const String& nameSpace, const String& userName, const String& password, const CIMObjectPath& instanceName, const String& propertyName) { CIMInstance cimInstance; Array<CIMName> propertyNames; PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIInstanceProvider::getProperty()"); setup(nameSpace,userName,password); if (!m_bInitialized) { throw CIMException(CIM_ERR_FAILED, "[getProperty] m_bInitialized"); } CIMName propName = propertyName; propertyNames.append(propName); CIMPropertyList propertyList = CIMPropertyList(propertyNames); // get the relevant CIMInstance object cimInstance = getCIMInstance(nameSpace, userName, password, instanceName, propertyList); // now fetch the property Uint32 pos = cimInstance.findProperty(propName); if (PEG_NOT_FOUND == pos) { throw CIMException(CIM_ERR_NO_SUCH_PROPERTY, "[getProperty] findproperty"); } CIMProperty property = cimInstance.getProperty(pos); // and return the value CIMValue value = property.getValue(); PEG_METHOD_EXIT(); return value; }
void PG_TestPropertyTypes::modifyInstance( const OperationContext& context, const CIMObjectPath& instanceReference, const CIMInstance& instanceObject, const Boolean includeQualifiers, const CIMPropertyList& propertyList, ResponseHandler& handler) { // This provider only allows partial instance modification for the // PropertyUint8 property. if (!(propertyList.isNull() || ((propertyList.size() == 1) && (propertyList[0].equal("PropertyUint8"))))) { throw CIMException(CIM_ERR_NOT_SUPPORTED); } // synchronously get references Array<CIMObjectPath> references = _enumerateInstanceNames(context, instanceReference); // ensure the Namespace is valid if (!instanceReference.getNameSpace().equal("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!instanceReference.getClassName().equal("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // ensure the property values are valid _testPropertyTypesValue(instanceObject); // ensure the request object exists Uint32 index = findObjectPath(references, instanceReference); if (index == PEG_NOT_FOUND) { throw CIMException(CIM_ERR_NOT_FOUND); } // begin processing the request handler.processing(); // We do nothing here since we like to have static result // complete processing the request handler.complete(); }
///////////////////////////////////////////////////////////////////////////// // WMIQualifierProvider::enumerateQualifiers // // /////////////////////////////////////////////////////////////////////////// Array<CIMQualifierDecl> WMIQualifierProvider::enumerateQualifiers( const String& nameSpace, const String& userName, const String& password) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
void TestFaultyInstanceProvider::deleteInstance( const OperationContext& context, const CIMObjectPath& instanceReference, ResponseHandler& handler) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
static void _parseFile(const char* fileName, Boolean hideEmptyTags) { // cout << "Parsing: " << fileName << endl; Buffer text; FileSystem::loadFileToMemory(text, fileName); XmlParser parser((char*)text.getData(), 0, hideEmptyTags); XmlEntry entry; // Get initial comment and ignore parser.next(entry, true); // get next comment, check for file Description parser.next(entry, true); if (!String::equal(entry.text, "Test XML file") ) { throw CIMException(CIM_ERR_FAILED, "Comment Error"); } PEGASUS_ASSERT (parser.getLine () == 2); PEGASUS_ASSERT (parser.getStackSize () == 0); // Put the Comment back... parser.putBack (entry); PEGASUS_ASSERT (parser.getLine () == 2); PEGASUS_ASSERT (parser.getStackSize () == 0); while (parser.next(entry)) { if (verbose) { entry.print(); } } PEGASUS_ASSERT (parser.next (entry, true) == false); }
///////////////////////////////////////////////////////////////////////////// // WMIBaseProvider::execCIMQuery - retrieves a query result // // /////////////////////////////////////////////////////////////////////////// Array<CIMObject> WMIBaseProvider::execCIMQuery( const String& nameSpace, const String& userName, const String& password, const String& queryLanguage, const String& query, const CIMPropertyList& propertyList, Boolean includeQualifiers, Boolean includeClassOrigin) { Array<CIMObject> objects; CIMInstance cimInstance; CIMStatusCode errorCode = CIM_ERR_SUCCESS; String errorDescription; WMIQueryProvider provider; PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIBaseProvider::execCIMQuery()"); try { // This fix uses the current boolean value stored in collector // to initialize it. provider.initialize(_collector->isLocalConnection()); objects = provider.execQuery(nameSpace, userName, password, queryLanguage, query, propertyList, includeQualifiers, includeClassOrigin); provider.terminate(); } catch(CIMException& exception) { provider.terminate(); errorCode = exception.getCode(); errorDescription = exception.getMessage(); throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription); } catch(Exception& exception) { provider.terminate(); errorCode = CIM_ERR_FAILED; errorDescription = exception.getMessage(); throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription); } catch(...) { provider.terminate(); throw CIMException(CIM_ERR_FAILED); } PEG_METHOD_EXIT(); return objects; }
ClientCIMOMHandleAccessController(Mutex& lock) : _lock(lock) { try { // assume default client timeout if (!_lock.timed_lock(PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS)) { throw CIMException(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Provider.CIMOMHandle.CIMOMHANDLE_TIMEOUT", "Timeout waiting for CIMOMHandle")); } } catch (Exception& e) { PEG_TRACE((TRC_CIMOM_HANDLE, Tracer::LEVEL2, "Unexpected Exception: %s", (const char*)e.getMessage().getCString())); throw; } catch (...) { PEG_TRACE_CSTRING(TRC_CIMOM_HANDLE, Tracer::LEVEL2, "Unexpected exception"); throw; } }
void DynamicIndicationProvider::deleteInstance( const OperationContext& context, const CIMObjectPath& instanceReference, ResponseHandler& handler) { throw CIMException( CIM_ERR_NOT_SUPPORTED, "DynamicIndicationProvider::deleteInstance"); }
void _Check(const String& name, CIMConstProperty& p, T* tag) { if (p.getName() == name) { if (IsArray(tag) != p.isArray() || GetType(tag) != p.getType()) throw CIMException(CIM_ERR_TYPE_MISMATCH, name); } }
///////////////////////////////////////////////////////////////////////////// // WMIQualifierProvider::getQualifier // // /////////////////////////////////////////////////////////////////////////// CIMQualifierDecl WMIQualifierProvider::getQualifier( const String& nameSpace, const String& userName, const String& password, const String& qualifierName) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
void benchmarkProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
void DynamicIndicationProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& classReference, ObjectPathResponseHandler& handler) { throw CIMException( CIM_ERR_NOT_SUPPORTED, "DynamicIndicationProvider::enumerateInstanceNames"); }
void PG_TestPropertyTypes::enumerateInstances( const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { // ensure the Namespace is valid if (!ref.getNameSpace().equal ("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!ref.getClassName().equal ("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // begin processing the request handler.processing(); // NOTE: It would be much more efficient to remember the instance names // get class definition from repository CIMClass cimclass = _cimom.getClass( context, ref.getNameSpace(), ref.getClassName(), false, true, true, CIMPropertyList()); for (Uint32 i = 0; i < _instances.size(); i++) { handler.deliver(_instances[i]); } // complete processing the request handler.complete(); }
CIMObjectPath ObjectNormalizer::processClassObjectPath( const CIMObjectPath& cimObjectPath) const { // pre-check if (!_enableNormalization || _cimClass.isUninitialized()) { // do nothing return cimObjectPath; } /* // ATTN: moving similar logic to the response handlers because this // type of error should be checked regardless with or without // normalization enabled. if (cimObjectPath.getClassName().isNull()) { throw CIMException(CIM_ERR_FAILED, "uninitialized object path"); } */ /* // ATTN: The following code is currently redundant because the CIMName // object validates legal names when it is constructed. It is included // here for completeness. // check class name if (!CIMName(cimObjectPath.getClassName()).legal()) { MessageLoaderParms message( "Common.ObjectNormalizer.INVALID_CLASS_NAME", "Invalid class name: $0", cimObjectPath.getClassName().getString()); throw CIMException(CIM_ERR_FAILED, message); } */ // check class type if (!_cimClass.getClassName().equal(cimObjectPath.getClassName())) { MessageLoaderParms message( "Common.ObjectNormalizer.INVALID_CLASS_TYPE", "Invalid class type: $0", cimObjectPath.getClassName().getString()); throw CIMException(CIM_ERR_FAILED, message); } CIMObjectPath normalizedObjectPath( _cimClass.getPath().getHost(), _cimClass.getPath().getNameSpace(), _cimClass.getClassName()); // ignore any keys, they are not part of a class object path return normalizedObjectPath; }
void TestFaultyInstanceProvider::getInstance( const OperationContext& context, const CIMObjectPath& instanceReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
void benchmarkProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { throw CIMException(CIM_ERR_NOT_SUPPORTED); }
static void _throw(CIMStatusCode code, const char* format, ...) { char buffer[4096]; va_list ap; va_start(ap, format); vsprintf(buffer, format, ap); va_end(ap); throw CIMException(code, format); }
CIMQualifier _processQualifier( CIMConstQualifier& referenceQualifier, CIMConstQualifier& cimQualifier) { // check name if (!referenceQualifier.getName().equal(cimQualifier.getName())) { MessageLoaderParms message( "Common.ObjectNormalizer.INVALID_QUALIFIER_NAME", "Invalid qualifier name: $0", cimQualifier.getName().getString()); throw CIMException(CIM_ERR_FAILED, message); } // check type if (referenceQualifier.getType() != cimQualifier.getType()) { MessageLoaderParms message( "Common.ObjectNormalizer.INVALID_QUALIFIER_TYPE", "Invalid qualifier type: $0", cimQualifier.getName().getString()); throw CIMException(CIM_ERR_FAILED, message); } CIMQualifier normalizedQualifier( referenceQualifier.getName(), referenceQualifier.getValue(), // default value referenceQualifier.getFlavor(), referenceQualifier.getPropagated() == 0 ? false : true); // TODO: check override // update value if (!cimQualifier.getValue().isNull()) { normalizedQualifier.setValue(cimQualifier.getValue()); } return normalizedQualifier; }
///////////////////////////////////////////////////////////////////////////// // WMIInstanceProvider::getHostName // // /////////////////////////////////////////////////////////////////////////// String WMIInstanceProvider::getHostName() { DWORD nSize = 255; char hostName[256]; // Get the computer name if(GetComputerName(hostName, &nSize)) return String(hostName); throw CIMException(CIM_ERR_FAILED); }
void DynamicIndicationProvider::enumerateInstances( const OperationContext& context, const CIMObjectPath& classReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { throw CIMException( CIM_ERR_NOT_SUPPORTED, "DynamicIndicationProvider::enumerateInstances"); }
///////////////////////////////////////////////////////////////////////////// // WMIBaseProvider::getCIMInstance - retrieves a CIMInstance object // // /////////////////////////////////////////////////////////////////////////// CIMInstance WMIBaseProvider::getCIMInstance(const String& nameSpace, const String& userName, const String& password, const CIMObjectPath &instanceName, const CIMPropertyList &propertyList) { CIMInstance cimInstance; CIMStatusCode errorCode = CIM_ERR_SUCCESS; String errorDescription; WMIInstanceProvider provider; PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIBaseProvider::getCIMInstance()"); try { // This fix uses the current boolean value stored in collector // to initialize it. provider.initialize(_collector->isLocalConnection()); cimInstance = provider.getInstance(nameSpace, userName, password, instanceName, false, false, false, propertyList); provider.terminate(); } catch(CIMException& exception) { provider.terminate(); errorCode = exception.getCode(); errorDescription = exception.getMessage(); throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription); } catch(Exception& exception) { provider.terminate(); errorCode = CIM_ERR_FAILED; errorDescription = exception.getMessage(); throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription); } catch(...) { provider.terminate(); throw CIMException(CIM_ERR_FAILED); } PEG_METHOD_EXIT(); return cimInstance; }
void AssociatorsResponseHandler::deliver(const SCMOInstance& scmoObject) { if (scmoObject.isUninitialized()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } SimpleObjectResponseHandler::deliver(scmoObject); }
/** TBD? */ void EmbeddedInstanceProvider::modifyInstance( const OperationContext& context, const CIMObjectPath& ref, const CIMInstance& obj, const Boolean includeQualifiers, const CIMPropertyList& propertyList, ResponseHandler& handler) { throw CIMException(CIM_ERR_NOT_SUPPORTED); // handler.processing(); // handler.complete(); }
void benchmarkProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { CIMInstance _instance; Uint32 numberOfProperties; Uint32 sizeOfPropertyValue; Uint32 numberOfInstances; CIMName className = instanceReference.getClassName(); test.getConfiguration(className, numberOfProperties, sizeOfPropertyValue, numberOfInstances); Array<CIMKeyBinding> keyBindings = instanceReference.getKeyBindings(); if (keyBindings.size() != 1) { throw CIMException(CIM_ERR_NOT_SUPPORTED); } // begin processing the request handler.processing(); Uint32 ID; if (sscanf (keyBindings[0].getValue().getCString(), "%u", &ID) != 1) { throw CIMException (CIM_ERR_INVALID_PARAMETER); } _instance = _buildInstance(className, numberOfProperties, sizeOfPropertyValue , CIMValue(ID)); handler.deliver(_instance); // complete processing the request handler.complete(); }
void AssociatorNamesResponseHandler::deliver(const CIMObjectPath& cimObjectPath) { if (cimObjectPath.getClassName().isNull()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } SimpleObjectPathResponseHandler::deliver(cimObjectPath); }
void ReferencesResponseHandler::deliver(const CIMObject& cimObject) { if (cimObject.isUninitialized()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } SimpleObjectResponseHandler::deliver(cimObject); }