MCPcopy Create free account
hub / github.com/saltstack/salt / verify_socket

Function verify_socket

salt/utils/verify.py:114–137  ·  view source on GitHub ↗

Attempt to bind to the sockets to verify that they are available

(interface, pub_port, ret_port)

Source from the content-addressed store, hash-verified

112
113
114def verify_socket(interface, pub_port, ret_port):
115 """
116 Attempt to bind to the sockets to verify that they are available
117 """
118
119 addr_family = lookup_family(interface)
120 for port in pub_port, ret_port:
121 sock = socket.socket(addr_family, socket.SOCK_STREAM)
122 try:
123 sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
124 sock.bind((interface, int(port)))
125 except Exception as exc: # pylint: disable=broad-except
126 msg = f"Unable to bind socket {interface}:{port}"
127 if exc.args:
128 msg = f"{msg}, error: {str(exc)}"
129 else:
130 msg = f"{msg}, this might not be a problem."
131 msg += "; Is there another salt-master running?"
132 log.warning(msg)
133 return False
134 finally:
135 sock.close()
136
137 return True
138
139
140def verify_logs_filter(files):

Callers 1

prepareMethod · 0.90

Calls 5

lookup_familyFunction · 0.85
warningMethod · 0.80
socketMethod · 0.45
setsockoptMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected