Blame SOURCES/bz1659051-01-fix-link-options-names-in-cluster-setup.patch

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