@@ -308,45 +308,36 @@ def _get_route_source(self, dest):
308308
309309 return source
310310
311- def _test_ip_reachability (self , ip_address ):
312- """Test if an IP address is reachable via HTTP GET request.
311+ def _test_ip_reachability (self , api_url ):
312+ """Test if an API URL is reachable via HTTP GET request.
313313
314- :param ip_address : The IP address to test
315- :returns: True if the IP is reachable, False otherwise
314+ :param api_url : The full API URL to test (including protocol and port)
315+ :returns: True if the URL is reachable, False otherwise
316316 """
317- test_urls = [
318- 'http://{}' .format (ip_address ),
319- 'https://{}' .format (ip_address ),
320- ]
321-
322- for url in test_urls :
323- try :
324- # Disable SSL verification for reachability testing only
325- response = requests .get (
326- url , timeout = CONF .http_request_timeout , verify = False
327- ) # nosec
328- # Any HTTP response (even 404, 500, etc.) indicates
329- # reachability
330- LOG .debug ('IP %s is reachable via %s (status: %s)' ,
331- ip_address , url , response .status_code )
332- return True
333- except requests .exceptions .RequestException as e :
334- LOG .debug ('IP %s not reachable via %s: %s' ,
335- ip_address , url , e )
336- continue
337-
338- return False
317+ try :
318+ # Disable SSL verification for reachability testing only
319+ response = requests .get (
320+ api_url , timeout = CONF .http_request_timeout , verify = False
321+ ) # nosec
322+ # Any HTTP response (even 404, 500, etc.) indicates reachability
323+ LOG .debug ('API URL %s is reachable (status: %s)' ,
324+ api_url , response .status_code )
325+ return True
326+ except requests .exceptions .RequestException as e :
327+ LOG .debug ('API URL %s not reachable: %s' , api_url , e )
328+ return False
339329
340330 def _find_routable_addr (self ):
341331 # Process API URLs: check reachability and collect IPs in one pass
342332 reachable_api_urls = []
343333 ips = set ()
344334
345335 for api_url in self .api_urls :
346- ironic_host = urlparse .urlparse (api_url ).hostname
336+ parsed = urlparse .urlparse (api_url )
337+ ironic_host = parsed .hostname
347338
348- # Test reachability once per hostname
349- if self ._test_ip_reachability (ironic_host ):
339+ # Test reachability using the full URL (including port)
340+ if self ._test_ip_reachability (api_url ):
350341 reachable_api_urls .append (api_url )
351342 LOG .debug ('API URL %s is reachable' , api_url )
352343
0 commit comments