rmLbc@s"ddlZejjddddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z ddlmZejeZd Zd Zd efd YZd efdYZdefdYZdefdYZdefdYZdS(iNis/usr/lib/fence-agents/bundled(tget_service_module_name(tWaiterDocstringi(t WaiterErrort ClientErrortWaiterConfigError(t xform_namec Cs|j|}t|j}tt||}d}td|d|jjd|jjd|dt |_ t dt |jj|f}t |tfi|d6}||||S( s :type waiter_name: str :param waiter_name: The name of the waiter. The name should match the name (including the casing) of the key name in the waiter model file (typically this is CamelCasing). :type waiter_model: botocore.waiter.WaiterModel :param waiter_model: The model for the waiter configuration. :type client: botocore.client.BaseClient :param client: The botocore client associated with the service. :rtype: botocore.waiter.Waiter :return: The waiter object. c[stj||dS(N(tWaitertwait(tselftkwargs((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR6st waiter_namet event_emittert service_modeltservice_waiter_modeltinclude_signatures %s.Waiter.%sR(t get_waiterRt operationtNormalizedOperationMethodtgetattrRtmetateventsR tFalset__doc__tstrRttypeR( R t waiter_modeltclienttsingle_waiter_configtoperation_nametoperation_methodRtwaiter_class_nametdocumented_waiter_cls((s0/usr/lib/fence-agents/bundled/botocore/waiter.pytcreate_waiter_with_clients$     cCs2|jd}t|tr.d|kr.tStS(NtErrortCode(tgett isinstancetdicttTrueR(tresponseterror((s0/usr/lib/fence-agents/bundled/botocore/waiter.pytis_valid_waiter_errorPsRcBseZdZdZRS(cCs ||_dS(N(t_client_method(Rt client_method((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyt__init__XscKs/y|j|SWntk r*}|jSXdS(N(R*RR'(RR te((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyt__call__[s(t__name__t __module__R,R.(((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRWs t WaiterModelcBs)eZdZdZdZdZRS(icCsX|d|_|jdd}|j|||_tt|dj|_dS(s Note that the WaiterModel takes ownership of the waiter_config. It may or may not mutate the waiter_config. If this is a concern, it is best to make a copy of the waiter config before passing it to the WaiterModel. :type waiter_config: dict :param waiter_config: The loaded waiter config from the *.waiters.json file. This can be obtained from a botocore Loader object as well. twaiterstversiontunknownN(t_waiter_configR#t_verify_supported_versionR3tlisttsortedtkeyst waiter_names(Rt waiter_configR3((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR,es    cCs2||jkr.tdd|j|fndS(Nt error_msgs^Unsupported waiter version, supported version must be: %s, but version of waiter config is: %s(tSUPPORTED_VERSIONR(RR3((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR6}s cCs?y|j|}Wn!tk r4td|nXt|S(NsWaiter does not exist: %s(R5tKeyErrort ValueErrortSingleWaiterConfig(RR R((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRs  (R/R0R=R,R6R(((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR1bs  R@cBs&eZdZdZedZRS(sRepresents the waiter configuration for a single waiter. A single waiter is considered the configuration for a single value associated with a named waiter (i.e TableExists). cCsI||_|jdd|_|d|_|d|_|d|_dS(Nt descriptiontRtdelayt maxAttempts(t_configR#RARRCt max_attempts(RR((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR,s    cCs;g}x.|jdD]}t|}|j|qW|S(Nt acceptors(REtAcceptorConfigtappend(RRGtacceptor_configtacceptor((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRGs  (R/R0RR,tpropertyRG(((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR@s RHcBsVeZdZedZdZdZdZdZdZ dZ RS(cCsL|d|_|d|_|d|_|jd|_|j|_dS(Ntstatetmatchertexpectedtargument(RMRNROR#RPt_create_matcher_funct matcher_func(Rtconfig((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR,s    cCs|jdkr#d|j|jfS|jdkrFd|j|jfS|jdkrid|j|jfS|jdkrd|jS|jd krd |jSd |jSdS( Ntpaths2For expression "%s" we matched expected path: "%s"tpathAlls;For expression "%s" all members matched excepted path: "%s"tpathAnys@For expression "%s" we matched expected path: "%s" at least oncetstatuss%Matched expected HTTP status code: %sR(s'Matched expected service error code: %ss,No explanation for unknown waiter type: "%s"(RNRPRO(R((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyt explanations  cCs|jdkr|jS|jdkr2|jS|jdkrK|jS|jdkrd|jS|jdkr}|jStdd|jdS(NRTRURVRWR(R<sUnknown acceptor: %s(RNt_create_path_matchert_create_path_all_matchert_create_path_any_matchert_create_status_matchert_create_error_matcherR(R((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRQs      cs1tj|j|jfd}|S(Ncs#t|rdSj|kS(N(R)tsearch(R'(ROt expression(s0/usr/lib/fence-agents/bundled/botocore/waiter.pytacceptor_matchess (tjmespathtcompileRPRO(RR`((ROR_s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRYs cs1tj|j|jfd}|S(Ncs_t|rdSj|}t|t s6| r:tSx|D]}|krAtSqAWtS(N(R)R^R$R7RR&(R'tresulttelement(ROR_(s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR`s   (RaRbRPRO(RR`((ROR_s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRZs cs1tj|j|jfd}|S(Ncs_t|rdSj|}t|t s6| r:tSx|D]}|krAtSqAWtS(N(R)R^R$R7RR&(R'RcRd(ROR_(s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR`s   (RaRbRPRO(RR`((ROR_s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR[s cs|jfd}|S(Ncs%|jdijd}|kS(NtResponseMetadatatHTTPStatusCode(R#(R't status_code(RO(s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR` s (RO(RR`((ROs0/usr/lib/fence-agents/bundled/botocore/waiter.pyR\s cs|jfd}|S(Ncs"|jdijddkS(NR!R"RB(R#(R'(RO(s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR`s(RO(RR`((ROs0/usr/lib/fence-agents/bundled/botocore/waiter.pyR]s ( R/R0R,RLRXRQRYRZR[R\R](((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyRHs     RcBseZdZdZRS(cCs||_||_||_dS(s :type name: string :param name: The name of the waiter :type config: botocore.waiter.SingleWaiterConfig :param config: The configuration for the waiter. :type operation_method: callable :param operation_method: A callable that accepts **kwargs and returns a response. For example, this can be a method from a botocore client. N(t_operation_methodtnameRS(RRiRSR((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR,"s  c Kst|jj}d}|jdi}|jd|jj}|jd|jj}d}d}x`tr|j |} |d7}x|D](} | j | r| }| j }PqqWt | rt d|jdd | d jd d | d jd d fd| n|dkr/tjddS|dkrid| j} t d|jd| d| n||kr|dkrd} n d| j} t d|jd| d| ntj|qiWdS(Ntwaitingt WaiterConfigtDelayt MaxAttemptsiiRitreasonsAn error occurred (%s): %sR!R"tUnknowntMessaget last_responsetsuccesss3Waiting complete, waiter matched the success state.tfailures/Waiter encountered a terminal failure state: %ssMax attempts exceededs4Max attempts exceeded. Previously accepted state: %s(R7RSRGtpopR#RCRFtNoneR&RhRRRMR)RRitloggertdebugRXttimetsleep( RR RGt current_stateRSt sleep_amountRFtlast_matched_acceptort num_attemptsR'RKRn((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR7sT                   (R/R0R,R(((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyR!s (tsysRTtinsertRatloggingRxtbotocore.utilsRtbotocore.docs.docstringRt exceptionsRRRRBRt getLoggerR/RvR R)tobjectRR1R@RHR(((s0/usr/lib/fence-agents/bundled/botocore/waiter.pyt s     4  +z