From baaf834db46f15910b82cceecd3417481b9bc3a4 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/. Change-Id: Iec99d194d261ae0cdab93e2b1b4ed0d030feae7f (cherry picked from commit 9314396efc318ae4553932fa76f24e1071a69da9) --- 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 de9081660..bae4b3f40 100644 --- a/tripleo_common/actions/parameters.py +++ b/tripleo_common/actions/parameters.py @@ -414,9 +414,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"] @@ -425,6 +430,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 fa0d32206..c082a7db8 100644 --- a/tripleo_common/tests/actions/test_parameters.py +++ b/tripleo_common/tests/actions/test_parameters.py @@ -1029,6 +1029,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 @@ -1053,6 +1057,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 @@ -1064,7 +1081,8 @@ class GenerateFencingParametersActionTestCase(base.TestCase): "mac": [ "22:33:44:55:66:77" ] - }] + } + ] action = parameters.GenerateFencingParametersAction(test_envjson, 28, @@ -1075,7 +1093,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", @@ -1103,6 +1121,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):