microsoft / omi-script-provider

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

omicli hang when post instance in python function #65

Closed Wayenyin closed 7 years ago

Wayenyin commented 7 years ago

Build

Reproduce steps

  1. Write mof file: class TestClass_AllDMTFArrays { [key] uint64 v_Key; Boolean a_bool[]; Uint8 a_uint8[]; };
  2. Generate above test1.mof and add code like following in mi_main.py: root@ omi64-cent7-01: /root/TestClass_AllDMTFArrays/; /opt/omi/bin/omigen_py -I /root/TestClass_AllDMTFArrays/ /root/TestClass_AllDMTFArrays/TestClass_AllDMTFArrays.mof TestClass_AllDMTFArrays
  def TestClass_AllDMTFArrays_CreateInstance (
        context, nameSpace, className, instance):
        be = BookEnd ('TestClass_AllDMTFArrays_CreateInstance')
        createKey = instance.GetValue('v_Key').value
        instanceTemp = context.NewInstance ('TestClass_AllDMTFArrays')
        instanceTemp.SetValue('v_Key', MI_Uint64(createKey))
        context.PostInstance(instanceTemp)             
        instanceStore.append(instanceTemp)
        context.PostResult (MI_RESULT_OK)
  1. 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
  2. Run ci, and this command will hang
    /opt/omi/lib
    root@omi64-cent7-01  # /opt/omi/bin/omicli ci root/cimv2 { TestClass_AllDMTFArrays  v_Key 4 } 

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

JumpingYang001 commented 7 years ago

full provider: https://github.com/Microsoft/ostc-automation/blob/master/OMIAutomation/OMIAutomation/Provider_TestAllDMTFArrays/mi_main.py

JumpingYang001 commented 7 years ago

We verified on our own private build and looks like it doesn't fix, anyway, we will verify with tomorrow's build to double check, thanks.

c64cosmin commented 7 years ago

I don't think you need to do postInstance there. Afterall, the server already got the instance object on server side. Posting it back to the client is useless because the client supposedly has the instance, hence sending it for Create Instance command.

Unless the client needs to get "instance data" back from server while doing Create Instance command.

EMumau commented 7 years ago

Yes. You should not be calling PostInstance in a CreateInstance method.

EMumau commented 7 years ago

This should be fixed in PR #77

Wayenyin commented 7 years ago

Verified on Python provider build 1.1.1-47 and the 'create' operation can be posted.

root@omi64-cent7-01  # /opt/omi/bin/omicli  ci root/cimv2 { TestClass_AllDMTFArrays v_Key 4 }
instance of TestClass_AllDMTFArrays
{
    [Key] v_Key=4
}