in src/hpc/autoscale/util.py [0:0]
def is_valid_hostname(config: Dict, node: "Node") -> bool:
# delayed import, as logging will import this module
from hpc.autoscale import hpclogging as logging
if not node.hostname:
return False
valid_hostnames: Optional[List[str]] = config.get("valid_hostnames")
if not valid_hostnames:
if is_standalone_dns(node):
valid_hostnames = ["^ip-[0-9A-Za-z]{8}$"]
else:
return True
for valid_hostname in valid_hostnames:
if re.match(valid_hostname, node.hostname):
return True
logging.warning(
"Rejecting invalid hostname '%s': Did not match any of the following patterns: %s",
node.hostname,
valid_hostnames,
)
return False