ironic: bugfix: ensure a host is set for volume connectors

Somehow, in some not fully understood case,
we have discovered that we are not storing a
host field for the volume connector information.

This information is largely required for logging,
and in some cases back-end driver relationships,
but previously we would only set the field in the
case that we have an IP address. That is not ideal
in that some users may be using other transport
mediums like fibre channel.

Change-Id: I17b1aaa26b7e7aff3ebb73fa10ab576149a00a3f
Related-Bug: #1766661
This commit is contained in:
Julia Kreger 2018-06-03 11:19:57 -07:00
parent a7994ec355
commit 22ef346521
2 changed files with 15 additions and 2 deletions

View File

@ -2220,7 +2220,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
@mock.patch.object(FAKE_CLIENT.portgroup, 'list')
def _test_get_volume_connector_no_ip(
self, mac_specified, mock_pgroup, mock_port, mock_node,
mock_nw_info, portgroup_exist=False):
mock_nw_info, portgroup_exist=False, no_fixed_ip=False):
node_uuid = uuids.node_uuid
node_props = {'cpu_arch': 'x86_64'}
node = ironic_utils.get_test_node(uuid=node_uuid,
@ -2247,12 +2247,17 @@ class IronicDriverTestCase(test.NoDBTestCase):
mock_node.get.return_value = node
mock_node.list_volume_connectors.return_value = connectors
mock_nw_info.return_value = [vif]
instance = fake_instance.fake_instance_obj(self.ctx, node=node_uuid)
port = ironic_utils.get_test_port(
node_uuid=node_uuid, address='11:22:33:44:55:66',
internal_info={'tenant_vif_port_id': vif['id']})
mock_port.return_value = [port]
if no_fixed_ip:
mock_nw_info.return_value = []
expected_props.pop('ip')
expected_props['host'] = instance.hostname
else:
mock_nw_info.return_value = [vif]
if portgroup_exist:
portgroup = ironic_utils.get_test_portgroup(
node_uuid=node_uuid, address='11:22:33:44:55:66',
@ -2287,6 +2292,9 @@ class IronicDriverTestCase(test.NoDBTestCase):
def test_get_volume_connector_no_ip_without_mac(self):
self._test_get_volume_connector_no_ip(False)
def test_get_volume_connector_no_ip_no_fixed_ip(self):
self._test_get_volume_connector_no_ip(False, no_fixed_ip=True)
@mock.patch.object(ironic_driver.IronicDriver, 'plug_vifs')
def test_prepare_networks_before_block_device_mapping(self, mock_pvifs):
instance = fake_instance.fake_instance_obj(self.ctx)

View File

@ -1859,6 +1859,11 @@ class IronicDriver(virt_driver.ComputeDriver):
props['platform'] = properties.get('cpu_arch')
props['os_type'] = 'baremetal'
# NOTE(TheJulia): The host field is important to cinder connectors
# as it is used in some drivers for logging purposes, and we presently
# only otherwise set it when an IP address is used.
if 'host' not in props:
props['host'] = instance.hostname
# Eventually it would be nice to be able to do multipath, but for now
# we should at least set the value to False.
props['multipath'] = False