Files
VPNaaS-Migrator/ipsec_migrator/__pycache__/sprut_client.cpython-311.pyc
T

50 lines
4.6 KiB
Plaintext
Raw Normal View History

2026-07-21 15:05:52 +03:00
§
.1^j# ãóTdZddlmZddlZddlZddlZddlmZGdd¦«ZdS)aREST client for the Sprut SDN API.
Mirrors sprut_api_call() from the bash original. Token, dry-run flag and
base URL are fixed at construction (replacing the bash globals $token /
$DRY_RUN / $sprut_api_base read by every call site) and a single
requests.Session is reused across all calls for connection reuse -- a
behaviorally-neutral efficiency improvement over one curl process per call.
The only deliberate behavioral deviation from the bash original (confirmed
with the user): a 30s timeout is applied to every HTTP call. curl in the
original has no --max-time at all, so a hung Sprut endpoint would hang the
whole script indefinitely; a timeout here is treated exactly like a non-2xx
response (error message to stderr, exit 1), so no new failure mode is
introduced, just an upper bound on how long a stuck call can hang.
The Keystone token is never refreshed after construction -- this directly
carries over the "token not refreshed across STAGE 2-4" known limitation
from the bash original. Do not add retry-on-401 here.
é)Ú annotationsNé)Ú
redact_pskcó2eZdZddd „ZdddZddZddZd
S)Ú SprutClientç>@Úbase_urlÚstrÚtokenÚdry_runÚboolÚtimeoutÚfloatcóÚ| d¦«|_||_||_||_t j¦«|_|jj  d|ddœ¦«dS)/zapplication/jsonÚSPRUT)z Content-Typez X-Auth-TokenzX-SDN)
Úrstripr r r rÚrequestsÚSessionÚ_sessionÚheadersÚupdate)Úselfr r r rs ú3/root/vkcloud/vpnaas/ipsec_migrator/sprut_client.pyÚ__init__zSprutClient.__init__stØ Ÿš¨ÑŒ
؈Œ
؈Œ ؈Œ Ý ÔŒ
Ø Œ
Ô×$à 2Ø %Ø ð
ð
ñ
ô
ð
ð
ð
ómethodÚpathÚdataú dict | NoneÚreturnÚdictc ó |j|}|jrj|dkrdtd|d|tj¬¦«|r?tdt jt|¦«d¬¦«tj¬¦«iS |j  ||||nd|j
¬¦«}nY#tj j
$rB}td |d|d
|tj¬¦«tjd ¦«Yd}~nd}~wwxYwd |jcxkrd
ksbntd |d|d|jtj¬¦«td|jtj¬¦«tjd ¦«|jsiS| ¦«S)GETz[DRY-RUN] Would ú )Úfilez[DRY-RUN] Body: é)Úindent)ÚjsonrzError: Sprut API z failed: réÈi,z returned HTTP z
Response: )r r ÚprintÚsysÚstderrr)ÚdumpsrrÚrequestrrÚ
exceptionsÚRequestExceptionÚexitÚ status_codeÚtext)rrrrÚurlÚresponseÚexcs rÚcallzSprutClient.call-ØÐ& Ð&ˆà Œ<ð ˜F ešO˜ Ð3 3¨cÐ3½#¼*Ð ð
dÝÐQ­¬µJ¸tÑ4DÔ4DÈQÐ)OÑ)OÔ)OÐQÕX[ÔXbЈIð Ø”}ט¨$Ð*: $ $ÀÈdÌlðôˆHˆHøõÔ ð ð Ý ÐB fÐB¨sÐB¸SÐÌÐ ŒHQ‰KŒKˆKˆKˆKˆKˆKˆKøøøøð øøøð0¨SÒ ÐY fÐY¨sÐYÀ8ÔCWÐYÕ`cÔ`jÐ Ð.˜xœ}Ð.µS´ZÐ ŒHQ‰KŒKˆKàŒ}ð ØˆIØ}Š}‰ŒÐsÁ>'B&Â&C<Â:8C7Ã7C<có.| d|¦«S)Nr$©r8)rrs rÚgetzSprutClient.getGsØyŠy˜ Ñ%rcó0| d||¦«S)POSTr:)rrrs rÚpostzSprutClient.postJsØyŠy˜  ,r)r)r r
r r
r r
rr)N)rr
rr
rr r!r")rr
r!r")rr
rr"r!r")Ú__name__Ú
__module__Ú __qualname__rr8r;r>©rrrrsnð 
ð