From: <bni...@us...> - 2006-12-08 22:45:20
|
Revision: 418 http://svn.sourceforge.net/omc/?rev=418&view=rev Author: bnicholes Date: 2006-12-08 14:45:14 -0800 (Fri, 08 Dec 2006) Log Message: ----------- Allow the value map values on a set command to be resolved before passing them to the cimom Modified Paths: -------------- clp/trunk/src/omcclpcmdmapping.cpp clp/trunk/src/omcclpcmdmapping.h Modified: clp/trunk/src/omcclpcmdmapping.cpp =================================================================== --- clp/trunk/src/omcclpcmdmapping.cpp 2006-12-08 22:43:44 UTC (rev 417) +++ clp/trunk/src/omcclpcmdmapping.cpp 2006-12-08 22:45:14 UTC (rev 418) @@ -25,7 +25,7 @@ #ifdef HAVE_CONFIG_H - #include <config.h> + #include <config.h> #endif #include "omcclpprogram.h" @@ -48,33 +48,33 @@ */ CIMValue SMCmdMapping::smRequestStateChange (const CIMObjectPath& cop, Int32 reqState) { - m_methodToCall = m_methodCalled = "RequestStateChange"; - m_cimObjectPath = cop; + m_methodToCall = m_methodCalled = "RequestStateChange"; + m_cimObjectPath = cop; - try - { - /* Push the parameters on the input parameter array. */ - /*XXX For now we aren't going to worry about the timeoutperiod. - That will come later */ - m_inParams.push_back(CIMParamValue("RequestedState", CIMValue(UInt16(reqState)))); - m_inParams.push_back(CIMParamValue("TimeoutPeriod", CIMValue(CIMDateTime(0)))); + try + { + /* Push the parameters on the input parameter array. */ + /*XXX For now we aren't going to worry about the timeoutperiod. + That will come later */ + m_inParams.push_back(CIMParamValue("RequestedState", CIMValue(UInt16(reqState)))); + m_inParams.push_back(CIMParamValue("TimeoutPeriod", CIMValue(CIMDateTime(0)))); - /*XXX The out paramenter should be checked for a job object, but that will come later */ + /*XXX The out paramenter should be checked for a job object, but that will come later */ - m_returnValue = m_cimClient->invokeMethod (m_cimObjectPath, m_methodToCall, m_inParams, m_outParams); - } - catch (const CIMException& ce) - { - cerr << ce << CLPENDL; - m_returnValue = CIMValue(2u); - m_errorMsg = String(ce.getDescription()); - } - catch (Exception& e) - { - cerr << e << CLPENDL; - } + m_returnValue = m_cimClient->invokeMethod (m_cimObjectPath, m_methodToCall, m_inParams, m_outParams); + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + m_returnValue = CIMValue(2u); + m_errorMsg = String(ce.getDescription()); + } + catch (Exception& e) + { + cerr << e << CLPENDL; + } - return m_returnValue; + return m_returnValue; } /** @@ -82,8 +82,8 @@ */ CIMValue SMCmdMapping::smResetRSC (const CIMObjectPath& cop) { - // Send a reset which evaluates to id 11 - return smRequestStateChange (cop, 11); + // Send a reset which evaluates to id 11 + return smRequestStateChange (cop, 11); } /** @@ -91,8 +91,8 @@ */ CIMValue SMCmdMapping::smStartRSC (const CIMObjectPath& cop) { - // Send a Enabled which evaluates to id 2 - return smRequestStateChange (cop, 2); + // Send a Enabled which evaluates to id 2 + return smRequestStateChange (cop, 2); } /** @@ -100,8 +100,8 @@ */ CIMValue SMCmdMapping::smStopRSC (const CIMObjectPath& cop) { - // Send a Disabled which evaluates to id 3 - return smRequestStateChange (cop, 3); + // Send a Disabled which evaluates to id 3 + return smRequestStateChange (cop, 3); } /** @@ -110,7 +110,7 @@ */ CIMValue SMCmdMapping::smOpDeleteInstance (const CIMObjectPath& cop) { - m_returnValue = CIMValue(0u); + m_returnValue = CIMValue(0u); try { @@ -145,15 +145,15 @@ } catch (const CIMException& ce) { - m_errorMsg = String(ce.getDescription()); - /*XXX Need to specify a real error value here */ - m_returnValue = CIMValue(2u); + m_errorMsg = String(ce.getDescription()); + /*XXX Need to specify a real error value here */ + m_returnValue = CIMValue(2u); } catch (Exception& e) { - m_errorMsg = String(e.getMessage()); - /*XXX Need to specify a real error value here */ - m_returnValue = CIMValue(2u); + m_errorMsg = String(e.getMessage()); + /*XXX Need to specify a real error value here */ + m_returnValue = CIMValue(2u); } return m_returnValue; @@ -165,35 +165,39 @@ */ CIMValue SMCmdMapping::smModifyInstance (const CIMObjectPath& cop) { - m_returnValue = CIMValue(0u); + m_returnValue = CIMValue(0u); - CIMInstance ci; - try - { - ci = m_cimClient->getInstance(cop); - } - catch (const CIMException& ce) - { - cerr << ce << CLPENDL; - /*XXX Need to specify a real error value here */ - m_returnValue = CIMValue(2u); - } + CIMInstance ci; + try + { + ci = m_cimClient->getInstance(cop, WBEMFlags::E_NOT_LOCAL_ONLY, + WBEMFlags::E_INCLUDE_QUALIFIERS); + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + /*XXX Need to specify a real error value here */ + m_returnValue = CIMValue(2u); + } - for (int i=0;i<m_property_names.size();i++) - { - ci.updatePropertyValue(m_property_names[i], m_property_values[i]); - } - try - { - m_cimClient->modifyInstance(ci, WBEMFlags::E_EXCLUDE_QUALIFIERS, &m_property_names); - } - catch (const CIMException& ce) - { - m_returnValue = CIMValue((UInt32)ce.getErrNo()); - m_errorMsg = String(ce.getDescription()); - } + for (int i=0;i<m_property_names.size();i++) + { + CIMProperty cprop = ci.getProperty(CIMName(m_property_names[i])); + CIMValue cv = resolveMappedValue(cprop, m_property_values[i].toString()); - return m_returnValue; + ci.updatePropertyValue(m_property_names[i], cv); + } + try + { + m_cimClient->modifyInstance(ci, WBEMFlags::E_EXCLUDE_QUALIFIERS, &m_property_names); + } + catch (const CIMException& ce) + { + m_returnValue = CIMValue((UInt32)ce.getErrNo()); + m_errorMsg = String(ce.getDescription()); + } + + return m_returnValue; } /** @@ -203,26 +207,26 @@ */ CIMValue SMCmdMapping::smInvokeMethod (const CIMObjectPath& cop) { - m_cimObjectPath = cop; + m_cimObjectPath = cop; - try - { - m_methodCalled = m_methodToCall; - m_returnValue = m_cimClient->invokeMethod (m_cimObjectPath, m_methodToCall, - m_inParams, m_outParams); - } - catch (const CIMException& ce) - { - cerr << ce << CLPENDL; - m_returnValue = CIMValue((UInt32)-1); - m_errorMsg = String(ce.getDescription()); - } - catch (Exception& e) - { - cerr << e << CLPENDL; - } + try + { + m_methodCalled = m_methodToCall; + m_returnValue = m_cimClient->invokeMethod (m_cimObjectPath, m_methodToCall, + m_inParams, m_outParams); + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + m_returnValue = CIMValue((UInt32)-1); + m_errorMsg = String(ce.getDescription()); + } + catch (Exception& e) + { + cerr << e << CLPENDL; + } - return m_returnValue; + return m_returnValue; } /** @@ -231,8 +235,8 @@ */ void SMCmdMapping::setProperty (const String name, const CIMValue value) { - m_property_names.push_back(name); - m_property_values.push_back(value); + m_property_names.push_back(name); + m_property_values.push_back(value); } /** @@ -241,144 +245,279 @@ * val - String value to be converted to the correct type and * set */ +CIMValue SMCmdMapping::resolveMappedValue (const CIMProperty prop, const String val) +{ + CIMValue cv(val); + + try + { + switch (prop.getDataType().getType()) + { + case CIMDataType::UINT8: + try + { + cv = CIMValue(val.toUInt8()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toUInt8()); + } + break; + case CIMDataType::SINT8: + try + { + cv = CIMValue(val.toInt8()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toInt8()); + } + break; + case CIMDataType::UINT16: + try + { + cv = CIMValue(val.toUInt16()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toUInt16()); + } + break; + case CIMDataType::SINT16: + try + { + cv = CIMValue(val.toInt16()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toInt16()); + } + break; + case CIMDataType::UINT32: + try + { + cv = CIMValue(val.toUInt32()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toUInt32()); + } + break; + case CIMDataType::SINT32: + try + { + cv = CIMValue(val.toInt32()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toInt32()); + } + break; + case CIMDataType::UINT64: + try + { + cv = CIMValue(val.toUInt64()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toUInt64()); + } + break; + case CIMDataType::SINT64: + try + { + cv = CIMValue(val.toInt64()); + } + catch (Exception& e) + { + String v = getPropertyMappedValue(prop,val); + cv = CIMValue(v.toInt64()); + } + break; + case CIMDataType::BOOLEAN: + cv = CIMValue(val.toBool()); + break; + case CIMDataType::REAL32: + cv = CIMValue(val.toReal32()); + break; + case CIMDataType::REAL64: + cv = CIMValue(val.toReal64()); + break; + // case CIMDataType::DATETIME: + // cv = CIMValue(val.toDateTime()); + // break; + // case CIMDataType::CHAR16: + // cv = CIMValue(val.toChar16()); + // break; + } + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + m_returnValue = CIMValue((UInt32)-1); + m_errorMsg = String("Invalid property type "); + cv = CIMValue(val); + } + catch (Exception& e) + { + cerr << e << CLPENDL; + cv = CIMValue(val); + } + + return cv; +} + +/** +* Set an IN parameter for a method that will be invoked +* param - String name of the parameter +* val - String value to be converted to the correct type and +* set +*/ bool SMCmdMapping::setInParamValue (String param, String val) { - String paramName; - bool ret = true; + String paramName; + bool ret = true; - try - { - for (int i=0; i<m_inParamsDesc.size(); i++) - { - paramName = m_inParamsDesc[i].getName(); - if (param.equalsIgnoreCase(paramName)) - { - CIMValue cv(val); - switch (m_inParamsDesc[i].getType().getType()) - { - case CIMDataType::UINT8: - try - { - cv = CIMValue(val.toUInt8()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toUInt8()); - } - break; - case CIMDataType::SINT8: - try - { - cv = CIMValue(val.toInt8()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toInt8()); - } - break; - case CIMDataType::UINT16: - try - { - cv = CIMValue(val.toUInt16()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toUInt16()); - } - break; - case CIMDataType::SINT16: - try - { - cv = CIMValue(val.toInt16()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toInt16()); - } - break; - case CIMDataType::UINT32: - try - { - cv = CIMValue(val.toUInt32()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toUInt32()); - } - break; - case CIMDataType::SINT32: - try - { - cv = CIMValue(val.toInt32()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toInt32()); - } - break; - case CIMDataType::UINT64: - try - { - cv = CIMValue(val.toUInt64()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toUInt64()); - } - break; - case CIMDataType::SINT64: - try - { - cv = CIMValue(val.toInt64()); - } - catch (Exception& e) - { - String v = getParameterMappedValue(m_inParamsDesc[i],val); - cv = CIMValue(v.toInt64()); - } - break; - case CIMDataType::BOOLEAN: - cv = CIMValue(val.toBool()); - break; - case CIMDataType::REAL32: - cv = CIMValue(val.toReal32()); - break; - case CIMDataType::REAL64: - cv = CIMValue(val.toReal64()); - break; + try + { + for (int i=0; i<m_inParamsDesc.size(); i++) + { + paramName = m_inParamsDesc[i].getName(); + if (param.equalsIgnoreCase(paramName)) + { + CIMValue cv(val); + switch (m_inParamsDesc[i].getType().getType()) + { + case CIMDataType::UINT8: + try + { + cv = CIMValue(val.toUInt8()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toUInt8()); + } + break; + case CIMDataType::SINT8: + try + { + cv = CIMValue(val.toInt8()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toInt8()); + } + break; + case CIMDataType::UINT16: + try + { + cv = CIMValue(val.toUInt16()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toUInt16()); + } + break; + case CIMDataType::SINT16: + try + { + cv = CIMValue(val.toInt16()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toInt16()); + } + break; + case CIMDataType::UINT32: + try + { + cv = CIMValue(val.toUInt32()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toUInt32()); + } + break; + case CIMDataType::SINT32: + try + { + cv = CIMValue(val.toInt32()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toInt32()); + } + break; + case CIMDataType::UINT64: + try + { + cv = CIMValue(val.toUInt64()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toUInt64()); + } + break; + case CIMDataType::SINT64: + try + { + cv = CIMValue(val.toInt64()); + } + catch (Exception& e) + { + String v = getParameterMappedValue(m_inParamsDesc[i],val); + cv = CIMValue(v.toInt64()); + } + break; + case CIMDataType::BOOLEAN: + cv = CIMValue(val.toBool()); + break; + case CIMDataType::REAL32: + cv = CIMValue(val.toReal32()); + break; + case CIMDataType::REAL64: + cv = CIMValue(val.toReal64()); + break; // case CIMDataType::DATETIME: // cv = CIMValue(val.toDateTime()); // break; // case CIMDataType::CHAR16: // cv = CIMValue(val.toChar16()); // break; - } + } - setInParamValue(CIMParamValue(paramName, cv)); - break; - } - } - } - catch (const CIMException& ce) - { - cerr << ce << CLPENDL; - m_returnValue = CIMValue((UInt32)-1); - m_errorMsg = String("Invalid parameter for method ") + paramName; - ret = false; - } - catch (Exception& e) - { - cerr << e << CLPENDL; - ret = false; - } - return ret; + setInParamValue(CIMParamValue(paramName, cv)); + break; + } + } + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + m_returnValue = CIMValue((UInt32)-1); + m_errorMsg = String("Invalid parameter for method ") + paramName; + ret = false; + } + catch (Exception& e) + { + cerr << e << CLPENDL; + ret = false; + } + return ret; } /** @@ -389,58 +528,58 @@ */ bool SMCmdMapping::setMethodToCall(String cmd) { - String params; - bool ret = true; + String params; + bool ret = true; - /* Parse the method invocation string for the class name, - method name and parameters. */ - try - { - Int32 idxStart = 0; - Int32 idxEnd = cmd.indexOf('.'); - m_methodClassName = cmd.substring(idxStart, idxEnd); + /* Parse the method invocation string for the class name, + method name and parameters. */ + try + { + Int32 idxStart = 0; + Int32 idxEnd = cmd.indexOf('.'); + m_methodClassName = cmd.substring(idxStart, idxEnd); - idxStart = idxStart+idxEnd+1; - idxEnd = cmd.indexOf('(', idxStart) - idxStart; - m_methodToCall = cmd.substring(idxStart, idxEnd); + idxStart = idxStart+idxEnd+1; + idxEnd = cmd.indexOf('(', idxStart) - idxStart; + m_methodToCall = cmd.substring(idxStart, idxEnd); - idxStart = idxStart+idxEnd+1; - idxEnd = cmd.indexOf(')', idxStart) - idxStart; - params = cmd.substring(idxStart, idxEnd); - } - catch (const CIMException& ce) - { - cerr << ce << CLPENDL; - m_returnValue = CIMValue((UInt32)-1); - m_errorMsg = String("Invalid method invocation string"); - ret = false; - } - catch (Exception& e) - { - cerr << e << CLPENDL; - ret = false; - } + idxStart = idxStart+idxEnd+1; + idxEnd = cmd.indexOf(')', idxStart) - idxStart; + params = cmd.substring(idxStart, idxEnd); + } + catch (const CIMException& ce) + { + cerr << ce << CLPENDL; + m_returnValue = CIMValue((UInt32)-1); + m_errorMsg = String("Invalid method invocation string"); + ret = false; + } + catch (Exception& e) + { + cerr << e << CLPENDL; + ret = false; + } - /* Get the method description from the CIMOM so that it can - be matched with the actual parameter list. This will - tell us if everything lines up for the method call. */ - CIMClass cimCls = m_cimClient->getClass(m_methodClassName, E_NOT_LOCAL_ONLY, - E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN); - CIMMethod cimMthd = cimCls.getMethod(m_methodToCall); + /* Get the method description from the CIMOM so that it can + be matched with the actual parameter list. This will + tell us if everything lines up for the method call. */ + CIMClass cimCls = m_cimClient->getClass(m_methodClassName, E_NOT_LOCAL_ONLY, + E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN); + CIMMethod cimMthd = cimCls.getMethod(m_methodToCall); - if (cimMthd) - { - m_inParamsDesc = cimMthd.getINParameters(); - m_outParamsDesc = cimMthd.getOUTParameters(); - } - else - { - m_returnValue = CIMValue((UInt32)-1); - m_errorMsg = String("Method: ") + m_methodToCall + - String("doesn't exist for class ") + m_methodClassName; - ret = false; - } - return ret; + if (cimMthd) + { + m_inParamsDesc = cimMthd.getINParameters(); + m_outParamsDesc = cimMthd.getOUTParameters(); + } + else + { + m_returnValue = CIMValue((UInt32)-1); + m_errorMsg = String("Method: ") + m_methodToCall + + String("doesn't exist for class ") + m_methodClassName; + ret = false; + } + return ret; } /** @@ -448,43 +587,43 @@ */ String SMCmdMapping::getReturnValueText() { - /* Initialize the return value */ - String msg(""); + /* Initialize the return value */ + String msg(""); - /* If we don't have a contained object then bail out */ - if (!m_cimObjectPath) - return msg; + /* If we don't have a contained object then bail out */ + if (!m_cimObjectPath) + return msg; - /* Get the CIMMethod object for the called method */ - String clsName = m_cimObjectPath.getClassName(); - CIMClass cimCls = m_cimClient->getClass(clsName, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN); - CIMMethod cimMeth = cimCls.getMethod(m_methodCalled); + /* Get the CIMMethod object for the called method */ + String clsName = m_cimObjectPath.getClassName(); + CIMClass cimCls = m_cimClient->getClass(clsName, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN); + CIMMethod cimMeth = cimCls.getMethod(m_methodCalled); - if (cimMeth) - { - /* Get the valueMap and values for the called method */ - String retValue = m_returnValue.toString(); - CIMQualifier returnsMap = cimMeth.getQualifier("ValueMap"); - CIMQualifier returnsMsgs = cimMeth.getQualifier("Values"); - if (returnsMap && returnsMsgs) - { - /* Tokenize the string array so that we can match up the return - value with the value map */ - StringArray returnsMapSA = returnsMap.getValue().toStringArray(); - StringArray returnsMsgsSA = returnsMsgs.getValue().toStringArray(); + if (cimMeth) + { + /* Get the valueMap and values for the called method */ + String retValue = m_returnValue.toString(); + CIMQualifier returnsMap = cimMeth.getQualifier("ValueMap"); + CIMQualifier returnsMsgs = cimMeth.getQualifier("Values"); + if (returnsMap && returnsMsgs) + { + /* Tokenize the string array so that we can match up the return + value with the value map */ + StringArray returnsMapSA = returnsMap.getValue().toStringArray(); + StringArray returnsMsgsSA = returnsMsgs.getValue().toStringArray(); - for (int i=0;i<returnsMapSA.size();i++) - { - if (retValue.equals(returnsMapSA[i])) - { - msg = returnsMsgsSA[i]; - break; - } - } - } - } + for (int i=0;i<returnsMapSA.size();i++) + { + if (retValue.equals(returnsMapSA[i])) + { + msg = returnsMsgsSA[i]; + break; + } + } + } + } - return msg; + return msg; } /** @@ -492,34 +631,67 @@ */ String SMCmdMapping::getParameterMappedValue(CIMParameter param, String val) { - /* Initialize the return value */ - String retVal(""); + /* Initialize the return value */ + String retVal(""); - /* Get the valueMap and values for the parameter */ - CIMQualifier paramMap = param.getQualifier(CIMName("ValueMap")); - CIMQualifier paramValues = param.getQualifier(CIMName("Values")); + /* Get the valueMap and values for the parameter */ + CIMQualifier paramMap = param.getQualifier(CIMName("ValueMap")); + CIMQualifier paramValues = param.getQualifier(CIMName("Values")); - if (paramMap && paramValues) - { - /* Tokenize the string array so that we can match up the command - line value with the the value map */ - StringArray paramMapSA = paramMap.getValue().toStringArray(); - StringArray paramValuesSA = paramValues.getValue().toStringArray(); - STRIP_QUOTES(val); + if (paramMap && paramValues) + { + /* Tokenize the string array so that we can match up the command + line value with the the value map */ + StringArray paramMapSA = paramMap.getValue().toStringArray(); + StringArray paramValuesSA = paramValues.getValue().toStringArray(); + STRIP_QUOTES(val); - for (int i=0; i<paramValuesSA.size(); i++) - { - if (val.equalsIgnoreCase(paramValuesSA[i])) - { - retVal = paramMapSA[i]; - break; - } - } - } + for (int i=0; i<paramValuesSA.size(); i++) + { + if (val.equalsIgnoreCase(paramValuesSA[i])) + { + retVal = paramMapSA[i]; + break; + } + } + } - return retVal; + return retVal; } +/** +* Get the mapped value for a property +*/ +String SMCmdMapping::getPropertyMappedValue(CIMProperty prop, String val) +{ + /* Initialize the return value */ + String retVal(""); + /* Get the valueMap and values for the parameter */ + CIMQualifier qualMap = prop.getQualifier(CIMName("ValueMap")); + CIMQualifier qualValues = prop.getQualifier(CIMName("Values")); + + if (qualMap && qualValues) + { + /* Tokenize the string array so that we can match up the command + line value with the the value map */ + StringArray qualMapSA = qualMap.getValue().toStringArray(); + StringArray qualValuesSA = qualValues.getValue().toStringArray(); + STRIP_QUOTES(val); + + for (int i=0; i<qualValuesSA.size(); i++) + { + if (val.equalsIgnoreCase(qualValuesSA[i])) + { + retVal = qualMapSA[i]; + break; + } + } + } + + return retVal; } + +} + Modified: clp/trunk/src/omcclpcmdmapping.h =================================================================== --- clp/trunk/src/omcclpcmdmapping.h 2006-12-08 22:43:44 UTC (rev 417) +++ clp/trunk/src/omcclpcmdmapping.h 2006-12-08 22:45:14 UTC (rev 418) @@ -36,6 +36,7 @@ #include <openwbem/OW_CIMValue.hpp> #include <openwbem/OW_CIMParamValue.hpp> #include <openwbem/OW_CIMParameter.hpp> +#include <openwbem/OW_CIMProperty.hpp> namespace OMCCLP { @@ -84,6 +85,7 @@ String getReturnValueText(); String getParameterMappedValue(CIMParameter param, String val); + String getPropertyMappedValue(CIMProperty prop, String val); String getErrorMsgText() const {return m_errorMsg;} CIMValue getReturnValue() const {return m_returnValue;} CIMParamValueArray getInParamValues () {return m_inParams;} @@ -101,6 +103,7 @@ bool setMethodToCall(String cmd); void setProperty (const String name, const CIMValue value); + CIMValue resolveMappedValue (const CIMProperty prop, const String val); protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |