Attempt to bind to the sockets to verify that they are available
(interface, pub_port, ret_port)
| 112 | |
| 113 | |
| 114 | def 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 | |
| 140 | def verify_logs_filter(files): |
no test coverage detected