microsoft / omi-script-provider

Script Provider for the OMI Project
Other
8 stars 7 forks source link

Can’t set value for String array #61

Closed Wayenyin closed 6 years ago

Wayenyin commented 6 years ago

Build:

Reproduce steps:

  1. Write mof file with String array: class TestClass_AllDMTFArrays { [key] uint64 v_Key; String a_string[]; };
  2. Generate above test1.mof and add code like following in mi_main.py:
    root@ omi64-cent7-01: cd /root/TestClass_AllDMTFArrays/; /opt/omi/bin/omigen_py -I /root/TestClass_AllDMTFArrays/ /root/TestClass_AllDMTFArrays/TestClass_AllDMTFArrays.mof TestClass_AllDMTFArrays
    Creating "schema.py"
    Creating "mi_main.py"
    def TestClass_AllDMTFArrays_EnumerateInstances (
    context, nameSpace, className, propertySet, keysOnly):
    instance = context.NewInstance ('TestClass_AllDMTFArrays')
    instance.SetValue ('v_Key', MI_Uint64 (0))
    stringArr = MI_StringA()
    stringArr.append(MI_String('Test0'))
    instance.SetValue ('a_string', stringArr)
    context.PostInstance (instance)
    context.PostResult (MI_RESULT_OK)
  3. Register your provider.
    /opt/omi/lib
    root@omi64-cent7-01  # _/opt/omi/bin/omireg --Python TestClass_AllDMTFArrays_
     Created /etc/opt/omi/conf/omiregister/root-cimv2/TestClass_AllDMTFArrays.reg
     /opt/omi/bin/omiserver: refreshed server
  4. Run ei
    /opt/omi/lib
    root@omi64-cent7-01  # /opt/omi/bin/omicli ei root/cimv2  TestClass_AllDMTFArrays
     /opt/omi/bin/omicli: result: MI_RESULT_FAILED
     /opt/omi/bin/omicli: result: A general error occurred, not covered by a more specific error code.
     instance of OMI_Error
    {
       OwningEntity=OMI:CIMOM
       MessageID=OMI:MI_Result:1
       Message=A general error occurred, not covered by a more specific error code.
       MessageArguments={}
       PerceivedSeverity=7
       ProbableCause=0
       ProbableCauseDescription=Unknown
       CIMStatusCode=1
       OMI_Code=1
       OMI_Category=0
       OMI_Type=MI
       OMI_ErrorMessage=A general error occurred, not covered by a more specific error code.
    }

    NOTE: If you try to set as following, it will work fine.

    • mof file with string: class TestClass_AllDMTFArrays { [key] uint64 v_Key; String a_string; };
JumpingYang001 commented 6 years ago

Verified on private build.