@@ -340,37 +340,20 @@ def construct_neighbor_advertiser_slice():
340
340
return slice_obj
341
341
342
342
343
- def wrapped_ferret_request (request_slice , https_endpoint , http_endpoint ):
344
- """
345
- Attempts to reach ferret by first trying HTTPS, failing over to HTTP in
346
- case of failure (e.g. timeout, endpoint not found, etc.).
347
- """
343
+ def wrapped_ferret_request (request_slice , https_endpoint ):
348
344
response = None
349
345
350
346
# NOTE: While we transition to HTTPS we're disabling the verify field. We
351
347
# need to add a way to fetch certificates in this script ASAP.
352
- try :
353
- with warnings .catch_warnings ():
354
- warnings .simplefilter ("ignore" )
355
- response = requests .post (https_endpoint ,
356
- json = request_slice ,
357
- timeout = DEFAULT_REQUEST_TIMEOUT ,
358
- verify = False )
359
-
360
- if not response :
361
- raise RuntimeError ("No response obtained from HTTPS endpoint" )
362
-
363
- # If the request is unsuccessful (e.g. has a non 2xx response code),
364
- # we'll try HTTP
365
- response .raise_for_status ()
366
- except Exception as e :
367
- log_info ("Connect HTTPS Ferret endpoint failed (error: {}), trying HTTP..." .format (e ))
368
- response = requests .post (http_endpoint ,
348
+ with warnings .catch_warnings ():
349
+ warnings .simplefilter ("ignore" )
350
+ response = requests .post (https_endpoint ,
369
351
json = request_slice ,
370
- timeout = DEFAULT_REQUEST_TIMEOUT )
352
+ timeout = DEFAULT_REQUEST_TIMEOUT ,
353
+ verify = False )
371
354
372
355
if not response :
373
- raise RuntimeError ("No response obtained from HTTP endpoint" )
356
+ raise RuntimeError ("No response obtained from HTTPS endpoint" )
374
357
375
358
# If the request is unsuccessful (e.g. has a non 2xx response code),
376
359
# we'll consider it failed
@@ -384,12 +367,11 @@ def post_neighbor_advertiser_slice(ferret_service_vip):
384
367
save_as_json (request_slice , NEIGHBOR_ADVERTISER_REQUEST_SLICE_PATH )
385
368
386
369
https_endpoint = "https://{}:448{}{}" .format (ferret_service_vip , FERRET_NEIGHBOR_ADVERTISER_API_PREFIX , get_switch_name ())
387
- http_endpoint = "http://{}:85{}{}" .format (ferret_service_vip , FERRET_NEIGHBOR_ADVERTISER_API_PREFIX , get_switch_name ())
388
370
response = None
389
371
390
372
for retry in range (DEFAULT_FERRET_QUERY_RETRIES ):
391
373
try :
392
- response = wrapped_ferret_request (request_slice , https_endpoint , http_endpoint )
374
+ response = wrapped_ferret_request (request_slice , https_endpoint )
393
375
except Exception as e :
394
376
log_error ("The request failed, vip: {}, error: {}" .format (ferret_service_vip , e ))
395
377
return None
0 commit comments