Merge "Rename nvme to nvmeof"

This commit is contained in:
Zuul 2019-09-04 02:04:12 +00:00 committed by Gerrit Code Review
commit cc22ac0ed5
4 changed files with 44 additions and 42 deletions

View File

@ -64,7 +64,7 @@ connector_list = [
'os_brick.initiator.windows.smbfs.WindowsSMBFSConnector',
'os_brick.initiator.connectors.vrtshyperscale.HyperScaleConnector',
'os_brick.initiator.connectors.storpool.StorPoolConnector',
'os_brick.initiator.connectors.nvme.NVMeConnector',
'os_brick.initiator.connectors.nvmeof.NVMeOFConnector',
]
# Mappings used to determine who to construct in the factory
@ -114,10 +114,12 @@ _connector_mapping_linux = {
'os_brick.initiator.connectors.vrtshyperscale.HyperScaleConnector',
initiator.STORPOOL:
'os_brick.initiator.connectors.storpool.StorPoolConnector',
# Leave this in for backwards compatibility
# This isn't an NVME connector, but NVME Over Fabrics
initiator.NVME:
'os_brick.initiator.connectors.nvme.NVMeConnector',
'os_brick.initiator.connectors.nvmeof.NVMeOFConnector',
initiator.NVMEOF:
'os_brick.initiator.connectors.nvme.NVMeConnector',
'os_brick.initiator.connectors.nvmeof.NVMeOFConnector',
}
# Mapping for the S390X platform

View File

@ -30,14 +30,14 @@ LOG = logging.getLogger(__name__)
synchronized = lockutils.synchronized_with_prefix('os-brick-')
class NVMeConnector(base.BaseLinuxConnector):
class NVMeOFConnector(base.BaseLinuxConnector):
"""Connector class to attach/detach NVMe over fabric volumes."""
def __init__(self, root_helper, driver=None, use_multipath=False,
device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT,
*args, **kwargs):
super(NVMeConnector, self).__init__(
super(NVMeOFConnector, self).__init__(
root_helper,
driver=driver,
device_scan_attempts=device_scan_attempts,
@ -66,9 +66,9 @@ class NVMeConnector(base.BaseLinuxConnector):
@staticmethod
def get_connector_properties(root_helper, *args, **kwargs):
"""The NVMe connector properties."""
nvme = NVMeConnector(root_helper=root_helper,
execute=kwargs.get('execute'))
"""The NVMeOF connector properties."""
nvme = NVMeOFConnector(root_helper=root_helper,
execute=kwargs.get('execute'))
uuid = nvme._get_system_uuid()
if uuid:
return {"system uuid": uuid}

View File

@ -15,7 +15,7 @@ import mock
from oslo_concurrency import processutils as putils
from os_brick import exception
from os_brick.initiator.connectors import nvme
from os_brick.initiator.connectors import nvmeof
from os_brick.initiator import linuxscsi
from os_brick.tests.initiator import test_connector
@ -31,17 +31,17 @@ Node SN Model \
"""
class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
class NVMeOFConnectorTestCase(test_connector.ConnectorTestCase):
"""Test cases for NVMe initiator class."""
def setUp(self):
super(NVMeConnectorTestCase, self).setUp()
self.connector = nvme.NVMeConnector(None,
execute=self.fake_execute,
use_multipath=False)
super(NVMeOFConnectorTestCase, self).setUp()
self.connector = nvmeof.NVMeOFConnector(None,
execute=self.fake_execute,
use_multipath=False)
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
def test_get_sysuuid_without_newline(self, mock_execute):
mock_execute.return_value = (
"9126E942-396D-11E7-B0B7-A81E84C186D1\n", "")
@ -49,7 +49,7 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
expected_uuid = "9126E942-396D-11E7-B0B7-A81E84C186D1"
self.assertEqual(expected_uuid, uuid)
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
def test_get_connector_properties_without_sysuuid(
self, mock_execute):
mock_execute.side_effect = putils.ProcessExecutionError
@ -57,7 +57,7 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
expected_props = {}
self.assertEqual(expected_props, props)
@mock.patch.object(nvme.NVMeConnector, '_get_system_uuid')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_system_uuid')
def test_get_connector_properties_with_sysuuid(
self, mock_sysuuid):
mock_sysuuid.return_value = "9126E942-396D-11E7-B0B7-A81E84C186D1"
@ -66,24 +66,24 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
"system uuid": "9126E942-396D-11E7-B0B7-A81E84C186D1"}
self.assertEqual(expected_props, props)
def _nvme_list_cmd(self, *args, **kwargs):
def _nvmeof_list_cmd(self, *args, **kwargs):
return FAKE_NVME_LIST_OUTPUT, None
def test__get_nvme_devices(self):
expected = ['/dev/nvme0n1', '/dev/nvme11n12']
self.connector._execute = self._nvme_list_cmd
self.connector._execute = self._nvmeof_list_cmd
actual = self.connector._get_nvme_devices()
self.assertEqual(expected, actual)
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_get_nvme_devices_raise(self, mock_sleep, mock_execute):
mock_execute.side_effect = putils.ProcessExecutionError
self.assertRaises(exception.CommandExecutionFailed,
self.connector._get_nvme_devices)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_volume(self, mock_sleep, mock_execute, mock_devices):
connection_properties = {'target_portal': 'portal',
@ -111,8 +111,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
root_helper=None,
run_as_root=True)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_volume_hostnqn(
self, mock_sleep, mock_execute, mock_devices):
@ -143,7 +143,7 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
root_helper=None,
run_as_root=True)
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_volume_raise(self, mock_sleep, mock_execute):
connection_properties = {'target_portal': 'portal',
@ -156,8 +156,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.connector.connect_volume,
connection_properties)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_volume_max_retry(
self, mock_sleep, mock_execute, mock_devices):
@ -173,8 +173,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.connector.connect_volume,
connection_properties)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_volume_nvmelist_retry_success(
self, mock_sleep, mock_execute, mock_devices):
@ -192,10 +192,10 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.assertEqual('/dev/nvme0n2', device_info['path'])
self.assertEqual('block', device_info['type'])
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_connect_nvme_retry_success(
def test_connect_nvmeof_retry_success(
self, mock_sleep, mock_execute, mock_devices):
connection_properties = {'target_portal': 'portal',
'target_port': 1,
@ -214,8 +214,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.assertEqual('/dev/nvme0n2', device_info['path'])
self.assertEqual('block', device_info['type'])
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_disconnect_volume_nova(
self, mock_sleep, mock_execute, mock_devices):
@ -233,8 +233,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
root_helper=None,
run_as_root=True)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_disconnect_volume_cinder(
self, mock_sleep, mock_execute, mock_devices):
@ -254,8 +254,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
root_helper=None,
run_as_root=True)
@mock.patch.object(nvme.NVMeConnector, '_get_nvme_devices')
@mock.patch.object(nvme.NVMeConnector, '_execute')
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute')
@mock.patch('time.sleep')
def test_disconnect_volume_raise(
self, mock_sleep, mock_execute, mock_devices):
@ -272,7 +272,7 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
connection_properties,
None)
@mock.patch.object(nvme.NVMeConnector, 'get_volume_paths')
@mock.patch.object(nvmeof.NVMeOFConnector, 'get_volume_paths')
def test_extend_volume_no_path(self, mock_volume_paths):
mock_volume_paths.return_value = []
connection_properties = {'target_portal': 'portal',
@ -287,7 +287,7 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device_path')
@mock.patch.object(linuxscsi.LinuxSCSI, 'extend_volume')
@mock.patch.object(nvme.NVMeConnector, 'get_volume_paths')
@mock.patch.object(nvmeof.NVMeOFConnector, 'get_volume_paths')
def test_extend_volume(self, mock_volume_paths, mock_scsi_extend,
mock_scsi_find_mpath):
fake_new_size = 1024

View File

@ -24,7 +24,7 @@ from os_brick.initiator import connector
from os_brick.initiator.connectors import base
from os_brick.initiator.connectors import fake
from os_brick.initiator.connectors import iscsi
from os_brick.initiator.connectors import nvme
from os_brick.initiator.connectors import nvmeof
from os_brick.initiator import linuxfc
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick.tests import base as test_base
@ -41,7 +41,7 @@ class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
class ConnectorUtilsTestCase(test_base.TestCase):
@mock.patch.object(nvme.NVMeConnector, '_get_system_uuid',
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_system_uuid',
return_value=None)
@mock.patch.object(iscsi.ISCSIConnector, 'get_initiator',
return_value='fakeinitiator')