Merge "Wrap iscsi portal in []'s if IPv6"
This commit is contained in:
commit
4ba3429343
@ -26,6 +26,7 @@ from oslo_concurrency import processutils
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
|
from oslo_utils import netutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -102,6 +103,12 @@ def _get_ironic_session():
|
|||||||
return _IRONIC_SESSION
|
return _IRONIC_SESSION
|
||||||
|
|
||||||
|
|
||||||
|
def _wrap_ipv6(ip):
|
||||||
|
if netutils.is_valid_ipv6(ip):
|
||||||
|
return "[%s]" % ip
|
||||||
|
return ip
|
||||||
|
|
||||||
|
|
||||||
def get_ironic_api_url():
|
def get_ironic_api_url():
|
||||||
"""Resolve Ironic API endpoint
|
"""Resolve Ironic API endpoint
|
||||||
|
|
||||||
@ -130,7 +137,7 @@ def discovery(portal_address, portal_port):
|
|||||||
utils.execute('iscsiadm',
|
utils.execute('iscsiadm',
|
||||||
'-m', 'discovery',
|
'-m', 'discovery',
|
||||||
'-t', 'st',
|
'-t', 'st',
|
||||||
'-p', '%s:%s' % (portal_address, portal_port),
|
'-p', '%s:%s' % (_wrap_ipv6(portal_address), portal_port),
|
||||||
run_as_root=True,
|
run_as_root=True,
|
||||||
check_exit_code=[0],
|
check_exit_code=[0],
|
||||||
attempts=5,
|
attempts=5,
|
||||||
@ -141,7 +148,7 @@ def login_iscsi(portal_address, portal_port, target_iqn):
|
|||||||
"""Login to an iSCSI target."""
|
"""Login to an iSCSI target."""
|
||||||
utils.execute('iscsiadm',
|
utils.execute('iscsiadm',
|
||||||
'-m', 'node',
|
'-m', 'node',
|
||||||
'-p', '%s:%s' % (portal_address, portal_port),
|
'-p', '%s:%s' % (_wrap_ipv6(portal_address), portal_port),
|
||||||
'-T', target_iqn,
|
'-T', target_iqn,
|
||||||
'--login',
|
'--login',
|
||||||
run_as_root=True,
|
run_as_root=True,
|
||||||
@ -225,7 +232,7 @@ def logout_iscsi(portal_address, portal_port, target_iqn):
|
|||||||
"""Logout from an iSCSI target."""
|
"""Logout from an iSCSI target."""
|
||||||
utils.execute('iscsiadm',
|
utils.execute('iscsiadm',
|
||||||
'-m', 'node',
|
'-m', 'node',
|
||||||
'-p', '%s:%s' % (portal_address, portal_port),
|
'-p', '%s:%s' % (_wrap_ipv6(portal_address), portal_port),
|
||||||
'-T', target_iqn,
|
'-T', target_iqn,
|
||||||
'--logout',
|
'--logout',
|
||||||
run_as_root=True,
|
run_as_root=True,
|
||||||
@ -240,7 +247,7 @@ def delete_iscsi(portal_address, portal_port, target_iqn):
|
|||||||
# no longer a target to delete (exit code 21).
|
# no longer a target to delete (exit code 21).
|
||||||
utils.execute('iscsiadm',
|
utils.execute('iscsiadm',
|
||||||
'-m', 'node',
|
'-m', 'node',
|
||||||
'-p', '%s:%s' % (portal_address, portal_port),
|
'-p', '%s:%s' % (_wrap_ipv6(portal_address), portal_port),
|
||||||
'-T', target_iqn,
|
'-T', target_iqn,
|
||||||
'-o', 'delete',
|
'-o', 'delete',
|
||||||
run_as_root=True,
|
run_as_root=True,
|
||||||
|
@ -647,6 +647,32 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
|||||||
|
|
||||||
mock_check_dev.assert_called_once_with(address, port, iqn)
|
mock_check_dev.assert_called_once_with(address, port, iqn)
|
||||||
|
|
||||||
|
@mock.patch.object(common_utils, 'execute', autospec=True)
|
||||||
|
@mock.patch.object(utils, 'verify_iscsi_connection', autospec=True)
|
||||||
|
@mock.patch.object(utils, 'force_iscsi_lun_update', autospec=True)
|
||||||
|
@mock.patch.object(utils, 'check_file_system_for_iscsi_device',
|
||||||
|
autospec=True)
|
||||||
|
def test_ipv6_address_wrapped(self,
|
||||||
|
mock_check_dev,
|
||||||
|
mock_update,
|
||||||
|
mock_verify,
|
||||||
|
mock_exec):
|
||||||
|
address = '2001:DB8::1111'
|
||||||
|
port = 3306
|
||||||
|
iqn = 'iqn.xyz'
|
||||||
|
mock_exec.return_value = ['iqn.xyz', '']
|
||||||
|
utils.login_iscsi(address, port, iqn)
|
||||||
|
mock_exec.assert_called_once_with(
|
||||||
|
'iscsiadm',
|
||||||
|
'-m', 'node',
|
||||||
|
'-p', '[%s]:%s' % (address, port),
|
||||||
|
'-T', iqn,
|
||||||
|
'--login',
|
||||||
|
run_as_root=True,
|
||||||
|
check_exit_code=[0],
|
||||||
|
attempts=5,
|
||||||
|
delay_on_retry=True)
|
||||||
|
|
||||||
@mock.patch.object(disk_utils, 'is_block_device', lambda d: True)
|
@mock.patch.object(disk_utils, 'is_block_device', lambda d: True)
|
||||||
def test_always_logout_and_delete_iscsi(self):
|
def test_always_logout_and_delete_iscsi(self):
|
||||||
"""Check if logout_iscsi() and delete_iscsi() are called.
|
"""Check if logout_iscsi() and delete_iscsi() are called.
|
||||||
|
4
releasenotes/notes/ipv6-provision-67bd9c1dbcc48c97.yaml
Normal file
4
releasenotes/notes/ipv6-provision-67bd9c1dbcc48c97.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Can now deploy to a IPv6 iscsi portal if
|
||||||
|
instructed to do so.
|
Loading…
x
Reference in New Issue
Block a user