From 1ed761c1aaa2322268c1b4284edd2607065741f7 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Mon, 31 Oct 2022 08:58:16 +0100 Subject: [PATCH] Correct an issue when using autodiscover in unitary test --- glances/autodiscover.py | 3 +++ glances/server.py | 1 + unitest-xmlrpc.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/glances/autodiscover.py b/glances/autodiscover.py index f7e86722..b521603f 100644 --- a/glances/autodiscover.py +++ b/glances/autodiscover.py @@ -186,6 +186,9 @@ class GlancesAutoDiscoverClient(object): # Issue #528 (no network interface available) pass + # Ensure zeroconf_bind_address is an IP address not an host + zeroconf_bind_address = socket.gethostbyname(zeroconf_bind_address) + # Check IP v4/v6 address_family = socket.getaddrinfo(zeroconf_bind_address, args.port)[0][0] diff --git a/glances/server.py b/glances/server.py index b6a907d5..6b680ad9 100644 --- a/glances/server.py +++ b/glances/server.py @@ -219,6 +219,7 @@ class GlancesServer(object): if not self.args.disable_autodiscover: # Note: The Zeroconf service name will be based on the hostname # Correct issue: Zeroconf problem with zeroconf service name #889 + logger.info('Autodiscover is enabled with service name {}'.format(socket.gethostname().split('.', 1)[0])) self.autodiscover_client = GlancesAutoDiscoverClient(socket.gethostname().split('.', 1)[0], args) else: logger.info("Glances autodiscover announce is disabled") diff --git a/unitest-xmlrpc.py b/unitest-xmlrpc.py index 8b836f3a..3a75273a 100755 --- a/unitest-xmlrpc.py +++ b/unitest-xmlrpc.py @@ -48,7 +48,7 @@ class TestGlances(unittest.TestCase): cmdline = "./venv/bin/python" else: cmdline = "python" - cmdline += " -m glances -B localhost -s --disable-autodiscover -p %s" % SERVER_PORT + cmdline += " -m glances -B localhost -s -p %s" % SERVER_PORT print("Run the Glances Server on port %s" % SERVER_PORT) args = shlex.split(cmdline) pid = subprocess.Popen(args)