>ac@sddlZddlZddlZddlmZddlmZmZmZddl m Z ddl m Z ej eZdefdYZdefd YZd efd YZd Zd efdYZdefdYZdefdYZdS(iN(t xform_name(t BotoCoreErrortHTTPClientErrortConnectionError(tOperationNotFoundError(tCachedPropertytEndpointDiscoveryExceptioncBseZRS((t__name__t __module__(((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyRstEndpointDiscoveryRequiredcBseZdZdZRS(sD Endpoint Discovery is disabled but is required for this operation. sAEndpoint Discovery is not enabled but this operation requires it.(RRt__doc__tfmt(((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyR stEndpointDiscoveryRefreshFailedcBseZdZdZRS(s? Endpoint Discovery failed to the refresh the known endpoints. s<Endpoint Discovery failed to refresh the required endpoints.(RRR R (((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyR "scKs.|j}|r*|jdr*tndS(Ntrequired(tendpoint_discoverytgetR (tmodeltkwargsR((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt,block_endpoint_discovery_required_operations's tEndpointDiscoveryModelcBsVeZdZedZedZdZdZdZddZ RS(cCs ||_dS(N(t_service_model(tselft service_model((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt__init__.scCs|jj}t|jS(N(Rtendpoint_discovery_operationRtname(Rtdiscovery_operation((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdiscovery_operation_name1s cCs:|jj}g}|jr6t|jjj}n|S(N(RRt input_shapetlisttmemberstkeys(RRR((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdiscovery_operation_keys6s   cCsBy)|jj|}|jjdtSWntk r=tSXdS(NR (Rtoperation_modelRRtFalseR(Rtoperation_nameR!((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdiscovery_required_for>s  c s[|j|jds;|jdd|jddntfd|jDS(Nt Identifierst Operationc3s-|]#\}}|kr||fVqdS(N((t.0tktv(t input_keys(s3/usr/lib/fence-agents/bundled/botocore/discovery.pys Ks(R RtpoptNonetdicttitems(RR((R*s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdiscovery_operation_kwargsEs  cCs|j|j|S(N(t _gather_idsR(Rt operationtparams((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytgather_identifiersMscCs|dkri}nxu|jjD]d\}}|jjdrT||||}s(RFR/RTRUR.(RR((Rs3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_create_cache_key{scCs|jj||S(N(RFR3(RR1R2((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyR3scKs/|j|}||jkr+|j|=ndS(N(RXR=(RRt cache_key((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdelete_endpointsscKsJ|jj|}|jj}t|j|}tjd|||S(Ns%Discovering endpoints with kwargs: %s(RFR/RtgetattrRDtloggertdebug(RRR#R((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_describe_endpointss  cCsM||jkrdS|j}g|j|D]}||dkr-|^q-S(NRM(R=R,R@(Rtkeytnowte((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_get_current_endpointss cKs|j|}yF|j|}|j|}||j|<|jj|d|SWn/ttfk r|j d|j|R+R,RRR@(RRRYRNRO((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_refresh_current_endpointss cCsC||jkr?|j}||j|kr2tS|j|=ntS(N(R>R@tTrueR"(RRYR`((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_recently_faileds   cCs |ddS(NitAddress((RRO((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyt_select_endpointscKs&|d}|jj|}|j rB| rBtjd|dS|j|}|j|}|rs|j|S|j |}|s|j |}|r|j|Sntjd||j j |d}|r|j|S|r"|r|j |}|r|j|Snt ndS(NR&sAOptional discovery disabled. Skipping discovery for Operation: %ss%Endpoint Discovery has failed for: %s(RFR$RAR\R]R,RXRbRgReRcR=RR (RRR1tdiscovery_requiredRYROtrecently_failedt stale_entries((s3/usr/lib/fence-agents/bundled/botocore/discovery.pytdescribe_endpoints6    N(RRR,RdRRRRWRXR3RZR^RbRcReRgRk(((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyR<]s        tEndpointDiscoveryHandlercBs5eZdZdZdZdZdZRS(cCs ||_dS(N(t_manager(Rtmanager((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyRscCsI|jd||j|jd||j|jd||jdS(Nsbefore-parameter-build.%ssrequest-created.%ssneeds-retry.%s(tregisterR3tregister_firsttdiscover_endpointthandle_retries(Rteventst service_id((s3/usr/lib/fence-agents/bundled/botocore/discovery.pyRos cKsC|j}|dkrdS|jj||}i|d6|d s    0|