From 3b5c0fffd777d599e36fac23854dca04173fa751 Mon Sep 17 00:00:00 2001 From: Pierre-Louis GONON Date: Fri, 8 Jul 2022 10:18:18 +0200 Subject: [PATCH] Remove ValueError if hostname does not contain dot ValueError has been replaced with Warning message if dot is missing. --- temboardagent/inventory.py | 2 ++ temboardagent/tools.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/temboardagent/inventory.py b/temboardagent/inventory.py index 4804898fe..a36091d8a 100644 --- a/temboardagent/inventory.py +++ b/temboardagent/inventory.py @@ -33,6 +33,8 @@ def hostname(self, hostname=None): raise Exception("Unsupported OS.") if not check_fqdn(hostname): raise ValueError("Invalid FQDN: %s" % (hostname)) + if '.' not in hostname: + logger.warning("Hostname %s is not a FQDN.", hostname) return hostname def uname(self): diff --git a/temboardagent/tools.py b/temboardagent/tools.py index 5c1db045e..55d1106ed 100644 --- a/temboardagent/tools.py +++ b/temboardagent/tools.py @@ -130,14 +130,15 @@ def which(prog, search_path=None): def check_fqdn(name): """ Check if a hostname is fully qualified, it must only contain - letters, - and have dots. + letters, - . + We now allow hostname without dot. """ - # StackOverflow #11809631 - if re.match(r'(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?