(hostfile, convert_ip=True)
| 45 | |
| 46 | |
| 47 | def parse_hostfile(hostfile, convert_ip=True): |
| 48 | hosts = [] |
| 49 | with open(hostfile) as f: |
| 50 | for h in f.readlines(): |
| 51 | h = h.strip() |
| 52 | if len(h) > 0: |
| 53 | if not convert_ip: |
| 54 | hosts.append(h.strip()) |
| 55 | else: |
| 56 | try: |
| 57 | ip = socket.gethostbyname(h) |
| 58 | hosts.append(ip) |
| 59 | except Exception as e: |
| 60 | print("error host ", h, " error: ", e) |
| 61 | return hosts |
| 62 | |
| 63 | |
| 64 | def find_available_ports(ip, port_num=1, port=9091, port_end=9999): |