Changeset 2998

Show
Ignore:
Timestamp:
11/07/08 09:17:57 (2 months ago)
Author:
kkaempf
Message:

eval plugin method return value and convert to WsmanStatus?
pass WsXmlDoc? to TargetCall? to allow wsman_generate_fault()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openwsman/trunk/src/plugins/swig/src/swig-plugin.c

    r2993 r2998  
    200200    TARGET_THREAD_BEGIN_BLOCK;  
    201201    _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 
    202     rc = TargetCall(_TARGET_MODULE, "identify", 1, _context);  
     202    rc = TargetCall(cntx->indoc, _TARGET_MODULE, "identify", 1, _context);  
    203203    TARGET_THREAD_END_BLOCK; 
    204204    return rc; 
     
    210210                void *opaqueData ) 
    211211{ 
    212     Target_Type _context; 
     212    Target_Type _context, _enumInfo; 
     213    Target_Type _status; 
    213214    int rc; 
    214215    TARGET_THREAD_BEGIN_BLOCK;  
    215216    _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 
    216     rc = TargetCall(_TARGET_MODULE, "enumerate", 1, _context ); 
     217    _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 
     218    _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 
     219    rc = TargetCall(cntx->indoc, _TARGET_MODULE, "enumerate", 3, _context, _enumInfo, _status ); 
    217220    TARGET_THREAD_END_BLOCK; 
    218221    return rc; 
     
    226229{ 
    227230    Target_Type _context; 
     231    Target_Type _enumInfo; 
     232    Target_Type _status; 
    228233    int rc; 
    229234    TARGET_THREAD_BEGIN_BLOCK;  
    230235    _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 
    231     rc = TargetCall(_TARGET_MODULE, "release", 0 ); 
     236    _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 
     237    _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 
     238    rc = TargetCall(cntx->indoc, _TARGET_MODULE, "release", 3, _context, _enumInfo, _status ); 
    232239    TARGET_THREAD_END_BLOCK; 
    233240    return rc; 
     
    241248{ 
    242249    Target_Type _context; 
     250    Target_Type _enumInfo; 
     251    Target_Type _status; 
    243252    int rc; 
    244253    TARGET_THREAD_BEGIN_BLOCK;  
    245254    _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 
    246     rc = TargetCall(_TARGET_MODULE, "pull", 1, _context ); 
     255    _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 
     256    _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 
     257    rc = TargetCall(cntx->indoc, _TARGET_MODULE, "pull", 3, _context, _enumInfo, _status ); 
    247258    TARGET_THREAD_END_BLOCK; 
    248259    return rc; 
     
    253264Swig_Get_EP( SoapOpH op, void* appData, void *opaqueData ) 
    254265{ 
    255     Target_Type _context; 
    256     int rc; 
    257     TARGET_THREAD_BEGIN_BLOCK;  
    258     rc = TargetCall(_TARGET_MODULE, "get", 0 ); 
     266    Target_Type _op; 
     267    int rc; 
     268    WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 
     269    TARGET_THREAD_BEGIN_BLOCK;  
     270    _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 
     271   
     272    rc = TargetCall(in_doc, _TARGET_MODULE, "get", 1, _op ); 
    259273    TARGET_THREAD_END_BLOCK; 
    260274    return rc; 
     
    265279Swig_Custom_EP( SoapOpH op, void* appData, void *opaqueData ) 
    266280{ 
    267     Target_Type _context; 
    268     int rc; 
    269     TARGET_THREAD_BEGIN_BLOCK;  
    270     rc = TargetCall(_TARGET_MODULE, "custom", 0 ); 
     281    Target_Type _op; 
     282    int rc; 
     283    WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 
     284    TARGET_THREAD_BEGIN_BLOCK;  
     285    _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 
     286    rc = TargetCall(in_doc, _TARGET_MODULE, "custom", 1, _op ); 
    271287    TARGET_THREAD_END_BLOCK; 
    272288    return rc; 
     
    277293Swig_Put_EP( SoapOpH op, void* appData, void *opaqueData ) 
    278294{ 
    279     Target_Type _context; 
    280     int rc; 
    281     TARGET_THREAD_BEGIN_BLOCK;  
    282     rc = TargetCall(_TARGET_MODULE, "put", 0 ); 
     295    Target_Type _op; 
     296    int rc; 
     297    WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 
     298    TARGET_THREAD_BEGIN_BLOCK;  
     299    _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 
     300    rc = TargetCall(in_doc, _TARGET_MODULE, "put", 1, _op ); 
    283301    TARGET_THREAD_END_BLOCK; 
    284302    return rc; 
     
    289307Swig_Create_EP( SoapOpH op, void* appData, void *opaqueData ) 
    290308{ 
    291     Target_Type _context; 
    292     int rc; 
    293     TARGET_THREAD_BEGIN_BLOCK;  
    294     rc = TargetCall(_TARGET_MODULE, "create", 0 ); 
     309    Target_Type _op; 
     310    int rc; 
     311    WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 
     312    TARGET_THREAD_BEGIN_BLOCK;  
     313    _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 
     314    rc = TargetCall(in_doc, _TARGET_MODULE, "create", 1, _op ); 
    295315    TARGET_THREAD_END_BLOCK; 
    296316    return rc; 
     
    302322Swig_Delete_EP( SoapOpH op, void* appData, void *opaqueData ) 
    303323{ 
    304     Target_Type _context; 
    305     int rc; 
    306     TARGET_THREAD_BEGIN_BLOCK;  
    307     rc = TargetCall(_TARGET_MODULE, "delete", 0 ); 
     324    Target_Type _op; 
     325    int rc; 
     326    WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 
     327    TARGET_THREAD_BEGIN_BLOCK;  
     328    _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 
     329    rc = TargetCall(in_doc, _TARGET_MODULE, "delete", 1, _op ); 
    308330    TARGET_THREAD_END_BLOCK; 
    309331    return rc; 
  • openwsman/trunk/src/plugins/swig/src/target_python.c

    r2993 r2998  
    187187 
    188188static int  
    189 TargetCall(PyObject* instance,  
     189TargetCall(WsXmlDocH doc, PyObject* instance,  
    190190                 const char* opname, int nargs, ...) 
    191191{ 
    192     int rc = 1;  
    193192    va_list vargs;  
    194193    PyObject *pyargs = NULL;  
     
    210209 
    211210        free(str);  
    212         rc = 1;  
    213211        goto cleanup;  
    214212    } 
     
    221219        status.fault_detail_code = 0; 
    222220        free(str);  
    223         rc = 1;  
    224221        goto cleanup;  
    225222    } 
     
    241238    if (PyErr_Occurred()) 
    242239    { 
    243        status.fault_code = WSA_ENDPOINT_UNAVAILABLE
     240        status.fault_code = WSMAN_INTERNAL_ERROR
    244241        status.fault_detail_code = 0; 
    245242        PyErr_Clear();  
    246         rc = 1;  
    247243        goto cleanup;  
    248244    } 
     
    252248    { 
    253249        TARGET_THREAD_BEGIN_ALLOW; 
    254         char* str = fmtstr("Python function \"%s\" didn't return a two-tuple", 
    255                 opname);  
    256         debug("%s", str);  
    257         status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 
    258         status.fault_detail_code = 0; 
    259         free(str);  
    260         rc = 1;  
     250        status.fault_msg = fmtstr("Python function \"%s\" didn't return a two-tuple", opname);  
     251        status.fault_code = WSMAN_INTERNAL_ERROR; 
     252        status.fault_detail_code = 0; 
    261253        TARGET_THREAD_END_ALLOW;  
    262254        goto cleanup;  
     
    272264    { 
    273265        TARGET_THREAD_BEGIN_ALLOW; 
    274         char* str = fmtstr("Python function \"%s\" didn't return a {<int>, <int>) two-tuple", opname);  
    275         debug("%s", str);  
    276         status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 
    277         status.fault_detail_code = 0; 
    278         free(str);  
    279         rc = 1;  
     266        status.fault_msg = fmtstr("Python function \"%s\" didn't return a {<int>, <int>) two-tuple", opname);  
     267        status.fault_code = WSMAN_INTERNAL_ERROR; 
     268        status.fault_detail_code = 0; 
    280269        TARGET_THREAD_END_ALLOW;  
    281270        goto cleanup;  
     
    284273    if (detail == Py_None) 
    285274    { 
    286         status.fault_code = WSA_ENDPOINT_UNAVAILABLE
     275        status.fault_code = WSMAN_INTERNAL_ERROR
    287276        status.fault_detail_code = 0; 
    288277    } 
     
    291280        status.fault_detail_code = PyInt_AsLong(detail); 
    292281    } 
    293     rc = code != 0; 
    294282cleanup: 
     283    if (status.fault_code != WSMAN_RC_OK) 
     284      wsman_generate_fault( doc, status.fault_code, status.fault_detail_code, status.fault_msg ); 
    295285    Py_DecRef(pyargs); 
    296286    Py_DecRef(pyfunc); 
    297287    Py_DecRef(result); 
    298288  
    299     return rc;  
     289    return status.fault_code != WSMAN_RC_OK;  
    300290} 
    301291 
     
    355345      return -1;  
    356346    } 
     347    *data = _TARGET_MODULE; 
    357348  } 
    358349  pthread_mutex_unlock(&_PLUGIN_INIT_MUTEX); 
  • openwsman/trunk/src/plugins/swig/src/target_ruby.c

    r2993 r2998  
    202202/* 
    203203 * TargetCall 
    204  * Call function 'opname' with nargs arguments within managed interface hdl->instance 
     204 * Call function 'opname' with nargs arguments within instance 
     205 *  
     206 * doc: in_doc from context, needed for fault generation 
     207 * instance: klass 
     208 * opname: name of method to call 
     209 * nargs: number of arguments 
     210 * ...: arguments as varargs 
     211 *  
    205212 */ 
    206213 
    207214static int  
    208 TargetCall(VALUE instance, const char* opname, int nargs, ...) 
     215TargetCall(WsXmlDocH doc, VALUE instance, const char* opname, int nargs, ...) 
    209216{ 
    210217  int i;  
     
    212219  va_list vargs;  
    213220  WsmanStatus status; 
     221  wsman_status_init(&status); 
    214222 
    215223  debug("TargetCall(Ruby): %s", opname); 
     
    250258    { 
    251259      char *trace = get_exc_trace(); 
    252       char *str = fmtstr("Ruby: calling '%s' failed: %s", opname, trace);  
    253       error("%s", str); 
     260      status.fault_msg = fmtstr("Ruby: calling '%s' failed: %s", opname, trace);  
     261      status.fault_code = WSMAN_INTERNAL_ERROR; 
     262      status.fault_detail_code = 0; 
     263      error("%s", status.fault_msg); 
    254264      return 1; 
    255265    } 
    256   wsman_status_init(&status); 
    257266   
    258267  if (NIL_P(result)) /* not or wrongly implemented */ 
     
    265274  if (result != Qtrue) 
    266275    { 
     276      int len; 
    267277      VALUE resulta = rb_check_array_type(result); 
    268       VALUE code, detail; 
     278       
    269279      if (NIL_P(resulta)) 
    270280        { 
    271           message(fmtstr("Ruby: calling '%s' returned unknown result", opname)); 
    272           status.fault_code = WSA_ENDPOINT_UNAVAILABLE
     281          status.fault_msg = fmtstr("Ruby: calling '%s' returned unknown result", opname); 
     282          status.fault_code = WSMAN_INTERNAL_ERROR
    273283          status.fault_detail_code = 0; 
    274284          return 1; 
    275285        } 
    276286   
    277       code = rb_ary_entry(resulta, 0); 
    278       detail = rb_ary_entry(resulta, 1); 
    279       if (!FIXNUM_P(code)) 
     287      len = RARRAY(resulta)->len; 
     288      if (len > 0)  
    280289        { 
    281           message(fmtstr("Ruby: calling '%s' returned non-numeric code", opname));  
    282           status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 
    283           status.fault_detail_code = 0; 
    284           return 1; 
     290          VALUE code = rb_ary_entry(resulta, 0); 
     291          if (!FIXNUM_P(code)) 
     292            { 
     293              status.fault_msg = fmtstr("Ruby: calling '%s' returned non-numeric code", opname); 
     294              status.fault_code = WSMAN_INTERNAL_ERROR; 
     295              status.fault_detail_code = 0; 
     296              return 1; 
     297            } 
     298          status.fault_code = FIX2LONG(code); 
    285299        } 
    286       status.fault_code = FIX2LONG(code); 
    287       status.fault_detail_code = FIX2LONG(detail); 
    288       return 1; 
     300       
     301      if (len > 1)  
     302        { 
     303          VALUE detail = rb_ary_entry(resulta, 1); 
     304          if (!FIXNUM_P(detail)) 
     305            { 
     306              status.fault_msg = fmtstr("Ruby: calling '%s' returned non-numeric detail", opname); 
     307              status.fault_code = WSMAN_INTERNAL_ERROR; 
     308              status.fault_detail_code = 0; 
     309              return 1; 
     310            } 
     311          status.fault_detail_code = FIX2LONG(detail); 
     312        } 
     313      if (len > 2) 
     314        { 
     315          VALUE str = rb_ary_entry(resulta, 2); 
     316          status.fault_msg = StringValuePtr(str); 
     317        } 
     318      wsman_generate_fault( doc, status.fault_code, status.fault_detail_code, status.fault_msg ); 
    289319    } 
    290320