From cf52ba4f1f4d2cecac7d71ce3987900fb788ef41 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Mon, 18 Jun 2018 11:37:06 +0200 Subject: [PATCH] Make server spawn and response times configurable This is a followup patch to [1] introducing configurable timing parameters for the client to wait for automatic vbmcd start up and vbmcd response timeout. 1. https://review.openstack.org/#/c/488874 Change-Id: Id1cdcecd8d407b31dc69166fb0fda555fc4a679f --- virtualbmc/cmd/vbmc.py | 4 ++-- virtualbmc/config.py | 2 ++ virtualbmc/tests/unit/test_config.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/virtualbmc/cmd/vbmc.py b/virtualbmc/cmd/vbmc.py index 304177c..f55b677 100644 --- a/virtualbmc/cmd/vbmc.py +++ b/virtualbmc/cmd/vbmc.py @@ -50,7 +50,7 @@ class ZmqClient(object): and `rows` attributes pointing to lists of cell values. """ - SERVER_TIMEOUT = 5000 # milliseconds + SERVER_TIMEOUT = CONF['default']['server_response_timeout'] def communicate(self, command, args, no_daemon=False): @@ -109,7 +109,7 @@ class ZmqClient(object): vbmcd.main([]) # TODO(etingof): perform some more retries - time.sleep(3) + time.sleep(CONF['default']['server_spawn_wait'] / 1000.) # MQ will deliver the original message to the daemon # we've started diff --git a/virtualbmc/config.py b/virtualbmc/config.py index 4b73a48..5d7a418 100644 --- a/virtualbmc/config.py +++ b/virtualbmc/config.py @@ -42,6 +42,8 @@ class VirtualBMCConfig(object): os.path.expanduser('~'), '.vbmc', 'master.pid' ), 'server_port': 50891, + 'server_response_timeout': 5000, # milliseconds + 'server_spawn_wait': 3000, # milliseconds }, 'log': { 'logfile': None, diff --git a/virtualbmc/tests/unit/test_config.py b/virtualbmc/tests/unit/test_config.py index 43ad746..ee5474c 100644 --- a/virtualbmc/tests/unit/test_config.py +++ b/virtualbmc/tests/unit/test_config.py @@ -33,7 +33,9 @@ class VirtualBMCConfigTestCase(base.TestCase): self.config_dict = {'default': {'show_passwords': 'true', 'config_dir': '/foo/bar/1', 'pid_file': '/foo/bar/2', - 'server_port': '12345'}, + 'server_port': '12345', + 'server_spawn_wait': 3000, + 'server_response_timeout': 5000}, 'log': {'debug': 'true', 'logfile': '/foo/bar/4'}, 'ipmi': {'session_timeout': '30'}}