microsoft / omi-script-provider

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

[DOC] How to invoke function in python provider? #59

Closed JumpingYang001 closed 7 years ago

JumpingYang001 commented 7 years ago

Do we have any doc to describe how to invoke function in python provider like following function? https://github.com/Microsoft/omi-script-provider/blob/master/samples/omi_tester/omi_tester_schema.mof#L5

For current scope, we will support enumerate, modify, create, get, delete and invoke operation for python provider, right?

I am not sure if invoke support in this release or not.

JumpingYang001 commented 7 years ago

[In(false), Out] String Out1, For this parameter, how does Out parameter use for? what's the difference between In and Out, how can use them? I mean from like omicli iv root/cimv2 function1 ...

JumpingYang001 commented 7 years ago

In c provider, we don't have out parameter, we just input the parameters and then PostInstance and PostResult.

JumpingYang001 commented 7 years ago

We have tried following:

root@omi64-ubun16-01:/opt/omi/lib# /opt/omi/bin/omicli iv root/cimv2 { OMI_Tester *Key "ONE" } Func1
instance of Func1
{
    Out1=ONE
    Out2=1
    Out3=true
    ReturnValue=0
} 
JumpingYang001 commented 7 years ago

I have tried to make it work right now, but we still need to document something for these things?

def OMI_Tester_Func1 (
    context, nameSpace, className, methodName, instanceName, parameters):
    be = BookEnd ('OMI_Tester_Func1')
    BookEndPrint ('**********')
    BookEndPrint ('**********')
    BookEndPrint ('**********')
    BookEndPrint ('**********')
    BookEndPrint ('**********')

    outParams = context.NewParameters ('OMI_Tester', 'Func1')
    keyvalue = instanceName.GetValue('Key')
    in1 = parameters.GetValue('In1')
    outParams.SetValue ('Out1', MI_String (in1.value))
    outParams.SetValue ('Out2', MI_Uint32 (1))
    outParams.SetValue ('Out3', MI_Boolean (True))
    outParams.SetValue ('MIReturn', MI_Uint32 (0))
    context.PostInstance (outParams)
context.PostResult (MI_RESULT_OK)

root@omi64ub16-dev1:/opt/omi/lib/omi_tester# /opt/omi/bin/omicli iv root/cimv2 { OMI_Tester Key "ONE" } Func1 { In1 "test" }
instance of Func1
{
    Out1=test
    Out2=1
    Out3=true
    ReturnValue=0
}