microsoft / omi-script-provider

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

Can’t set real32 and real64 value to 0 #60

Closed LinfyZhai closed 6 years ago

LinfyZhai commented 6 years ago

Build: \\redmond\wsscfs\OSTCData\Builds\omi\develop\1.4.0-37 \\redmond\wsscfs\OSTCData\Builds\omiscriptprovider\develop\1.1.1-35 Reproduce steps:

  1. Write mof file:
    class test1
    {
        [key] uint64 v_Key;
        Real32 testR32;
    };
  2. Generate above test1.mof with below command: root@omi64-ubun16-01:/opt/omi/lib# /opt/omi/bin/omigen_py /opt/omi/lib/test1/schema.mof test1 -d /opt/omi/lib/test1/ And add code like following in mi_main.py:
    def test1_EnumerateInstances (
    context, nameSpace, className, propertySet, keysOnly):
    instance = context.NewInstance ('test1')
    instance.SetValue ('v_Key', MI_Uint32(1))
    instance.SetValue ('testR32', MI_Real32(0))
    context.PostInstance (instance)
    context.PostResult (MI_RESULT_OK)
  3. Register your provider and run ei.
    
    root@omi64-ubun16-01:/opt/omi/lib# /opt/omi/bin/omireg --Python test1
    Created /etc/opt/omi/conf/omiregister/root-cimv2/test1.reg
    /opt/omi/bin/omiserver: refreshed server
    root@omi64-ubun16-01:/opt/omi/lib# /opt/omi/bin/omicli ei root/cimv2 test1
    /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.
    }
Detail log as below:

root@omi64-ubun16-01:~# cat /var/opt/omi/log/omiagent.root.root.log 2017/11/08 18:54:46 [56144,56144] WARNING: null(0): EventId=30056 Priority=WARNING failed to call library unload: 1:test1 2017/11/08 18:57:25 [56177,56177] WARNING: null(0): EventId=30056 Priority=WARNING failed to call library unload: 1:test1

JumpingYang001 commented 6 years ago

This is an exist bug from the beginning, we just find it today.

JumpingYang001 commented 6 years ago

I have tried instance.SetValue('testR32',MI_Real32(0.0)), it also get the error.

c64cosmin commented 6 years ago

Fails even when a variable is passed as zero.

JumpingYang001 commented 6 years ago

@c64cosmin , do you mean a = 0 in the code? I tried this works fine.

alinbalutoiu commented 6 years ago

This issue should be fixed with the above patch:

$ omicli ei root/cimv2 test1
instance of test1
{
    [Key] v_Key=1
    testR32=0
}

Code:

def test1_EnumerateInstances (
    context, nameSpace, className, propertySet, keysOnly):
    instance = context.NewInstance ('test1')
    instance.SetValue ('v_Key', MI_Uint32(1))
    instance.SetValue ('testR32', MI_Real32(float(0)))
    context.PostInstance (instance)
    context.PostResult (MI_RESULT_OK)
JumpingYang001 commented 6 years ago

@alinbalutoiu , thanks for fixing it! Eric has added in his PR and I have merged to master. We'll verify all issues after new build come.

JumpingYang001 commented 6 years ago

Verified on private build.