summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/mgr_util.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
commit389020e14594e4894e28d1eb9103c210b142509e (patch)
tree2ba734cdd7a243f46dda7c3d0cc88c2293d9699f /src/pybind/mgr/mgr_util.py
parentAdding upstream version 18.2.2. (diff)
downloadceph-389020e14594e4894e28d1eb9103c210b142509e.tar.xz
ceph-389020e14594e4894e28d1eb9103c210b142509e.zip
Adding upstream version 18.2.3.upstream/18.2.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/pybind/mgr/mgr_util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pybind/mgr/mgr_util.py b/src/pybind/mgr/mgr_util.py
index 8684f8013..05ec64966 100644
--- a/src/pybind/mgr/mgr_util.py
+++ b/src/pybind/mgr/mgr_util.py
@@ -12,6 +12,7 @@ import socket
import time
import logging
import sys
+from ipaddress import ip_address
from threading import Lock, Condition, Event
from typing import no_type_check, NewType
import urllib
@@ -413,7 +414,9 @@ def test_port_allocation(addr: str, port: int) -> None:
If no exception is raised, the port can be assumed available
"""
try:
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ ip_version = ip_address(addr).version
+ addr_family = socket.AF_INET if ip_version == 4 else socket.AF_INET6
+ sock = socket.socket(addr_family, socket.SOCK_STREAM)
sock.bind((addr, port))
sock.close()
except socket.error as e: