1########################################################################### 2# 3# This program is part of Zenoss Core, an open source monitoring platform. 4# Copyright (C) 2008-2010, Zenoss Inc. 5# 6# This program is free software; you can redistribute it and/or modify it 7# under the terms of the GNU General Public License version 2, or (at your 8# option) any later version, as published by the Free Software Foundation. 9# 10# For complete information please visit: http://www.zenoss.com/oss/ 11# 12########################################################################### 13 14from pysamba.library import * 15from pysamba.rpc.credentials import CRED_SPECIFIED 16import logging 17 18log = logging.getLogger('p.composite_context') 19 20( COMPOSITE_STATE_INIT, COMPOSITE_STATE_IN_PROGRESS, 21 COMPOSITE_STATE_DONE, COMPOSITE_STATE_ERROR ) = range(4) 22 23class composite_context(Structure): pass 24composite_context_callback = CFUNCTYPE(None, POINTER(composite_context)) 25class async(Structure): 26 _fields_ = [ 27 ('fn', composite_context_callback), 28 ('private_data', c_void_p), 29 ] 30 31composite_context._fields_ = [ 32 ('state', enum), 33 ('private_data', c_void_p), 34 ('status', NTSTATUS), 35 ('event_ctx', c_void_p), # struct event_context * 36 ('async', async), 37 ('used_wait', BOOL), 38 ] 39 40# _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx, 41# struct event_context *ev); 42 43library.composite_create.restype = POINTER(composite_context) 44library.composite_create.argtypes = [c_void_p, c_void_p] 45library.composite_create = logFuncCall(library.composite_create) 46 47def composite_create(memctx, eventContext): 48 result = library.composite_create(memctx, eventContext) 49 if not result: 50 raise RuntimeError("Unable to allocate a composite_context") 51 return result 52 53# _PUBLIC_ BOOL composite_nomem(const void *p, struct composite_context *ctx); 54library.composite_nomem.restype = BOOL 55library.composite_nomem.argtypes = [c_void_p, POINTER(composite_context)] 56library.composite_nomem = logFuncCall(library.composite_nomem) 57 58library.composite_wait.restype = NTSTATUS 59library.composite_wait.argtypes = [POINTER(composite_context)] 60library.composite_wait = logFuncCall(library.composite_wait) 61library.composite_is_ok.restype = BOOL 62library.composite_is_ok.argtypes = [POINTER(composite_context)] 63library.composite_is_ok = logFuncCall(library.composite_is_ok) 64library.composite_error.restype = None 65library.composite_error.argtypes = [POINTER(composite_context), NTSTATUS] 66library.composite_error = logFuncCall(library.composite_error) 67library.composite_done.restype = None 68library.composite_done.argtypes = [POINTER(composite_context)] 69library.composite_done = logFuncCall(library.composite_done) 70