Validate inventory hostnames via DNS resolution
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 11s
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 11s
This commit is contained in:
@@ -15,6 +15,14 @@ def get_ip(hostname: str) -> Optional[str]:
|
||||
except socket.error:
|
||||
return None
|
||||
|
||||
def is_valid_hostname(hostname: str) -> bool:
|
||||
"""
|
||||
Checks if a hostname resolves to an IP.
|
||||
"""
|
||||
if not hostname:
|
||||
return False
|
||||
return get_ip(hostname) is not None
|
||||
|
||||
def to_mgt_ip(name_or_ip: str) -> Optional[str]:
|
||||
"""
|
||||
Mimics the Ruby script's to_mgt_ip logic:
|
||||
|
||||
Reference in New Issue
Block a user