⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimmanagedclient.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	hasHostandNameSpace(host, nameSpace);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(host, port, nameSpace);    _rep->modifyClass(        nameSpace,        modifiedClass);}void CIMManagedClient::setQualifier(	const String& host,	const String& port,    const CIMNamespaceName& nameSpace,    const CIMQualifierDecl& qualifierDeclaration){	// test if host and namespace are provided	hasHostandNameSpace(host, nameSpace);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(host, port, nameSpace);    _rep->setQualifier(        nameSpace,        qualifierDeclaration);}CIMValue CIMManagedClient::getProperty(    const CIMObjectPath& instanceName,    const CIMName& propertyName){	hasHostandNameSpace(instanceName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(instanceName);    return _rep->getProperty(        instanceName.getNameSpace(),        instanceName,        propertyName);}void CIMManagedClient::setProperty(    const CIMObjectPath& instanceName,    const CIMName& propertyName,    const CIMValue& newValue){	hasHostandNameSpace(instanceName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(instanceName);    _rep->setProperty(        instanceName.getNameSpace(),        instanceName,        propertyName,        newValue);}void CIMManagedClient::deleteInstance(    const CIMObjectPath& instanceName){	hasHostandNameSpace(instanceName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(instanceName);    _rep->deleteInstance(		instanceName.getNameSpace(),		instanceName);}CIMObjectPath CIMManagedClient::createInstance(    const CIMInstance& newInstance){	hasHostandNameSpace(newInstance);	// save name space for later usage	CIMNamespaceName reqNameSpace = CIMNamespaceName(newInstance.getPath().getNameSpace());	CIMClientRep *   _rep;	_rep = getTargetCIMOM(newInstance.getPath());	CIMObjectPath returnedObjectPath = _rep->createInstance(					reqNameSpace,					newInstance);	// put host and namespace back into object path, so it is definite fully specified	returnedObjectPath.setHost(newInstance.getPath().getHost());	returnedObjectPath.setNameSpace(reqNameSpace);	return returnedObjectPath;}CIMInstance CIMManagedClient::getInstance(    const CIMObjectPath& instanceName,    Boolean localOnly,    Boolean includeQualifiers,    Boolean includeClassOrigin,    const CIMPropertyList& propertyList){	hasHostandNameSpace(instanceName);	CIMNamespaceName reqNameSpace = CIMNamespaceName(instanceName.getNameSpace());	CIMClientRep *   _rep;	_rep = getTargetCIMOM(instanceName);    CIMInstance returnedCimInstance = _rep->getInstance(		reqNameSpace,        instanceName,        localOnly,        includeQualifiers,        includeClassOrigin,        propertyList);/*	CIMObjectPath chgObjectPath = CIMObjectPath(returnedCimInstance.getPath());	chgObjectPath.setHost(instanceName.getHost());	chgObjectPath.setNameSpace(reqNameSpace);	returnedCimInstance.setPath(chgObjectPath);*/	// changed to take over the entire CIMObjectPath that was given ...	returnedCimInstance.setPath(instanceName);	return returnedCimInstance;}void CIMManagedClient::modifyInstance(    const CIMInstance& modifiedInstance,    Boolean includeQualifiers,    const CIMPropertyList& propertyList){	hasHostandNameSpace(modifiedInstance);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(modifiedInstance.getPath());    _rep->modifyInstance(        modifiedInstance.getPath().getNameSpace(),        modifiedInstance,        includeQualifiers,        propertyList);}CIMValue CIMManagedClient::invokeMethod(    const CIMObjectPath& instanceName,    const CIMName& methodName,    const Array<CIMParamValue>& inParameters,    Array<CIMParamValue>& outParameters){	hasHostandNameSpace(instanceName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(instanceName);    return _rep->invokeMethod(        instanceName.getNameSpace(),        instanceName,        methodName,        inParameters,        outParameters);}Array<CIMObjectPath> CIMManagedClient::associatorNames(    const CIMObjectPath& objectName,    const CIMName& assocClass,    const CIMName& resultClass,    const String& role,    const String& resultRole){	hasHostandNameSpace(objectName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(objectName);    Array<CIMObjectPath> retAssocNames = _rep->associatorNames(		objectName.getNameSpace(),        objectName,        assocClass,        resultClass,        role,        resultRole);	for (Uint32 i = 0; i < retAssocNames.size(); i++)	{		try		{			// check if all object paths are fully qualified			hasHostandNameSpace(retAssocNames[i]);		}		catch(TypeMismatchException tme)		{			// should throw nasty exception about missing namespace ....			// TODO: prepare exception for this			MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",										 "Returned CIM object path incomplete specified.");			throw TypeMismatchException(retTypeMismatchMessage);		}	}	return retAssocNames;}Array<CIMObject> CIMManagedClient::associators(    const CIMObjectPath& objectName,    const CIMName& assocClass,    const CIMName& resultClass,    const String& role,    const String& resultRole,    Boolean includeQualifiers,    Boolean includeClassOrigin,    const CIMPropertyList& propertyList){	hasHostandNameSpace(objectName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(objectName);	Array<CIMObject> retAssoc = _rep->associators(		objectName.getNameSpace(),        objectName,        assocClass,        resultClass,        role,        resultRole,        includeQualifiers,        includeClassOrigin,        propertyList);	for (Uint32 i = 0; i < retAssoc.size(); i++)	{		// check if all object paths are fully qualified		try		{			hasHostandNameSpace(retAssoc[i].getPath());		}		catch(TypeMismatchException tme)		{			// should throw nasty exception about missing namespace ....			// TODO: prepare exception for this			MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",											 "Returned CIM object path incomplete specified.");			throw TypeMismatchException(retTypeMismatchMessage);		}	}	return retAssoc;}Array<CIMObject> CIMManagedClient::references(    const CIMObjectPath& objectName,    const CIMName& resultClass,    const String& role,    Boolean includeQualifiers,    Boolean includeClassOrigin,    const CIMPropertyList& propertyList){	hasHostandNameSpace(objectName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(objectName);	Array<CIMObject> retRefer = _rep->references(        objectName.getNameSpace(),        objectName,        resultClass,        role,        includeQualifiers,        includeClassOrigin,        propertyList);	for (Uint32 i = 0; i < retRefer.size(); i++)	{		// check if all object paths are fully qualified		try		{			hasHostandNameSpace(retRefer[i].getPath());		}		catch(TypeMismatchException tme)		{			// should throw nasty exception about missing namespace ....			// TODO: prepare exception for this			MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",											 "Returned CIM object path incomplete specified.");			throw TypeMismatchException(retTypeMismatchMessage);		}	}	return retRefer;}Array<CIMObjectPath> CIMManagedClient::referenceNames(    const CIMObjectPath& objectName,    const CIMName& resultClass,    const String& role){	hasHostandNameSpace(objectName);	CIMClientRep *   _rep;	_rep = getTargetCIMOM(objectName);    Array<CIMObjectPath> retReferNames = _rep->referenceNames(        objectName.getNameSpace(),        objectName,        resultClass,        role);	for (Uint32 i = 0; i < retReferNames.size(); i++)	{		try		{			// check if all object paths are fully qualified			hasHostandNameSpace(retReferNames[i]);		}		catch(TypeMismatchException tme)		{			// should throw nasty exception about missing namespace ....			// TODO: prepare exception for this			MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",										 "Returned CIM object path incomplete specified.");			throw TypeMismatchException(retTypeMismatchMessage);		}	}	return retReferNames;}void CIMManagedClient::hasHostandNameSpace(const String& _host, const CIMNamespaceName& _nameSpace){	MessageLoaderParms typeMismatchMessage;	if (_host == String::EMPTY)	{		// should throw nasty exception about missing hostname ....		// TODO: prepare exception for this		typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",										 "Failed validation of CIM object path: no host name specified");		throw TypeMismatchException(typeMismatchMessage);	}	if (_nameSpace.isNull())	{		// should throw nasty exception about missing namespace ....		// TODO: prepare exception for this		typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",										 "Failed validation of CIM object path: no namespace specified");		throw TypeMismatchException(typeMismatchMessage);	}	CDEBUG("No exception thrown, seems the host and namespace are there.");}void CIMManagedClient::hasHostandNameSpace(const CIMObjectPath& inObjectPath){	CDEBUG("hasHostandNameSpace(inObjectPath.getHost(), inObjectPath.getNameSpace())=" << inObjectPath.getHost() << "," << inObjectPath.getNameSpace());	hasHostandNameSpace(inObjectPath.getHost(), inObjectPath.getNameSpace());}void CIMManagedClient::hasHostandNameSpace(const CIMInstance& inInstance){	hasHostandNameSpace(inInstance.getPath());}CIMClientRep* CIMManagedClient::getTargetCIMOM(const String& _host,const String& _port, const CIMNamespaceName& _nameSpace) const{	CIMClientRep *   targetCIMOM;	if (strtoul((const char*) _port.getCString(), NULL, 0) == 0)	{		CDEBUG("no port given explicitly, thus we use the default port:" << _pegasusDefaultPort);		// no port given explicitly, thus we use the default port of 5988		// lets determine if there is a connection for this object path available		targetCIMOM = _cccm->getConnection(_host, _pegasusDefaultPort, _nameSpace);	} else {		// lets determine if there is a connection for this object path available		targetCIMOM = _cccm->getConnection(_host, _port, _nameSpace);	}	// damn, somehow we missed to construct a CIMClientRep for this connection	// shouldn't be possible at all, but one never knows everything	if (targetCIMOM == 0)	{		// throw some crazy exception		// TODO: invent exception		MessageLoaderParms typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",										 "No valid CIMOM connection configured for: ($0:$1) ",										_host, _port);		throw TypeMismatchException(typeMismatchMessage);	}	CDEBUG("targetCIMOM=" << targetCIMOM);	return targetCIMOM;}CIMClientRep* CIMManagedClient::getTargetCIMOM(const CIMObjectPath& inObjectPath) const{	String inHost, inPort;	CIMNamespaceName inNameSpace;	inNameSpace = inObjectPath.getNameSpace();	// need to create our own Host String object, as we split it in two pieces	// thus change it ...	inHost = String(inObjectPath.getHost());	// test if a host is given at all not necessary	here	// if there is no we failed to detect that before anyway	// wonder how that should possibly happen???	// splitting the port from hostname	int i = inHost.find(":");	// only if there is a ":" we should split a port address from hostname string	if (i > 0)	{		inPort = inHost.subString(i+1);		inHost.remove(i);	} else	{		// if there is no : , there is no port, we use the default empty port		inPort = String::EMPTY;	}	return getTargetCIMOM(inHost, inPort, inNameSpace);}void CIMManagedClient::setPegasusDefaultPort(){	_pegasusDefaultPort = String("5988");}String CIMManagedClient::_getHostwithPort(const String& host, const String& port){	String hostwithport=String(host);	hostwithport.append(":");	hostwithport.append(port);	return hostwithport;}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -