diff --git a/cinder/tests/unit/targets/test_nvmet_driver.py b/cinder/tests/unit/targets/test_nvmet_driver.py index 61d3718b5f3..8d9141bfc8c 100644 --- a/cinder/tests/unit/targets/test_nvmet_driver.py +++ b/cinder/tests/unit/targets/test_nvmet_driver.py @@ -12,6 +12,7 @@ from unittest import mock +import ddt from oslo_utils import timeutils from cinder import context @@ -20,12 +21,15 @@ from cinder import utils from cinder.volume.targets import nvmet +@ddt.ddt class TestNVMETDriver(tf.TargetDriverFixture): def setUp(self): super(TestNVMETDriver, self).setUp() + self.initialize('nvmet_rdma', 'rdma') - self.configuration.target_protocol = 'nvmet_rdma' + def initialize(self, target_protocol, transport_type): + self.configuration.target_protocol = target_protocol self.target = nvmet.NVMET(root_helper=utils.get_root_helper(), configuration=self.configuration) @@ -34,7 +38,7 @@ class TestNVMETDriver(tf.TargetDriverFixture): self.nvmet_subsystem_name = self.configuration.target_prefix self.nvmet_ns_id = self.configuration.nvmet_ns_id self.nvmet_port_id = self.configuration.nvmet_port_id - self.nvme_transport_type = 'rdma' + self.nvme_transport_type = transport_type self.fake_volume_id = 'c446b9a2-c968-4260-b95f-a18a7b41c004' self.testvol_path = ( @@ -56,12 +60,16 @@ class TestNVMETDriver(tf.TargetDriverFixture): 'created_at': timeutils.utcnow(), 'host': 'fake_host@lvm#lvm'}) + @ddt.data(('nvmet_rdma', 'rdma'), ('nvmet_tcp', 'tcp')) + @ddt.unpack @mock.patch.object(nvmet.NVMET, '_get_nvmf_subsystem') @mock.patch.object(nvmet.NVMET, '_get_available_nvmf_subsystems') @mock.patch.object(nvmet.NVMET, '_add_nvmf_subsystem') - def test_create_export(self, mock_add_nvmf_subsystem, + def test_create_export(self, target_protocol, transport_type, + mock_add_nvmf_subsystem, mock_get_available_nvmf_subsystems, mock_get_nvmf_subsystem): + self.initialize(target_protocol, transport_type) mock_testvol = self.testvol mock_testvol_path = self.testvol_path @@ -75,7 +83,7 @@ class TestNVMETDriver(tf.TargetDriverFixture): "portid": 1, "addr": {"treq": "not specified", - "trtype": "rdma", + "trtype": self.nvme_transport_type, "adrfam": "ipv4", "trsvcid": self.target_port, "traddr": @@ -126,7 +134,7 @@ class TestNVMETDriver(tf.TargetDriverFixture): "portid": 1, "addr": {"treq": "not specified", - "trtype": "rdma", + "trtype": self.nvme_transport_type, "adrfam": "ipv4", "trsvcid": self.target_port, "traddr": @@ -180,7 +188,7 @@ class TestNVMETDriver(tf.TargetDriverFixture): "portid": self.nvmet_port_id, "addr": {"treq": "not specified", - "trtype": "rdma", + "trtype": self.nvme_transport_type, "adrfam": "ipv4", "trsvcid": self.target_port, "traddr": self.target_ip}} @@ -249,7 +257,7 @@ class TestNVMETDriver(tf.TargetDriverFixture): "portid": self.nvmet_port_id, "addr": {"treq": "not specified", - "trtype": "rdma", + "trtype": self.nvme_transport_type, "adrfam": "ipv4", "trsvcid": self.target_port, "traddr": self.target_ip}} diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index e5d434e0ef2..a1dfdf1ebd3 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -136,13 +136,13 @@ volume_opts = [ 'as is to the underlying tool.'), cfg.StrOpt('target_protocol', default='iscsi', - choices=['iscsi', 'iser', 'nvmet_rdma'], + choices=['iscsi', 'iser', 'nvmet_rdma', 'nvmet_tcp'], help='Determines the target protocol for new volumes, ' 'created with tgtadm, lioadm and nvmet target helpers. ' 'In order to enable RDMA, this parameter should be set ' 'with the value "iser". The supported iSCSI protocol ' 'values are "iscsi" and "iser", in case of nvmet target ' - 'set to "nvmet_rdma".'), + 'set to "nvmet_rdma" or "nvmet_tcp".'), cfg.StrOpt('driver_client_cert_key', help='The path to the client certificate key for verification, ' 'if the driver supports it.'), diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 973f8daec7d..955f840770a 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -125,7 +125,7 @@ class LVMVolumeDriver(driver.VolumeDriver): 'target_port', 'iscsi_write_cache', 'iscsi_target_flags', # TGT 'iet_conf', 'iscsi_iotype', # IET - 'nvmet_port_id', # NVMET + 'nvmet_port_id', 'nvmet_ns_id', # NVMET 'scst_target_iqn_name', 'scst_target_driver', # SCST 'spdk_rpc_ip', 'spdk_rpc_port', 'spdk_rpc_username', # SPDKNVMF 'spdk_rpc_password', 'spdk_max_queue_depth', # SPDKNVMF diff --git a/cinder/volume/targets/nvmeof.py b/cinder/volume/targets/nvmeof.py index c4d30062c4d..f250f60c7eb 100644 --- a/cinder/volume/targets/nvmeof.py +++ b/cinder/volume/targets/nvmeof.py @@ -34,6 +34,7 @@ class NVMeOF(driver.Target): protocol = 'nvmeof' target_protocol_map = { 'nvmet_rdma': 'rdma', + 'nvmet_tcp': 'tcp', } def __init__(self, *args, **kwargs): diff --git a/cinder/volume/targets/nvmet.py b/cinder/volume/targets/nvmet.py index 59c7b5fb2b5..5ebc73064dd 100644 --- a/cinder/volume/targets/nvmet.py +++ b/cinder/volume/targets/nvmet.py @@ -62,7 +62,7 @@ class NVMET(nvmeof.NVMeOF): target_port, nvmet_port_id, subsystem_name, - ns_id, volume_id, volume_path) + ns_id, volume_id, volume_path, transport_type) if newly_added_subsystem is None: LOG.error('Failed to add subsystem: %s', subsystem_name) raise NVMETTargetAddError(subsystem=subsystem_name) @@ -93,7 +93,7 @@ class NVMET(nvmeof.NVMeOF): def _add_nvmf_subsystem(self, nvmf_subsystems, target_ip, target_port, nvmet_port_id, nvmet_subsystem_name, nvmet_ns_id, - volume_id, volume_path): + volume_id, volume_path, transport_type): subsystem_name = self._get_target_info(nvmet_subsystem_name, volume_id) # Create JSON sections for the new subsystem to be created @@ -104,7 +104,7 @@ class NVMET(nvmeof.NVMeOF): "traddr": target_ip, "treq": "not specified", "trsvcid": target_port, - "trtype": "rdma" + "trtype": transport_type, }, "portid": nvmet_port_id, "referrals": [], diff --git a/releasenotes/notes/lvm-nvmet-tcp-72a41be1a1fe0fbd.yaml b/releasenotes/notes/lvm-nvmet-tcp-72a41be1a1fe0fbd.yaml new file mode 100644 index 00000000000..5c65c74ab6c --- /dev/null +++ b/releasenotes/notes/lvm-nvmet-tcp-72a41be1a1fe0fbd.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + LVM driver: Added support for the NVMe TCP transport protocol. + Configuration option is ``target_protocol = nvmet_tcp`` when using + ``nvmet`` as the ``target_helper``.