From c13c9cf5a2e26b4a27fabc454d99d3643ba3dd42 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Fri, 12 Apr 2019 11:46:50 +0200 Subject: [PATCH] Enable staging-ovirt (fence_rhevm) fencing agent. This commit extends actions/parameters to generate fencing parameters for nodes using staging-ovirt (fence_rhevm). Given instackenv.json content like: { "nodes":[ { "name":"ctrl01", "pm_type":"staging-ovirt", "mac": [ "56:6f:71:33:00:0d" ], "arch": "x86_64", "pm_user":"admin@internal", "pm_password":"redhat", "pm_addr":"10.0.0.141", "pm_vm_name":"ctrl01" } ... Here the generated fence.yaml: parameter_defaults: EnableFencing: true FencingConfig: devices: - agent: fence_rhevm host_mac: 56:6f:71:33:00:0d params: ipaddr: 10.0.0.141 login: admin@internal passwd: redhat port: ctrl01 ssl: 1 ssl_insecure: 1 And the resulting pacemaker stonith resource: stonith-fence_rhevm-566f7133000d (stonith:fence_rhevm:( Started overcloud-controller-1 To have this working 'out of the box' we assume the worst case scenario of ovirt-engine using a self-signed certificate, so we explicitly ssl_insecure=1. Users/Operators should be aware of this and eventually adjust the value accordingly. Change-Id: I3b746eff8367133cec2c6ff03aad25993d26e90c --- tripleo_common/actions/parameters.py | 14 +++++++++ .../tests/actions/test_parameters.py | 31 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tripleo_common/actions/parameters.py b/tripleo_common/actions/parameters.py index e93fd7c3b..1418edcd4 100644 --- a/tripleo_common/actions/parameters.py +++ b/tripleo_common/actions/parameters.py @@ -442,6 +442,20 @@ class GenerateFencingParametersAction(base.TripleOAction): params["cipher"] = self.ipmi_cipher if self.ipmi_level: params["privlvl"] = self.ipmi_level + elif driver_proto in {'staging-ovirt'}: + # fence_rhevm + node_data["agent"] = "fence_rhevm" + params["ipaddr"] = node["pm_addr"] + params["passwd"] = node["pm_password"] + params["login"] = node["pm_user"] + params["port"] = node["pm_vm_name"] + params["ssl"] = 1 + params["ssl_insecure"] = 1 + if hostmap: + params["pcmk_host_list"] = \ + hostmap[mac_addr]["compute_name"] + if self.delay: + params["delay"] = self.delay else: error = ("Unable to generate fencing parameters for %s" % node["pm_type"]) diff --git a/tripleo_common/tests/actions/test_parameters.py b/tripleo_common/tests/actions/test_parameters.py index fd5352ad0..95d1890e0 100644 --- a/tripleo_common/tests/actions/test_parameters.py +++ b/tripleo_common/tests/actions/test_parameters.py @@ -1034,6 +1034,10 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "aa:bb:cc:dd:ee:ff": { "compute_name": "compute_name_4", "baremetal_name": "baremetal_name_4" + }, + "bb:cc:dd:ee:ff:gg": { + "compute_name": "compute_name_5", + "baremetal_name": "baremetal_name_5" } } mock_generate_hostmap.return_value = test_hostmap @@ -1071,6 +1075,17 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "mac": [ "aa:bb:cc:dd:ee:ff" ] + }, { + # This is an extra node on oVirt/RHV + "name": "control-3", + "pm_password": "ovirt-password", + "pm_type": "staging-ovirt", + "pm_user": "admin@internal", + "pm_addr": "3.4.5.6", + "pm_vm_name": "control-3", + "mac": [ + "bb:cc:dd:ee:ff:gg" + ] }, { # This is an extra node that is not in the hostmap, to ensure we # cope with unprovisioned nodes @@ -1094,7 +1109,7 @@ class GenerateFencingParametersActionTestCase(base.TestCase): result = action.run(mock_ctx)["parameter_defaults"] self.assertTrue(result["EnableFencing"]) - self.assertEqual(len(result["FencingConfig"]["devices"]), 3) + self.assertEqual(len(result["FencingConfig"]["devices"]), 4) self.assertEqual(result["FencingConfig"]["devices"][0], { "agent": "fence_ipmilan", "host_mac": "00:11:22:33:44:55", @@ -1138,6 +1153,20 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "pcmk_host_list": "compute_name_4" } }) + self.assertEqual(result["FencingConfig"]["devices"][3], { + "agent": "fence_rhevm", + "host_mac": "bb:cc:dd:ee:ff:gg", + "params": { + "delay": 28, + "ipaddr": "3.4.5.6", + "login": "admin@internal", + "passwd": "ovirt-password", + "port": "control-3", + "ssl": 1, + "ssl_insecure": 1, + "pcmk_host_list": "compute_name_5" + } + }) class GetFlattenedParametersActionTest(base.TestCase):