From 9314396efc318ae4553932fa76f24e1071a69da9 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Wed, 20 Feb 2019 17:28:11 +0100 Subject: [PATCH] Adds redfish support to 'overcloud generate fencing'. See https://review.openstack.org/#/c/636889/. Still work in progress. Change-Id: Iec99d194d261ae0cdab93e2b1b4ed0d030feae7f --- tripleo_common/actions/parameters.py | 14 ++++++- .../tests/actions/test_parameters.py | 38 ++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/tripleo_common/actions/parameters.py b/tripleo_common/actions/parameters.py index 6f70d2fd7..e93fd7c3b 100644 --- a/tripleo_common/actions/parameters.py +++ b/tripleo_common/actions/parameters.py @@ -413,9 +413,14 @@ class GenerateFencingParametersAction(base.TripleOAction): # New-style hardware types (ipmi, etc) driver_proto = node['pm_type'] - if driver_proto in {'ipmi', 'ipmitool', 'drac', 'idrac', 'ilo'}: + if driver_proto in {'ipmi', 'ipmitool', 'drac', 'idrac', 'ilo', + 'redfish'}: # IPMI fencing driver - node_data["agent"] = "fence_ipmilan" + if driver_proto == "redfish": + node_data["agent"] = "fence_redfish" + params["systems_uri"] = node["pm_system_id"] + else: + node_data["agent"] = "fence_ipmilan" params["ipaddr"] = node["pm_addr"] params["passwd"] = node["pm_password"] params["login"] = node["pm_user"] @@ -424,6 +429,11 @@ class GenerateFencingParametersAction(base.TripleOAction): hostmap[mac_addr]["compute_name"] if "pm_port" in node: params["ipport"] = node["pm_port"] + if "redfish_verify_ca" in node: + if node["redfish_verify_ca"] == "false": + params["ssl_insecure"] = "true" + else: + params["ssl_insecure"] = "false" if self.ipmi_lanplus: params["lanplus"] = self.ipmi_lanplus if self.delay: diff --git a/tripleo_common/tests/actions/test_parameters.py b/tripleo_common/tests/actions/test_parameters.py index 2cf026a17..fd5352ad0 100644 --- a/tripleo_common/tests/actions/test_parameters.py +++ b/tripleo_common/tests/actions/test_parameters.py @@ -1030,6 +1030,10 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "11:22:33:44:55:66": { "compute_name": "compute_name_1", "baremetal_name": "baremetal_name_1" + }, + "aa:bb:cc:dd:ee:ff": { + "compute_name": "compute_name_4", + "baremetal_name": "baremetal_name_4" } } mock_generate_hostmap.return_value = test_hostmap @@ -1054,6 +1058,19 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "mac": [ "11:22:33:44:55:66" ] + }, { + # test node using redfish pm + "name": "compute-4", + "pm_password": "calvin", + "pm_type": "redfish", + "pm_user": "root", + "pm_addr": "172.16.0.1:8000", + "pm_port": "8000", + "redfish_verify_ca": "false", + "pm_system_id": "/redfish/v1/Systems/5678", + "mac": [ + "aa:bb:cc:dd:ee:ff" + ] }, { # This is an extra node that is not in the hostmap, to ensure we # cope with unprovisioned nodes @@ -1065,7 +1082,8 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "mac": [ "22:33:44:55:66:77" ] - }] + } + ] action = parameters.GenerateFencingParametersAction(test_envjson, 28, @@ -1076,7 +1094,7 @@ class GenerateFencingParametersActionTestCase(base.TestCase): result = action.run(mock_ctx)["parameter_defaults"] self.assertTrue(result["EnableFencing"]) - self.assertEqual(len(result["FencingConfig"]["devices"]), 2) + self.assertEqual(len(result["FencingConfig"]["devices"]), 3) self.assertEqual(result["FencingConfig"]["devices"][0], { "agent": "fence_ipmilan", "host_mac": "00:11:22:33:44:55", @@ -1104,6 +1122,22 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "pcmk_host_list": "compute_name_1" } }) + self.assertEqual(result["FencingConfig"]["devices"][2], { + "agent": "fence_redfish", + "host_mac": "aa:bb:cc:dd:ee:ff", + "params": { + "delay": 28, + "ipaddr": "172.16.0.1:8000", + "ipport": "8000", + "lanplus": True, + "privlvl": 5, + "login": "root", + "passwd": "calvin", + "systems_uri": "/redfish/v1/Systems/5678", + "ssl_insecure": "true", + "pcmk_host_list": "compute_name_4" + } + }) class GetFlattenedParametersActionTest(base.TestCase):