From 0a672951ac07341a254dfd52d97348be6a13db33 Mon Sep 17 00:00:00 2001 From: Ivan Devat Date: Fri, 11 Jan 2019 15:13:09 +0100 Subject: [PATCH] fix link options' names in cluster setup --- pcs/lib/commands/test/cluster/test_setup.py | 27 +++++++++++++++------ pcs/lib/corosync/config_facade.py | 15 +++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/pcs/lib/commands/test/cluster/test_setup.py b/pcs/lib/commands/test/cluster/test_setup.py index bc7b51f0..441c4d67 100644 --- a/pcs/lib/commands/test/cluster/test_setup.py +++ b/pcs/lib/commands/test/cluster/test_setup.py @@ -95,10 +95,10 @@ def add_key_prefix(prefix, options): options = options or {} return {f"{prefix}{key}": value for key, value in options.items()} -def options_fixture(options): +def options_fixture(options, template=OPTION_TEMPLATE): options = options or {} return "".join([ - OPTION_TEMPLATE.format(option=o, value=v) + template.format(option=o, value=v) for o, v in sorted(options.items()) ]) @@ -107,7 +107,7 @@ def corosync_conf_fixture( links_numbers=None, quorum_options=None, totem_options=None, transport_options=None, compression_options=None, crypto_options=None, ): - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments, too-many-locals if transport_type == "knet" and not crypto_options: crypto_options = { "cipher": "aes256", @@ -115,18 +115,31 @@ def corosync_conf_fixture( } interface_list = "" if link_list: + knet_options = { + "link_priority", + "ping_interval", + "ping_precision", + "ping_timeout", + "pong_count", + "transport", + } + link_list = [dict(link) for link in link_list] links_numbers = links_numbers if links_numbers else list( range(constants.LINKS_KNET_MAX) ) for i, link in enumerate(link_list): link["linknumber"] = links_numbers[i] + link_translated = {} + for name, value in link.items(): + if name in knet_options: + name = f"knet_{name}" + link_translated[name] = value + link_list[i] = link_translated + interface_list = "".join([ INTERFACE_TEMPLATE.format( - option_list="".join([ - INTERFACE_OPTION_TEMPLATE.format(option=o, value=v) - for o, v in sorted(link.items()) - ]) + option_list=options_fixture(link, INTERFACE_OPTION_TEMPLATE) ) for link in sorted( link_list, key=lambda item: item["linknumber"] ) diff --git a/pcs/lib/corosync/config_facade.py b/pcs/lib/corosync/config_facade.py index 13cc61b2..db98f435 100644 --- a/pcs/lib/corosync/config_facade.py +++ b/pcs/lib/corosync/config_facade.py @@ -260,6 +260,14 @@ class ConfigFacade: dict options -- link options """ + options_translate = { + "link_priority": "knet_link_priority", + "ping_interval": "knet_ping_interval", + "ping_precision": "knet_ping_precision", + "ping_timeout": "knet_ping_timeout", + "pong_count": "knet_pong_count", + "transport": "knet_transport", + } totem_section = self.__ensure_section(self.config, "totem")[-1] new_link_section = config_parser.Section("interface") options_to_set = {} @@ -268,9 +276,10 @@ class ConfigFacade: # If broadcast == 1, transform it to broadcast == yes. Else do # not put the option to the config at all. if value in ("1", 1): - options_to_set[name] = "yes" - continue - options_to_set[name] = value + value = "yes" + else: + continue + options_to_set[options_translate.get(name, name)] = value self.__set_section_options([new_link_section], options_to_set) totem_section.add_section(new_link_section) self.__remove_empty_sections(self.config) -- 2.17.0