Validate inventory hostnames via DNS resolution
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 11s

This commit is contained in:
2026-02-06 16:25:39 -05:00
parent fc1c4bfaa8
commit 9e7e4054c4
3 changed files with 80 additions and 17 deletions

View File

@@ -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: