Merge "Fix handling hardware types and drivers when generating fencing parameters"

This commit is contained in:
Zuul 2018-05-31 11:27:17 +00:00 committed by Gerrit Code Review
commit fa0462695f
5 changed files with 32 additions and 59 deletions

View File

@ -0,0 +1,11 @@
---
fixes:
- |
Fixes handling hardware types (new-style Ironic drivers) when generating
fencing parameters. Also completely removes support for no longer existing
``pxe_ssh`` driver.
deprecations:
- |
The ``os_auth`` argument to the ``generate_fencing_parameters`` workflow
is deprecated and should not be provided. It will be removed in a future
version.

View File

@ -342,18 +342,16 @@ class GenerateFencingParametersAction(base.TripleOAction):
"""Generates fencing configuration for a deployment.
:param nodes_json: list of nodes & attributes in json format
:param os_auth: dictionary of OS client auth data (if using pxe_ssh)
:param delay: time to wait before taking fencing action
:param ipmi_level: IPMI user level to use
:param ipmi_cipher: IPMI cipher suite to use
:param ipmi_lanplus: whether to use IPMIv2.0
"""
def __init__(self, nodes_json, os_auth, delay,
def __init__(self, nodes_json, delay,
ipmi_level, ipmi_cipher, ipmi_lanplus):
super(GenerateFencingParametersAction, self).__init__()
self.nodes_json = nodes.convert_nodes_json_mac_to_ports(nodes_json)
self.os_auth = os_auth
self.delay = delay
self.ipmi_level = ipmi_level
self.ipmi_cipher = ipmi_cipher
@ -382,20 +380,14 @@ class GenerateFencingParametersAction(base.TripleOAction):
# Build up fencing parameters based on which Ironic driver this
# node is using
if hostmap and node["pm_type"] == "pxe_ssh":
# Ironic fencing driver
node_data["agent"] = "fence_ironic"
params["auth_url"] = self.os_auth["auth_url"]
params["login"] = self.os_auth["login"]
params["passwd"] = self.os_auth["passwd"]
params["tenant_name"] = self.os_auth["tenant_name"]
params["pcmk_host_map"] = "%(compute_name)s:%(bm_name)s" % (
{"compute_name": hostmap[mac_addr]["compute_name"],
"bm_name": hostmap[mac_addr]["baremetal_name"]})
if self.delay:
params["delay"] = self.delay
elif (node['pm_type'] == 'ipmi' or node["pm_type"].split('_')[1] in
("ipmitool", "ilo", "drac")):
try:
# Deprecated classic drivers (pxe_ipmitool, etc)
driver_proto = node['pm_type'].split('_')[1]
except IndexError:
# New-style hardware types (ipmi, etc)
driver_proto = node['pm_type']
if driver_proto in {'ipmi', 'ipmitool', 'drac', 'idrac', 'ilo'}:
# IPMI fencing driver
node_data["agent"] = "fence_ipmilan"
params["ipaddr"] = node["pm_addr"]

View File

@ -881,7 +881,7 @@ class GenerateFencingParametersActionTestCase(base.TestCase):
test_envjson = [{
"name": "control-0",
"pm_password": "control-0-password",
"pm_type": "pxe_ipmitool",
"pm_type": "ipmi",
"pm_user": "control-0-admin",
"pm_addr": "0.1.2.3",
"pm_port": "0123",
@ -891,7 +891,8 @@ class GenerateFencingParametersActionTestCase(base.TestCase):
}, {
"name": "control-1",
"pm_password": "control-1-password",
"pm_type": "pxe_ssh",
# Still support deprecated drivers
"pm_type": "pxe_ipmitool",
"pm_user": "control-1-admin",
"pm_addr": "1.2.3.4",
"mac": [
@ -902,22 +903,15 @@ class GenerateFencingParametersActionTestCase(base.TestCase):
# cope with unprovisioned nodes
"name": "control-2",
"pm_password": "control-2-password",
"pm_type": "pxe_ipmitool",
"pm_type": "ipmi",
"pm_user": "control-2-admin",
"pm_addr": "2.3.4.5",
"mac": [
"22:33:44:55:66:77"
]
}]
test_osauth = {
"auth_url": "test://auth.url",
"login": "test_os_username",
"passwd": "test_os_password",
"tenant_name": "test_os_tenant_name",
}
action = parameters.GenerateFencingParametersAction(test_envjson,
test_osauth,
28,
5,
0,
@ -942,15 +936,16 @@ class GenerateFencingParametersActionTestCase(base.TestCase):
}
})
self.assertEqual(result["FencingConfig"]["devices"][1], {
"agent": "fence_ironic",
"agent": "fence_ipmilan",
"host_mac": "11:22:33:44:55:66",
"params": {
"auth_url": "test://auth.url",
"delay": 28,
"login": "test_os_username",
"passwd": "test_os_password",
"tenant_name": "test_os_tenant_name",
"pcmk_host_map": "compute_name_1:baremetal_name_1"
"ipaddr": "1.2.3.4",
"lanplus": True,
"privlvl": 5,
"login": "control-1-admin",
"passwd": "control-1-password",
"pcmk_host_list": "compute_name_1"
}
})

View File

@ -227,31 +227,6 @@ class oVirtDriverInfo(DriverInfo):
return
class SshDriverInfo(DriverInfo):
DEFAULTS = {'ssh_virt_type': 'virsh'}
def __init__(self):
super(SshDriverInfo, self).__init__(
'ssh',
{
'pm_addr': 'ssh_address',
'pm_user': 'ssh_username',
# TODO(dtantsur): support ssh_key_filename as well
'pm_password': 'ssh_key_contents',
},
deprecated_mapping={
'pm_virt_type': 'ssh_virt_type',
},
mandatory_fields=['pm_addr', 'pm_user', 'pm_password'],
)
def validate(self, node):
super(SshDriverInfo, self).validate(node)
if not node.get('ports')[0]['address']:
raise exception.InvalidNode(
'Nodes with SSH drivers require at least one PORT')
class iBootDriverInfo(PrefixedDriverInfo):
def __init__(self):
super(iBootDriverInfo, self).__init__(

View File

@ -10,6 +10,7 @@ workflows:
a deployment.
input:
- nodes_json
# TODO(dtantsur): remove in Stein (after it is no longer used)
- os_auth
- fence_action
- delay
@ -29,7 +30,6 @@ workflows:
action: tripleo.parameters.generate_fencing
input:
nodes_json: <% $.nodes_json %>
os_auth: <% $.os_auth %>
fence_action: <% $.fence_action %>
delay: <% $.delay %>
ipmi_level: <% $.ipmi_level %>