From 68311a0794435f98d2b86b2faa9970208f50b746 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor <geguileo@redhat.com> Date: Mon, 18 Apr 2022 17:37:34 +0200 Subject: [PATCH] Fix cacheable capability When using the LVM cinder driver the cacheable capability is not being reported by the backend to the scheduler when the transport protocol is NVMe-oF (nvmet target driver), but it is properly reported if it's the LIO target driver. This also happens with other drivers that should be reporting that they are cacheable. This happens because even if the volume manager correctly uses the "storage_protocol" reported by the drivers on their stats to add the "cacheable" capability for iSCSI, FC, and NVMe-oF protocols, it isn't taking into account all the variants these have: - FC, fc, fibre_channel - iSCSI, iscsi - NVMe-oF, nvmeof, NVMeOF Same thing happens for the shared_targets of the volumes, which are not missing an iSCSI variant. This patch creates constants for the different storge protocols to try to avoid these variants (as agreed on the PTG) and also makes the cacheable and shared_targets check against all the existing variants. This change facilitates identifying NVMe-oF drivers (for bug 1961102) for the shared_targets part. Closes-Bug: #1969366 Related-Bug: #1961102 Change-Id: I1333b0471974e94eb2b3b79ea70a06e0afe28cd9 --- cinder/common/constants.py | 30 +++++++++++++++++++ cinder/volume/driver.py | 11 +++---- cinder/volume/drivers/ceph/rbd_iscsi.py | 3 +- cinder/volume/drivers/datera/datera_api21.py | 3 +- cinder/volume/drivers/datera/datera_api22.py | 3 +- .../drivers/dell_emc/powerflex/driver.py | 3 +- cinder/volume/drivers/dell_emc/powermax/fc.py | 3 +- .../volume/drivers/dell_emc/powermax/iscsi.py | 3 +- .../drivers/dell_emc/powerstore/adapter.py | 5 ++-- .../drivers/dell_emc/sc/storagecenter_api.py | 3 +- .../dell_emc/sc/storagecenter_common.py | 3 +- .../drivers/dell_emc/sc/storagecenter_fc.py | 3 +- .../volume/drivers/dell_emc/unity/adapter.py | 5 ++-- cinder/volume/drivers/dell_emc/xtremio.py | 5 ++-- .../fujitsu/eternus_dx/eternus_dx_fc.py | 3 +- .../fujitsu/eternus_dx/eternus_dx_iscsi.py | 3 +- cinder/volume/drivers/fusionstorage/dsware.py | 3 +- cinder/volume/drivers/hedvig/hedvig_cinder.py | 3 +- cinder/volume/drivers/hpe/hpe_3par_fc.py | 3 +- cinder/volume/drivers/hpe/hpe_3par_iscsi.py | 3 +- cinder/volume/drivers/hpe/nimble.py | 15 +++++----- cinder/volume/drivers/huawei/huawei_driver.py | 5 ++-- cinder/volume/drivers/ibm/gpfs.py | 5 ++-- .../ibm/storwize_svc/storwize_svc_iscsi.py | 3 +- cinder/volume/drivers/infinidat.py | 20 +++++++------ .../drivers/inspur/as13000/as13000_driver.py | 4 +-- .../inspur/instorage/instorage_common.py | 9 +++--- .../volume/drivers/kaminario/kaminario_fc.py | 3 +- .../drivers/kaminario/kaminario_iscsi.py | 3 +- cinder/volume/drivers/kioxia/kumoscale.py | 3 +- cinder/volume/drivers/lightos.py | 4 +-- cinder/volume/drivers/linstordrv.py | 5 ++-- cinder/volume/drivers/macrosan/driver.py | 5 ++-- cinder/volume/drivers/nec/volume_helper.py | 5 ++-- .../drivers/netapp/dataontap/nfs_cmode.py | 3 +- cinder/volume/drivers/nexenta/iscsi.py | 3 +- cinder/volume/drivers/nexenta/nfs.py | 3 +- cinder/volume/drivers/nexenta/ns5/iscsi.py | 3 +- cinder/volume/drivers/nexenta/ns5/nfs.py | 3 +- cinder/volume/drivers/open_e/iscsi.py | 3 +- cinder/volume/drivers/prophetstor/dpl_fc.py | 3 +- .../volume/drivers/prophetstor/dpl_iscsi.py | 3 +- .../volume/drivers/prophetstor/dplcommon.py | 3 +- cinder/volume/drivers/pure.py | 5 ++-- cinder/volume/drivers/qnap.py | 3 +- cinder/volume/drivers/rbd.py | 5 ++-- cinder/volume/drivers/rsd.py | 3 +- cinder/volume/drivers/sandstone/sds_driver.py | 3 +- cinder/volume/drivers/solidfire.py | 3 +- cinder/volume/drivers/spdk.py | 5 ++-- cinder/volume/drivers/storpool.py | 3 +- cinder/volume/drivers/stx/fc.py | 3 +- cinder/volume/drivers/stx/iscsi.py | 3 +- .../drivers/toyou/acs5000/acs5000_common.py | 3 +- .../drivers/toyou/acs5000/acs5000_fc.py | 3 +- .../drivers/toyou/acs5000/acs5000_iscsi.py | 3 +- .../drivers/veritas_access/veritas_iscsi.py | 4 +-- cinder/volume/drivers/veritas_cnfs.py | 3 +- cinder/volume/drivers/vmware/fcd.py | 3 +- cinder/volume/drivers/vmware/vmdk.py | 3 +- cinder/volume/drivers/windows/iscsi.py | 3 +- cinder/volume/drivers/zadara/zadara.py | 5 ++-- cinder/volume/manager.py | 9 +++--- cinder/volume/targets/iscsi.py | 3 +- cinder/volume/targets/nvmeof.py | 3 +- ...cacheable-capability-f893520d79c3db60.yaml | 5 ++++ 66 files changed, 200 insertions(+), 103 deletions(-) create mode 100644 releasenotes/notes/fix-cacheable-capability-f893520d79c3db60.yaml diff --git a/cinder/common/constants.py b/cinder/common/constants.py index 61c84132d74..d8030333070 100644 --- a/cinder/common/constants.py +++ b/cinder/common/constants.py @@ -29,3 +29,33 @@ LOG_BINARIES = (SCHEDULER_BINARY, VOLUME_BINARY, BACKUP_BINARY, API_BINARY) # The encryption key ID used by the legacy fixed-key ConfKeyMgr FIXED_KEY_ID = '00000000-0000-0000-0000-000000000000' + +# Storage protocol constants +CEPH = 'ceph' +DRBD = 'DRBD' +FC = 'FC' +FC_VARIANT_1 = 'fibre_channel' +FC_VARIANT_2 = 'fc' +FILE = 'file' +ISCSI = 'iSCSI' +ISCSI_VARIANT = 'iscsi' +ISER = 'iSER' +LIGHTOS = 'lightos' +NFS = 'NFS' +NFS_VARIANT = 'nfs' +NVMEOF = 'NVMe-oF' +NVMEOF_VARIANT_1 = 'NVMeOF' +NVMEOF_VARIANT_2 = 'nvmeof' +SCALEIO = 'scaleio' +SCSI = 'SCSI' +STORPOOL = 'storpool' +VMDK = 'vmdk' +VSTORAGE = 'vstorageobject' + +# These must be strings, because there are places that check specific type +ISCSI_VARIANTS = [ISCSI, ISCSI_VARIANT] +FC_VARIANTS = [FC, FC_VARIANT_1, FC_VARIANT_2] +NFS_VARIANTS = [NFS, NFS_VARIANT] +NVMEOF_VARIANTS = [NVMEOF, NVMEOF_VARIANT_1, NVMEOF_VARIANT_2] + +CACHEABLE_PROTOCOLS = FC_VARIANTS + ISCSI_VARIANTS + NVMEOF_VARIANTS diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 69d6b22d01c..5f097f19a8e 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -25,6 +25,7 @@ from oslo_config import types from oslo_log import log as logging from oslo_utils import excutils +from cinder.common import constants from cinder import db from cinder import exception from cinder.i18n import _ @@ -221,8 +222,8 @@ volume_opts = [ 'directly, it will only notify that it can be used.'), cfg.StrOpt('storage_protocol', ignore_case=True, - default='iscsi', - choices=['iscsi', 'fc'], + default=constants.ISCSI, + choices=[constants.ISCSI, constants.FC], help='Protocol for transferring data between host and ' 'storage back-end.'), cfg.BoolOpt('enable_unsupported_driver', @@ -2805,7 +2806,7 @@ class ISCSIDriver(VolumeDriver): data["volume_backend_name"] = backend_name or 'Generic_iSCSI' data["vendor_name"] = 'Open Source' data["driver_version"] = '1.0' - data["storage_protocol"] = 'iSCSI' + data["storage_protocol"] = constants.ISCSI data["pools"] = [] data["replication_enabled"] = False @@ -2874,7 +2875,7 @@ class ISERDriver(ISCSIDriver): data["volume_backend_name"] = backend_name or 'Generic_iSER' data["vendor_name"] = 'Open Source' data["driver_version"] = '1.0' - data["storage_protocol"] = 'iSER' + data["storage_protocol"] = constants.ISER data["pools"] = [] self._update_pools_and_stats(data) @@ -2950,7 +2951,7 @@ class FibreChannelDriver(VolumeDriver): data["volume_backend_name"] = backend_name or 'Generic_FC' data["vendor_name"] = 'Open Source' data["driver_version"] = '1.0' - data["storage_protocol"] = 'FC' + data["storage_protocol"] = constants.FC data["pools"] = [] self._update_pools_and_stats(data) diff --git a/cinder/volume/drivers/ceph/rbd_iscsi.py b/cinder/volume/drivers/ceph/rbd_iscsi.py index 8ec821493e6..42aa3c65fea 100644 --- a/cinder/volume/drivers/ceph/rbd_iscsi.py +++ b/cinder/volume/drivers/ceph/rbd_iscsi.py @@ -17,6 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import netutils +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -72,7 +73,7 @@ class RBDISCSIDriver(rbd.RBDDriver): SUPPORTS_ACTIVE_ACTIVE = True - STORAGE_PROTOCOL = 'iSCSI' + STORAGE_PROTOCOL = constants.ISCSI CHAP_LENGTH = 16 # The target IQN to use for creating all exports diff --git a/cinder/volume/drivers/datera/datera_api21.py b/cinder/volume/drivers/datera/datera_api21.py index 2379f3606c5..69d161e8729 100644 --- a/cinder/volume/drivers/datera/datera_api21.py +++ b/cinder/volume/drivers/datera/datera_api21.py @@ -28,6 +28,7 @@ from oslo_utils import importutils from oslo_utils import units import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -975,7 +976,7 @@ class DateraApi(object): 'volume_backend_name': self.backend_name, 'vendor_name': 'Datera', 'driver_version': self.VERSION, - 'storage_protocol': 'iSCSI', + 'storage_protocol': constants.ISCSI, 'total_capacity_gb': ( int(results.total_capacity) / units.Gi), 'free_capacity_gb': ( diff --git a/cinder/volume/drivers/datera/datera_api22.py b/cinder/volume/drivers/datera/datera_api22.py index 4dab3d9b798..1fa26c6660d 100644 --- a/cinder/volume/drivers/datera/datera_api22.py +++ b/cinder/volume/drivers/datera/datera_api22.py @@ -28,6 +28,7 @@ from oslo_utils import importutils from oslo_utils import units import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -1026,7 +1027,7 @@ class DateraApi(object): 'volume_backend_name': self.backend_name, 'vendor_name': 'Datera', 'driver_version': self.VERSION, - 'storage_protocol': 'iSCSI', + 'storage_protocol': constants.ISCSI, 'total_capacity_gb': ( int(results.total_capacity) / units.Gi), 'free_capacity_gb': ( diff --git a/cinder/volume/drivers/dell_emc/powerflex/driver.py b/cinder/volume/drivers/dell_emc/powerflex/driver.py index 7989af24658..0ac24fd50f5 100644 --- a/cinder/volume/drivers/dell_emc/powerflex/driver.py +++ b/cinder/volume/drivers/dell_emc/powerflex/driver.py @@ -29,6 +29,7 @@ from oslo_utils import units import six from six.moves import http_client +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -956,7 +957,7 @@ class PowerFlexDriver(driver.VolumeDriver): stats["volume_backend_name"] = backend_name or "powerflex" stats["vendor_name"] = "Dell EMC" stats["driver_version"] = self.VERSION - stats["storage_protocol"] = "scaleio" + stats["storage_protocol"] = constants.SCALEIO stats["reserved_percentage"] = 0 stats["QoS_support"] = True stats["consistent_group_snapshot_enabled"] = True diff --git a/cinder/volume/drivers/dell_emc/powermax/fc.py b/cinder/volume/drivers/dell_emc/powermax/fc.py index f477bd3e066..2a2824a365b 100644 --- a/cinder/volume/drivers/dell_emc/powermax/fc.py +++ b/cinder/volume/drivers/dell_emc/powermax/fc.py @@ -17,6 +17,7 @@ import ast from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder import interface from cinder.volume import driver @@ -538,7 +539,7 @@ class PowerMaxFCDriver(san.SanDriver, driver.FibreChannelDriver): """Retrieve stats info from volume group.""" LOG.debug("Updating volume stats") data = self.common.update_volume_stats() - data['storage_protocol'] = 'FC' + data['storage_protocol'] = constants.FC data['driver_version'] = self.VERSION self._stats = data diff --git a/cinder/volume/drivers/dell_emc/powermax/iscsi.py b/cinder/volume/drivers/dell_emc/powermax/iscsi.py index 21e9ab537db..c87f05d19cd 100644 --- a/cinder/volume/drivers/dell_emc/powermax/iscsi.py +++ b/cinder/volume/drivers/dell_emc/powermax/iscsi.py @@ -22,6 +22,7 @@ from oslo_log import log as logging from oslo_utils import strutils import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -452,7 +453,7 @@ class PowerMaxISCSIDriver(san.SanISCSIDriver): """Retrieve stats info from volume group.""" LOG.debug("Updating volume stats") data = self.common.update_volume_stats() - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = constants.ISCSI data['driver_version'] = self.VERSION self._stats = data diff --git a/cinder/volume/drivers/dell_emc/powerstore/adapter.py b/cinder/volume/drivers/dell_emc/powerstore/adapter.py index 343e12a2ea3..2154a106b9c 100644 --- a/cinder/volume/drivers/dell_emc/powerstore/adapter.py +++ b/cinder/volume/drivers/dell_emc/powerstore/adapter.py @@ -18,6 +18,7 @@ from oslo_log import log as logging from oslo_utils import strutils +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -31,8 +32,8 @@ from cinder.volume import volume_utils LOG = logging.getLogger(__name__) -PROTOCOL_FC = "FC" -PROTOCOL_ISCSI = "iSCSI" +PROTOCOL_FC = constants.FC +PROTOCOL_ISCSI = constants.ISCSI CHAP_MODE_SINGLE = "Single" diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py index 7c08a99d942..1d7ab1d8d62 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py @@ -24,6 +24,7 @@ import requests import six from six.moves import http_client +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import utils @@ -373,7 +374,7 @@ class SCApiHelper(object): connection.excluded_domain_ips)) # Our primary SSN doesn't change connection.primaryssn = self.primaryssn - if self.storage_protocol == 'FC': + if self.storage_protocol == constants.FC: connection.protocol = 'FibreChannel' # Set appropriate ssn and failover state. if self.active_backend_id: diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_common.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_common.py index 5e78ef4e390..67ce942ad36 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_common.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_common.py @@ -19,6 +19,7 @@ from oslo_log import log as logging from oslo_utils import excutils import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.objects import fields @@ -112,7 +113,7 @@ class SCCommonDriver(driver.ManageableVD, LOG.info('Loading %(name)s: Failover state is %(state)r', {'name': self.backend_name, 'state': self.failed_over}) - self.storage_protocol = 'iSCSI' + self.storage_protocol = constants.ISCSI self.failback_timeout = 60 @staticmethod diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_fc.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_fc.py index 377edfc8233..636a56b9094 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_fc.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_fc.py @@ -17,6 +17,7 @@ from oslo_log import log as logging from oslo_utils import excutils +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -77,7 +78,7 @@ class SCFCDriver(storagecenter_common.SCCommonDriver, super(SCFCDriver, self).__init__(*args, **kwargs) self.backend_name =\ self.configuration.safe_get('volume_backend_name') or 'Dell-FC' - self.storage_protocol = 'FC' + self.storage_protocol = constants.FC def validate_connector(self, connector): """Fail if connector doesn't contain all the data needed by driver. diff --git a/cinder/volume/drivers/dell_emc/unity/adapter.py b/cinder/volume/drivers/dell_emc/unity/adapter.py index 93a8eb7d95f..6ee99fbb420 100644 --- a/cinder/volume/drivers/dell_emc/unity/adapter.py +++ b/cinder/volume/drivers/dell_emc/unity/adapter.py @@ -24,6 +24,7 @@ from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import importutils +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.objects import fields @@ -44,8 +45,8 @@ else: LOG = logging.getLogger(__name__) -PROTOCOL_FC = 'FC' -PROTOCOL_ISCSI = 'iSCSI' +PROTOCOL_FC = constants.FC +PROTOCOL_ISCSI = constants.ISCSI class VolumeParams(object): diff --git a/cinder/volume/drivers/dell_emc/xtremio.py b/cinder/volume/drivers/dell_emc/xtremio.py index 53847a7a6c9..567096e495d 100644 --- a/cinder/volume/drivers/dell_emc/xtremio.py +++ b/cinder/volume/drivers/dell_emc/xtremio.py @@ -49,6 +49,7 @@ import requests import six from six.moves import http_client +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -1101,7 +1102,7 @@ class XtremIOISCSIDriver(XtremIOVolumeDriver, driver.ISCSIDriver): def __init__(self, *args, **kwargs): super(XtremIOISCSIDriver, self).__init__(*args, **kwargs) - self.protocol = 'iSCSI' + self.protocol = constants.ISCSI def _add_auth(self, data, login_chap, discovery_chap): login_passwd, discovery_passwd = None, None @@ -1240,7 +1241,7 @@ class XtremIOFCDriver(XtremIOVolumeDriver, def __init__(self, *args, **kwargs): super(XtremIOFCDriver, self).__init__(*args, **kwargs) - self.protocol = 'FC' + self.protocol = constants.FC self._targets = None def get_targets(self): diff --git a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_fc.py b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_fc.py index b5c8bf398cd..550ae38e1da 100644 --- a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_fc.py +++ b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_fc.py @@ -22,6 +22,7 @@ FibreChannel Cinder Volume driver for Fujitsu ETERNUS DX S3 series. from oslo_log import log as logging import six +from cinder.common import constants from cinder import interface from cinder.volume import driver from cinder.volume.drivers.fujitsu.eternus_dx import eternus_dx_common @@ -202,7 +203,7 @@ class FJDXFCDriver(driver.FibreChannelDriver): data, pool_name = self.common.update_volume_stats() backend_name = self.configuration.safe_get('volume_backend_name') data['volume_backend_name'] = backend_name or 'FJDXFCDriver' - data['storage_protocol'] = 'FC' + data['storage_protocol'] = constants.FC self._stats = data LOG.debug('get_volume_stats, ' diff --git a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py index a158a7e98ae..f3d7fdd58d5 100644 --- a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py +++ b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py @@ -20,6 +20,7 @@ from oslo_log import log as logging import six +from cinder.common import constants from cinder import interface from cinder.volume import driver from cinder.volume.drivers.fujitsu.eternus_dx import eternus_dx_common @@ -192,7 +193,7 @@ class FJDXISCSIDriver(driver.ISCSIDriver): data, pool_name = self.common.update_volume_stats() backend_name = self.configuration.safe_get('volume_backend_name') data['volume_backend_name'] = backend_name or 'FJDXISCSIDriver' - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = constants.ISCSI self._stats = data LOG.debug('get_volume_stats, ' diff --git a/cinder/volume/drivers/fusionstorage/dsware.py b/cinder/volume/drivers/fusionstorage/dsware.py index 91a2d9cf8cb..43b4eac85b9 100644 --- a/cinder/volume/drivers/fusionstorage/dsware.py +++ b/cinder/volume/drivers/fusionstorage/dsware.py @@ -19,6 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import units +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -159,7 +160,7 @@ class DSWAREDriver(driver.VolumeDriver): "thin_provisioning_support": False, "pools": [], "vendor_name": "Huawei", - "storage_protocol": "SCSI", + "storage_protocol": constants.SCSI, } all_pools = self.client.query_pool_info() diff --git a/cinder/volume/drivers/hedvig/hedvig_cinder.py b/cinder/volume/drivers/hedvig/hedvig_cinder.py index f7cc9756d41..58a4b0a83b7 100644 --- a/cinder/volume/drivers/hedvig/hedvig_cinder.py +++ b/cinder/volume/drivers/hedvig/hedvig_cinder.py @@ -24,6 +24,7 @@ from oslo_log import log as logging from oslo_utils import strutils from oslo_utils import units +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -97,7 +98,7 @@ class HedvigISCSIDriver(driver.ISCSIDriver, san.SanDriver): stats["volume_backend_name"] = "hedvig" stats["vendor_name"] = "Hedvig Inc" stats["driver_version"] = self.VERSION - stats["storage_protocol"] = "iSCSI" + stats["storage_protocol"] = constants.ISCSI stats["total_capacity_gb"] = total_capacity stats["free_capacity_gb"] = free_capacity stats["QoS_support"] = True diff --git a/cinder/volume/drivers/hpe/hpe_3par_fc.py b/cinder/volume/drivers/hpe/hpe_3par_fc.py index 4fd702492e2..e0874dd4b2e 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_fc.py +++ b/cinder/volume/drivers/hpe/hpe_3par_fc.py @@ -37,6 +37,7 @@ except ImportError: from oslo_log import log as logging from oslo_utils.excutils import save_and_reraise_exception +from cinder.common import constants from cinder import coordination from cinder import interface from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver @@ -125,7 +126,7 @@ class HPE3PARFCDriver(hpebasedriver.HPE3PARDriverBase): def __init__(self, *args, **kwargs): super(HPE3PARFCDriver, self).__init__(*args, **kwargs) self.lookup_service = fczm_utils.create_lookup_service() - self.protocol = 'FC' + self.protocol = constants.FC def _initialize_connection_common(self, volume, connector, common, host, target_wwns, init_targ_map, numPaths, diff --git a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py index ab851868d9c..2d949840e32 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py @@ -38,6 +38,7 @@ except ImportError: from oslo_log import log as logging from oslo_utils.excutils import save_and_reraise_exception +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -138,7 +139,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase): def __init__(self, *args, **kwargs): super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs) - self.protocol = 'iSCSI' + self.protocol = constants.ISCSI def _do_setup(self, common): client_obj = common.client diff --git a/cinder/volume/drivers/hpe/nimble.py b/cinder/volume/drivers/hpe/nimble.py index cbabc58f9b7..f061176c0e2 100644 --- a/cinder/volume/drivers/hpe/nimble.py +++ b/cinder/volume/drivers/hpe/nimble.py @@ -34,6 +34,7 @@ from oslo_utils import units import requests import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -586,7 +587,7 @@ class NimbleBaseVolumeDriver(san.SanDriver): password=self.configuration.san_password, ip=self.configuration.san_ip, verify=self.verify) - if self._storage_protocol == "iSCSI": + if self._storage_protocol == constants.ISCSI: group_info = self.APIExecutor.get_group_info() self._enable_group_scoped_target(group_info) except Exception: @@ -670,10 +671,10 @@ class NimbleBaseVolumeDriver(san.SanDriver): LOG.info('Creating initiator group %(grp)s ' 'with initiator %(iname)s', {'grp': igrp_name, 'iname': initiator_name}) - if self._storage_protocol == "iSCSI": + if self._storage_protocol == constants.ISCSI: self.APIExecutor.create_initiator_group(igrp_name) self.APIExecutor.add_initiator_to_igroup(igrp_name, initiator_name) - elif self._storage_protocol == "FC": + elif self._storage_protocol == constants.FC: self.APIExecutor.create_initiator_group_fc(igrp_name) for wwpn in wwpns: self.APIExecutor.add_initiator_to_igroup_fc(igrp_name, wwpn) @@ -952,7 +953,7 @@ class NimbleISCSIDriver(NimbleBaseVolumeDriver, san.SanISCSIDriver): def __init__(self, *args, **kwargs): super(NimbleISCSIDriver, self).__init__(*args, **kwargs) - self._storage_protocol = "iSCSI" + self._storage_protocol = constants.ISCSI self._group_target_name = None def _set_gst_for_group(self): @@ -1126,7 +1127,7 @@ class NimbleFCDriver(NimbleBaseVolumeDriver, driver.FibreChannelDriver): def __init__(self, *args, **kwargs): super(NimbleFCDriver, self).__init__(*args, **kwargs) - self._storage_protocol = "FC" + self._storage_protocol = constants.FC self._lookup_service = fczm_utils.create_lookup_service() def _get_provider_location(self, volume_name): @@ -1545,7 +1546,7 @@ class NimbleRestAPIExecutor(object): 'perfpolicy_id': perf_policy_id, 'encryption_cipher': cipher}} - if protocol == "iSCSI": + if protocol == constants.ISCSI: data['data']['multi_initiator'] = multi_initiator if dedupe.lower() == 'true': @@ -2012,7 +2013,7 @@ class NimbleRestAPIExecutor(object): "encryption_cipher": cipher } } - if protocol == "iSCSI": + if protocol == constants.ISCSI: data['data']['multi_initiator'] = multi_initiator folder_id = None diff --git a/cinder/volume/drivers/huawei/huawei_driver.py b/cinder/volume/drivers/huawei/huawei_driver.py index 1095cf0d73b..0312ba34828 100644 --- a/cinder/volume/drivers/huawei/huawei_driver.py +++ b/cinder/volume/drivers/huawei/huawei_driver.py @@ -18,6 +18,7 @@ import json from oslo_log import log as logging from oslo_utils import strutils +from cinder.common import constants as cinder_constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -72,7 +73,7 @@ class HuaweiISCSIDriver(common.HuaweiBaseDriver, driver.ISCSIDriver): def get_volume_stats(self, refresh=False): """Get volume status.""" data = self._get_volume_stats(refresh=False) - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = cinder_constants.ISCSI data['driver_version'] = self.VERSION return data @@ -264,7 +265,7 @@ class HuaweiFCDriver(common.HuaweiBaseDriver, driver.FibreChannelDriver): def get_volume_stats(self, refresh=False): """Get volume status.""" data = self._get_volume_stats(refresh=False) - data['storage_protocol'] = 'FC' + data['storage_protocol'] = cinder_constants.FC data['driver_version'] = self.VERSION return data diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index aa9ea89ebe5..892e7ce384b 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -28,6 +28,7 @@ from oslo_utils import units import paramiko import six +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -856,7 +857,7 @@ class GPFSDriver(driver.CloneableImageVD, data["volume_backend_name"] = backend_name or 'GPFS' data["vendor_name"] = 'IBM' data["driver_version"] = self.VERSION - data["storage_protocol"] = 'file' + data["storage_protocol"] = constants.FILE free, capacity = self._get_available_capacity(self.configuration. gpfs_mount_point_base) data['total_capacity_gb'] = math.ceil(capacity / units.Gi) @@ -1561,7 +1562,7 @@ class GPFSNFSDriver(GPFSDriver, nfs.NfsDriver, san.SanDriver): data['volume_backend_name'] = backend_name or 'GPFSNFS' data['vendor_name'] = 'IBM' data['driver_version'] = self.get_version() - data['storage_protocol'] = 'file' + data['storage_protocol'] = constants.FILE self._ensure_shares_mounted() diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py index 9e4d9211f60..041a5f6276d 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py @@ -39,6 +39,7 @@ from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import strutils +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -104,7 +105,7 @@ class StorwizeSVCISCSIDriver(storwize_common.StorwizeSVCCommonDriver): def __init__(self, *args, **kwargs): super(StorwizeSVCISCSIDriver, self).__init__(*args, **kwargs) - self.protocol = 'iSCSI' + self.protocol = constants.ISCSI self.configuration.append_config_values( storwize_svc_iscsi_opts) diff --git a/cinder/volume/drivers/infinidat.py b/cinder/volume/drivers/infinidat.py index f9a7853196a..0dae912b1b7 100644 --- a/cinder/volume/drivers/infinidat.py +++ b/cinder/volume/drivers/infinidat.py @@ -24,6 +24,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import units +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -164,12 +165,12 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): self._backend_name = backend_name or self.__class__.__name__ self._volume_stats = None if self.configuration.infinidat_storage_protocol.lower() == 'iscsi': - self._protocol = 'iSCSI' + self._protocol = constants.ISCSI if len(self.configuration.infinidat_iscsi_netspaces) == 0: msg = _('No iSCSI network spaces configured') raise exception.VolumeDriverException(message=msg) else: - self._protocol = 'FC' + self._protocol = constants.FC if (self.configuration.infinidat_use_compression and not self._system.compat.has_compression()): # InfiniBox systems support compression only from v3.0 and up @@ -182,7 +183,8 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): LOG.debug('setup complete') def validate_connector(self, connector): - required = 'initiator' if self._protocol == 'iSCSI' else 'wwpns' + required = ('initiator' if self._protocol == constants.ISCSI + else 'wwpns') if required not in connector: LOG.error('The volume driver requires %(data)s ' 'in the connector.', {'data': required}) @@ -419,7 +421,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): if connector is None: # If no connector was provided it is a force-detach - remove all # host connections for the volume - if self._protocol == 'FC': + if self._protocol == constants.FC: port_cls = wwn.WWN else: port_cls = iqn.IQN @@ -429,7 +431,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): host_ports = [port for port in host_ports if isinstance(port, port_cls)] ports.extend(host_ports) - elif self._protocol == 'FC': + elif self._protocol == constants.FC: ports = [wwn.WWN(wwpn) for wwpn in connector['wwpns']] else: ports = [iqn.IQN(connector['initiator'])] @@ -439,7 +441,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): @coordination.synchronized('infinidat-{self.management_address}-lock') def initialize_connection(self, volume, connector): """Map an InfiniBox volume to the host""" - if self._protocol == 'FC': + if self._protocol == constants.FC: return self._initialize_connection_fc(volume, connector) else: return self._initialize_connection_iscsi(volume, connector) @@ -449,7 +451,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): def terminate_connection(self, volume, connector, **kwargs): """Unmap an InfiniBox volume from the host""" infinidat_volume = self._get_infinidat_volume(volume) - if self._protocol == 'FC': + if self._protocol == constants.FC: volume_type = 'fibre_channel' else: volume_type = 'iscsi' @@ -469,7 +471,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): # check if the host now doesn't have mappings if host is not None and len(host.get_luns()) == 0: host.safe_delete() - if self._protocol == 'FC' and connector is not None: + if self._protocol == constants.FC and connector is not None: # Create initiator-target mapping to delete host entry # this is only relevant for regular (specific host) detach target_wwpns = list(self._get_online_fc_ports()) @@ -480,7 +482,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): initiator_target_map=target_map) conn_info = dict(driver_volume_type=volume_type, data=result_data) - if self._protocol == 'FC': + if self._protocol == constants.FC: fczm_utils.remove_fc_zone(conn_info) return conn_info diff --git a/cinder/volume/drivers/inspur/as13000/as13000_driver.py b/cinder/volume/drivers/inspur/as13000/as13000_driver.py index 59ca8ddec08..70e85d629af 100644 --- a/cinder/volume/drivers/inspur/as13000/as13000_driver.py +++ b/cinder/volume/drivers/inspur/as13000/as13000_driver.py @@ -29,6 +29,7 @@ from oslo_log import log as logging from oslo_utils import units import requests +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -176,7 +177,6 @@ class AS13000Driver(san.SanISCSIDriver): VENDOR = 'INSPUR' VERSION = '1.0.0' - PROTOCOL = 'iSCSI' # ThirdPartySystems wiki page CI_WIKI_NAME = 'Inspur_CI' @@ -474,7 +474,7 @@ class AS13000Driver(san.SanISCSIDriver): backend_name = self.configuration.safe_get('volume_backend_name') data['vendor_name'] = self.VENDOR data['driver_version'] = self.VERSION - data['storage_protocol'] = self.PROTOCOL + data['storage_protocol'] = constants.ISCSI data['volume_backend_name'] = backend_name data['pools'] = self._get_pools_stats() diff --git a/cinder/volume/drivers/inspur/instorage/instorage_common.py b/cinder/volume/drivers/inspur/instorage/instorage_common.py index 4945ab68e65..66b9953cc52 100644 --- a/cinder/volume/drivers/inspur/instorage/instorage_common.py +++ b/cinder/volume/drivers/inspur/instorage/instorage_common.py @@ -32,6 +32,7 @@ from oslo_utils import units import paramiko import six +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -212,11 +213,11 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver): for k, node in self._state['storage_nodes'].items(): if ((len(node['ipv4']) or len(node['ipv6'])) and len(node['iscsi_name'])): - node['enabled_protocols'].append('iSCSI') - self._state['enabled_protocols'].add('iSCSI') + node['enabled_protocols'].append(constants.ISCSI) + self._state['enabled_protocols'].add(constants.ISCSI) if len(node['WWPN']): - node['enabled_protocols'].append('FC') - self._state['enabled_protocols'].add('FC') + node['enabled_protocols'].append(constants.FC) + self._state['enabled_protocols'].add(constants.FC) if not len(node['enabled_protocols']): to_delete.append(k) for delkey in to_delete: diff --git a/cinder/volume/drivers/kaminario/kaminario_fc.py b/cinder/volume/drivers/kaminario/kaminario_fc.py index f1db77db2cb..c00ae1490fb 100644 --- a/cinder/volume/drivers/kaminario/kaminario_fc.py +++ b/cinder/volume/drivers/kaminario/kaminario_fc.py @@ -15,6 +15,7 @@ """Volume driver for Kaminario K2 all-flash arrays.""" from oslo_log import log as logging +from cinder.common import constants from cinder import coordination from cinder.i18n import _ from cinder.objects import fields @@ -45,7 +46,7 @@ class KaminarioFCDriver(common.KaminarioCinderDriver): @volume_utils.trace def __init__(self, *args, **kwargs): super(KaminarioFCDriver, self).__init__(*args, **kwargs) - self._protocol = 'FC' + self._protocol = constants.FC self.lookup_service = fczm_utils.create_lookup_service() @volume_utils.trace diff --git a/cinder/volume/drivers/kaminario/kaminario_iscsi.py b/cinder/volume/drivers/kaminario/kaminario_iscsi.py index 5d97c3ce104..c93abccee04 100644 --- a/cinder/volume/drivers/kaminario/kaminario_iscsi.py +++ b/cinder/volume/drivers/kaminario/kaminario_iscsi.py @@ -15,6 +15,7 @@ """Volume driver for Kaminario K2 all-flash arrays.""" from oslo_log import log as logging +from cinder.common import constants from cinder import coordination from cinder.i18n import _ from cinder import interface @@ -50,7 +51,7 @@ class KaminarioISCSIDriver(common.KaminarioCinderDriver): @volume_utils.trace def __init__(self, *args, **kwargs): super(KaminarioISCSIDriver, self).__init__(*args, **kwargs) - self._protocol = 'iSCSI' + self._protocol = constants.ISCSI @volume_utils.trace @coordination.synchronized('{self.k2_lock_name}') diff --git a/cinder/volume/drivers/kioxia/kumoscale.py b/cinder/volume/drivers/kioxia/kumoscale.py index f3999bde382..0a2767707fe 100644 --- a/cinder/volume/drivers/kioxia/kumoscale.py +++ b/cinder/volume/drivers/kioxia/kumoscale.py @@ -19,6 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils.secretutils import md5 +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -414,7 +415,7 @@ class KumoScaleBaseVolumeDriver(driver.BaseVD): volume_backend_name=self._backend_name, vendor_name='KIOXIA', driver_version=self.VERSION, - storage_protocol='NVMeOF', + storage_protocol=constants.NVMEOF_VARIANT_1, ) data['total_capacity_gb'] = 'unknown' data['free_capacity_gb'] = 'unknown' diff --git a/cinder/volume/drivers/lightos.py b/cinder/volume/drivers/lightos.py index be38ef0ec83..8f4dd073572 100644 --- a/cinder/volume/drivers/lightos.py +++ b/cinder/volume/drivers/lightos.py @@ -28,6 +28,7 @@ from oslo_utils import units import requests import urllib3 +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -980,7 +981,6 @@ class LightOSVolumeDriver(driver.VolumeDriver): backend_name = self.configuration.safe_get('volume_backend_name') res_percentage = self.configuration.safe_get('reserved_percentage') - storage_protocol = 'lightos' # as a tenant we dont have access to cluster stats # in the future we might expose this per project via get_project API # currently we remove this stats call. @@ -989,7 +989,7 @@ class LightOSVolumeDriver(driver.VolumeDriver): data = {'vendor_name': 'LightOS Storage', 'volume_backend_name': backend_name or self.__class__.__name__, 'driver_version': self.VERSION, - 'storage_protocol': storage_protocol, + 'storage_protocol': constants.LIGHTOS, 'reserved_percentage': res_percentage, 'QoS_support': False, 'online_extend_support': True, diff --git a/cinder/volume/drivers/linstordrv.py b/cinder/volume/drivers/linstordrv.py index 9fcfe2f6ac2..c621e275456 100644 --- a/cinder/volume/drivers/linstordrv.py +++ b/cinder/volume/drivers/linstordrv.py @@ -27,6 +27,7 @@ from oslo_log import log as logging from oslo_utils import importutils from oslo_utils import units +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -1027,7 +1028,7 @@ class LinstorIscsiDriver(LinstorBaseDriver): def get_volume_stats(self, refresh=False): data = self._get_volume_stats() - data["storage_protocol"] = 'iSCSI' + data["storage_protocol"] = constants.ISCSI data["pools"][0]["location_info"] = ( 'LinstorIscsiDriver:' + data["pools"][0]["location_info"]) @@ -1097,7 +1098,7 @@ class LinstorDrbdDriver(LinstorBaseDriver): def get_volume_stats(self, refresh=False): data = self._get_volume_stats() - data["storage_protocol"] = 'DRBD' + data["storage_protocol"] = constants.DRBD data["pools"][0]["location_info"] = 'LinstorDrbdDriver:{}'.format( data["pools"][0]["location_info"]) diff --git a/cinder/volume/drivers/macrosan/driver.py b/cinder/volume/drivers/macrosan/driver.py index 4146be9d408..ad02bd801ec 100644 --- a/cinder/volume/drivers/macrosan/driver.py +++ b/cinder/volume/drivers/macrosan/driver.py @@ -27,6 +27,7 @@ from oslo_utils import excutils from oslo_utils import strutils from oslo_utils import timeutils +from cinder.common import constants from cinder import context from cinder.coordination import synchronized from cinder import exception @@ -1023,7 +1024,7 @@ class MacroSANISCSIDriver(MacroSANBaseDriver, driver.ISCSIDriver): def __init__(self, *args, **kwargs): """Initialize the driver.""" super(MacroSANISCSIDriver, self).__init__(*args, **kwargs) - self.storage_protocol = 'iSCSI' + self.storage_protocol = constants.ISCSI def _do_setup(self): ports = self.client.get_iscsi_ports() @@ -1224,7 +1225,7 @@ class MacroSANFCDriver(MacroSANBaseDriver, driver.FibreChannelDriver): def __init__(self, *args, **kwargs): """Initialize the driver.""" super(MacroSANFCDriver, self).__init__(*args, **kwargs) - self.storage_protocol = 'FC' + self.storage_protocol = constants.FC self.fcsan_lookup_service = None self.use_sp_port_nr = self.configuration.macrosan_fc_use_sp_port_nr self.keep_mapped_ports = \ diff --git a/cinder/volume/drivers/nec/volume_helper.py b/cinder/volume/drivers/nec/volume_helper.py index 6bca861ef49..7989c843289 100644 --- a/cinder/volume/drivers/nec/volume_helper.py +++ b/cinder/volume/drivers/nec/volume_helper.py @@ -21,6 +21,7 @@ from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import units +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -1467,7 +1468,7 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): """ if refresh: self._stats = self._update_volume_status() - self._stats['storage_protocol'] = 'iSCSI' + self._stats['storage_protocol'] = constants.ISCSI LOG.debug('data=%(data)s, config_group=%(group)s', {'data': self._stats, 'group': self._config_group}) @@ -1481,7 +1482,7 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): if refresh: self._stats = self._update_volume_status() - self._stats['storage_protocol'] = 'FC' + self._stats['storage_protocol'] = constants.FC LOG.debug('data=%(data)s, config_group=%(group)s', {'data': self._stats, 'group': self._config_group}) diff --git a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py index 54aebb2d463..0cccbef649f 100644 --- a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py @@ -30,6 +30,7 @@ from oslo_utils import excutils from oslo_utils import units import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -327,7 +328,7 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver, data['volume_backend_name'] = backend_name or self.driver_name data['vendor_name'] = 'NetApp' data['driver_version'] = self.VERSION - data['storage_protocol'] = 'nfs' + data['storage_protocol'] = constants.NFS_VARIANT data['pools'] = self._get_pool_stats( filter_function=self.get_filter_function(), goodness_function=self.get_goodness_function()) diff --git a/cinder/volume/drivers/nexenta/iscsi.py b/cinder/volume/drivers/nexenta/iscsi.py index f359901a056..70e7ee5a679 100644 --- a/cinder/volume/drivers/nexenta/iscsi.py +++ b/cinder/volume/drivers/nexenta/iscsi.py @@ -16,6 +16,7 @@ from oslo_log import log as logging from oslo_utils import excutils import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -664,7 +665,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): 'compression': self.volume_compression, 'description': self.volume_description, 'driver_version': self.VERSION, - 'storage_protocol': 'iSCSI', + 'storage_protocol': constants.ISCSI, 'total_capacity_gb': total_amount, 'free_capacity_gb': free_amount, 'reserved_percentage': self.configuration.reserved_percentage, diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index ffbf2c7e83b..b079c23a0d0 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -23,6 +23,7 @@ from oslo_utils.secretutils import md5 from oslo_utils import units import six +from cinder.common import constants from cinder import context from cinder import db from cinder import exception @@ -823,7 +824,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 'nms_url': nms_url, 'ns_shares': self.shares_with_capacities, 'driver_version': self.VERSION, - 'storage_protocol': 'NFS', + 'storage_protocol': constants.NFS, 'total_capacity_gb': total_space, 'free_capacity_gb': free_space, 'reserved_percentage': self.configuration.reserved_percentage, diff --git a/cinder/volume/drivers/nexenta/ns5/iscsi.py b/cinder/volume/drivers/nexenta/ns5/iscsi.py index bf8d3f3cb06..7b67aeb9dd1 100644 --- a/cinder/volume/drivers/nexenta/ns5/iscsi.py +++ b/cinder/volume/drivers/nexenta/ns5/iscsi.py @@ -22,6 +22,7 @@ from oslo_log import log as logging from oslo_utils import units import six +from cinder.common import constants from cinder import context from cinder import coordination from cinder.i18n import _ @@ -77,7 +78,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): vendor_name = 'Nexenta' product_name = 'NexentaStor5' - storage_protocol = 'iSCSI' + storage_protocol = constants.ISCSI driver_volume_type = 'iscsi' def __init__(self, *args, **kwargs): diff --git a/cinder/volume/drivers/nexenta/ns5/nfs.py b/cinder/volume/drivers/nexenta/ns5/nfs.py index 61de0d7d681..8573fc42e17 100644 --- a/cinder/volume/drivers/nexenta/ns5/nfs.py +++ b/cinder/volume/drivers/nexenta/ns5/nfs.py @@ -23,6 +23,7 @@ from oslo_utils.secretutils import md5 from oslo_utils import units import six +from cinder.common import constants from cinder import context from cinder import coordination from cinder.i18n import _ @@ -88,7 +89,7 @@ class NexentaNfsDriver(nfs.NfsDriver): vendor_name = 'Nexenta' product_name = 'NexentaStor5' - storage_protocol = 'NFS' + storage_protocol = constants.NFS driver_volume_type = 'nfs' def __init__(self, *args, **kwargs): diff --git a/cinder/volume/drivers/open_e/iscsi.py b/cinder/volume/drivers/open_e/iscsi.py index cfb006fb926..3117b6342d2 100644 --- a/cinder/volume/drivers/open_e/iscsi.py +++ b/cinder/volume/drivers/open_e/iscsi.py @@ -20,6 +20,7 @@ import string from oslo_log import log as logging from oslo_utils import units as o_units +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -743,7 +744,7 @@ class JovianISCSIDriver(driver.ISCSIDriver): self._stats = { 'vendor_name': 'Open-E', 'driver_version': self.VERSION, - 'storage_protocol': 'iSCSI', + 'storage_protocol': constants.ISCSI, 'total_capacity_gb': total_capacity, 'free_capacity_gb': free_capacity, 'reserved_percentage': int(reserved_percentage), diff --git a/cinder/volume/drivers/prophetstor/dpl_fc.py b/cinder/volume/drivers/prophetstor/dpl_fc.py index b2c76094778..145700bacec 100644 --- a/cinder/volume/drivers/prophetstor/dpl_fc.py +++ b/cinder/volume/drivers/prophetstor/dpl_fc.py @@ -17,6 +17,7 @@ import errno from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -389,7 +390,7 @@ class DPLFCDriver(dplcommon.DPLCOMMONDriver, if refresh: data = super(DPLFCDriver, self).get_volume_stats(refresh) if data: - data['storage_protocol'] = 'FC' + data['storage_protocol'] = constants.FC backend_name = \ self.configuration.safe_get('volume_backend_name') data['volume_backend_name'] = (backend_name or 'DPLFCDriver') diff --git a/cinder/volume/drivers/prophetstor/dpl_iscsi.py b/cinder/volume/drivers/prophetstor/dpl_iscsi.py index f922e5dca57..413b62f6e90 100644 --- a/cinder/volume/drivers/prophetstor/dpl_iscsi.py +++ b/cinder/volume/drivers/prophetstor/dpl_iscsi.py @@ -17,6 +17,7 @@ import errno from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -144,7 +145,7 @@ class DPLISCSIDriver(dplcommon.DPLCOMMONDriver, try: data = super(DPLISCSIDriver, self).get_volume_stats(refresh) if data: - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = constants.ISCSI backend_name = \ self.configuration.safe_get('volume_backend_name') data['volume_backend_name'] = \ diff --git a/cinder/volume/drivers/prophetstor/dplcommon.py b/cinder/volume/drivers/prophetstor/dplcommon.py index 9d69ec4bea4..2cde1c5133e 100644 --- a/cinder/volume/drivers/prophetstor/dplcommon.py +++ b/cinder/volume/drivers/prophetstor/dplcommon.py @@ -34,6 +34,7 @@ import requests import six from six.moves import http_client +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import objects @@ -1455,7 +1456,7 @@ class DPLCOMMONDriver(driver.CloneableImageVD, if ret == 0: data['vendor_name'] = output['metadata']['vendor'] data['driver_version'] = output['metadata']['version'] - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = constants.ISCSI data['location_info'] = location_info data['consistencygroup_support'] = True data['consistent_group_snapshot_enabled'] = True diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 01cffb99918..95cfa6c4107 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -35,6 +35,7 @@ try: except ImportError: purestorage = None +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -2526,7 +2527,7 @@ class PureISCSIDriver(PureBaseVolumeDriver, san.SanISCSIDriver): def __init__(self, *args, **kwargs): execute = kwargs.pop("execute", utils.execute) super(PureISCSIDriver, self).__init__(execute=execute, *args, **kwargs) - self._storage_protocol = "iSCSI" + self._storage_protocol = constants.ISCSI def _get_host(self, array, connector, remote=False): """Return dict describing existing Purity host object or None.""" @@ -2748,7 +2749,7 @@ class PureFCDriver(PureBaseVolumeDriver, driver.FibreChannelDriver): def __init__(self, *args, **kwargs): execute = kwargs.pop("execute", utils.execute) super(PureFCDriver, self).__init__(execute=execute, *args, **kwargs) - self._storage_protocol = "FC" + self._storage_protocol = constants.FC self._lookup_service = fczm_utils.create_lookup_service() def _get_host(self, array, connector, remote=False): diff --git a/cinder/volume/drivers/qnap.py b/cinder/volume/drivers/qnap.py index d963d037527..362083b8217 100644 --- a/cinder/volume/drivers/qnap.py +++ b/cinder/volume/drivers/qnap.py @@ -35,6 +35,7 @@ import requests import six from six.moves import urllib +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -51,7 +52,7 @@ qnap_opts = [ cfg.StrOpt('qnap_poolname', help='The pool name in the QNAP Storage'), cfg.StrOpt('qnap_storage_protocol', - default='iscsi', + default=constants.ISCSI, help='Communication protocol to access QNAP storage') ] diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 16a484536f0..9dbd973520e 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -40,6 +40,7 @@ except ImportError: rados = None rbd = None +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -243,7 +244,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, RBD_FEATURE_OBJECT_MAP = 8 RBD_FEATURE_FAST_DIFF = 16 RBD_FEATURE_JOURNALING = 64 - STORAGE_PROTOCOL = 'ceph' + STORAGE_PROTOCOL = constants.CEPH def __init__(self, active_backend_id: str = None, @@ -2065,7 +2066,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, 'migration.') return refuse_to_migrate - if (host['capabilities']['storage_protocol'] != 'ceph'): + if (host['capabilities']['storage_protocol'] != self.STORAGE_PROTOCOL): LOG.debug('Source and destination drivers need to be RBD ' 'to use backend assisted migration. Falling back to ' 'generic migration.') diff --git a/cinder/volume/drivers/rsd.py b/cinder/volume/drivers/rsd.py index e0e1013dd05..fc90168f842 100644 --- a/cinder/volume/drivers/rsd.py +++ b/cinder/volume/drivers/rsd.py @@ -26,6 +26,7 @@ except ImportError: RSDLib = None sushy_exceptions = None +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -594,7 +595,7 @@ class RSDDriver(driver.VolumeDriver): self._stats['volume_backend_name'] = backend_name self._stats['vendor_name'] = 'Intel' self._stats['driver_version'] = self.VERSION - self._stats['storage_protocol'] = 'nvmeof' + self._stats['storage_protocol'] = constants.NVMEOF_VARIANT_2 # SinglePool self._stats['pools'] = [spool] diff --git a/cinder/volume/drivers/sandstone/sds_driver.py b/cinder/volume/drivers/sandstone/sds_driver.py index 32cb9ac6f33..52924dcaf0b 100644 --- a/cinder/volume/drivers/sandstone/sds_driver.py +++ b/cinder/volume/drivers/sandstone/sds_driver.py @@ -18,6 +18,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import units +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -334,7 +335,7 @@ class SdsISCSIDriver(SdsBaseDriver, driver.ISCSIDriver): data = SdsBaseDriver.get_volume_stats(self, refresh) backend_name = self.configuration.safe_get('volume_backend_name') data['volume_backend_name'] = backend_name or self.__class__.__name__ - data['storage_protocol'] = 'iSCSI' + data['storage_protocol'] = constants.ISCSI data['driver_version'] = self.VERSION data['vendor_name'] = 'SandStone USP' return data diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 522cae8546a..5527633c222 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -31,6 +31,7 @@ from oslo_utils import units import requests import six +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -2163,7 +2164,7 @@ class SolidFireDriver(san.SanISCSIDriver): data["volume_backend_name"] = backend_name or self.__class__.__name__ data["vendor_name"] = 'SolidFire Inc' data["driver_version"] = self.VERSION - data["storage_protocol"] = 'iSCSI' + data["storage_protocol"] = constants.ISCSI data['consistencygroup_support'] = True data['consistent_group_snapshot_enabled'] = True data['replication_enabled'] = self.replication_enabled diff --git a/cinder/volume/drivers/spdk.py b/cinder/volume/drivers/spdk.py index 80be966be7a..34c7b1fe676 100644 --- a/cinder/volume/drivers/spdk.py +++ b/cinder/volume/drivers/spdk.py @@ -19,6 +19,7 @@ from oslo_utils import importutils from oslo_utils import units import requests +from cinder.common import constants from cinder import context from cinder import exception from cinder.i18n import _ @@ -91,7 +92,7 @@ class SPDKDriver(driver.VolumeDriver): status = {'volume_backend_name': 'SPDK', 'vendor_name': 'Open Source', 'driver_version': self.VERSION, - 'storage_protocol': 'NVMe-oF'} + 'storage_protocol': constants.NVMEOF} pools_status = [] self.lvs = [] @@ -109,7 +110,7 @@ class SPDKDriver(driver.VolumeDriver): pool["volume_backend_name"] = 'SPDK' pool["vendor_name"] = 'Open Source' pool["driver_version"] = self.VERSION - pool["storage_protocol"] = 'NVMe-oF' + pool["storage_protocol"] = constants.NVMEOF pool["total_capacity_gb"] = total_size pool["free_capacity_gb"] = free_size pool["pool_name"] = lvs['name'] diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py index cf5707cbc7e..47685cb3f51 100644 --- a/cinder/volume/drivers/storpool.py +++ b/cinder/volume/drivers/storpool.py @@ -23,6 +23,7 @@ from oslo_utils import importutils from oslo_utils import units import six +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -305,7 +306,7 @@ class StorPoolDriver(driver.VolumeDriver): 'volume_backend_name') or 'storpool', 'vendor_name': 'StorPool', 'driver_version': self.VERSION, - 'storage_protocol': 'storpool', + 'storage_protocol': constants.STORPOOL, 'sparse_copy_volume': True, diff --git a/cinder/volume/drivers/stx/fc.py b/cinder/volume/drivers/stx/fc.py index e7b60b4e6cc..8a58a4b9384 100644 --- a/cinder/volume/drivers/stx/fc.py +++ b/cinder/volume/drivers/stx/fc.py @@ -15,6 +15,7 @@ # under the License. # +from cinder.common import constants import cinder.volume.driver import cinder.volume.drivers.san.san as san import cinder.volume.drivers.stx.common as common @@ -146,7 +147,7 @@ class STXFCDriver(cinder.volume.driver.FibreChannelDriver): def get_volume_stats(self, refresh=False): stats = self.common.get_volume_stats(refresh) - stats['storage_protocol'] = 'FC' + stats['storage_protocol'] = constants.FC stats['driver_version'] = self.VERSION backend_name = self.configuration.safe_get('volume_backend_name') stats['volume_backend_name'] = (backend_name or diff --git a/cinder/volume/drivers/stx/iscsi.py b/cinder/volume/drivers/stx/iscsi.py index 787aa4d52b9..5c57b520b09 100644 --- a/cinder/volume/drivers/stx/iscsi.py +++ b/cinder/volume/drivers/stx/iscsi.py @@ -17,6 +17,7 @@ from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ import cinder.volume.driver @@ -161,7 +162,7 @@ class STXISCSIDriver(cinder.volume.driver.ISCSIDriver): def get_volume_stats(self, refresh=False): stats = self.common.get_volume_stats(refresh) - stats['storage_protocol'] = 'iSCSI' + stats['storage_protocol'] = constants.ISCSI stats['driver_version'] = self.VERSION backend_name = self.configuration.safe_get('volume_backend_name') stats['volume_backend_name'] = (backend_name or diff --git a/cinder/volume/drivers/toyou/acs5000/acs5000_common.py b/cinder/volume/drivers/toyou/acs5000/acs5000_common.py index 17b34f8ac82..a8ff3807222 100644 --- a/cinder/volume/drivers/toyou/acs5000/acs5000_common.py +++ b/cinder/volume/drivers/toyou/acs5000/acs5000_common.py @@ -30,6 +30,7 @@ from oslo_utils import excutils from oslo_utils import units import paramiko +from cinder.common import constants from cinder import coordination from cinder import exception from cinder.i18n import _ @@ -355,7 +356,7 @@ class Acs5000CommonDriver(san.SanDriver, self._state.update(self._cmd.get_system()) self._state['controller'] = self._cmd.ls_controller() - if self.protocol == 'FC': + if self.protocol == constants.FC: ports = self._cmd.ls_fc() else: ports = self._cmd.ls_iscsi() diff --git a/cinder/volume/drivers/toyou/acs5000/acs5000_fc.py b/cinder/volume/drivers/toyou/acs5000/acs5000_fc.py index e974df345e7..a97474688c5 100644 --- a/cinder/volume/drivers/toyou/acs5000/acs5000_fc.py +++ b/cinder/volume/drivers/toyou/acs5000/acs5000_fc.py @@ -19,6 +19,7 @@ acs5000 FC driver from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -42,7 +43,7 @@ class Acs5000FCDriver(acs5000_common.Acs5000CommonDriver): VENDOR = 'TOYOU' VERSION = '1.0.0' - PROTOCOL = 'FC' + PROTOCOL = constants.FC # ThirdPartySystems wiki page CI_WIKI_NAME = 'TOYOU_ACS5000_CI' diff --git a/cinder/volume/drivers/toyou/acs5000/acs5000_iscsi.py b/cinder/volume/drivers/toyou/acs5000/acs5000_iscsi.py index ce9b4715b70..95221693d76 100644 --- a/cinder/volume/drivers/toyou/acs5000/acs5000_iscsi.py +++ b/cinder/volume/drivers/toyou/acs5000/acs5000_iscsi.py @@ -19,6 +19,7 @@ acs5000 iSCSI driver from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -41,7 +42,7 @@ class Acs5000ISCSIDriver(acs5000_common.Acs5000CommonDriver): VENDOR = 'TOYOU' VERSION = '1.0.0' - PROTOCOL = 'iSCSI' + PROTOCOL = constants.ISCSI # ThirdPartySystems wiki page CI_WIKI_NAME = 'TOYOU_ACS5000_CI' diff --git a/cinder/volume/drivers/veritas_access/veritas_iscsi.py b/cinder/volume/drivers/veritas_access/veritas_iscsi.py index 4b3f69e6ecd..1b88f28ff65 100644 --- a/cinder/volume/drivers/veritas_access/veritas_iscsi.py +++ b/cinder/volume/drivers/veritas_access/veritas_iscsi.py @@ -31,6 +31,7 @@ import requests import requests.auth from six.moves import http_client +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -85,7 +86,6 @@ class ACCESSIscsiDriver(driver.ISCSIDriver): VERSION = "1.0" # ThirdPartySytems wiki page CI_WIKI_NAME = "Veritas_Access_CI" - DRIVER_VOLUME_TYPE = 'iSCSI' LUN_FOUND_INTERVAL = 30 # seconds # TODO(jsbryant) Remove driver in the 'U' release if CI is not fixed. @@ -892,7 +892,7 @@ class ACCESSIscsiDriver(driver.ISCSIDriver): self._stats["vendor_name"] = 'Veritas' self._stats["reserved_percentage"] = res_percentage or 0 self._stats["driver_version"] = self.VERSION - self._stats["storage_protocol"] = self.DRIVER_VOLUME_TYPE + self._stats["storage_protocol"] = constants.ISCSI self._stats['total_capacity_gb'] = total_capacity self._stats['free_capacity_gb'] = free_capacity self._stats['thin_provisioning_support'] = True diff --git a/cinder/volume/drivers/veritas_cnfs.py b/cinder/volume/drivers/veritas_cnfs.py index 25e36c036c6..33c9d30f1de 100644 --- a/cinder/volume/drivers/veritas_cnfs.py +++ b/cinder/volume/drivers/veritas_cnfs.py @@ -18,6 +18,7 @@ import os from oslo_log import log as logging from oslo_utils import excutils +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -52,7 +53,7 @@ class VeritasCNFSDriver(nfs.NfsDriver): VERSION = "1.0.3" # ThirdPartySytems wiki page CI_WIKI_NAME = "Veritas_Access_CI" - DRIVER_VOLUME_TYPE = 'nfs' + DRIVER_VOLUME_TYPE = constants.NFS_VARIANT # TODO(jsbryant) Remove driver in the 'V' release if CI is not fixed. SUPPORTED = False diff --git a/cinder/volume/drivers/vmware/fcd.py b/cinder/volume/drivers/vmware/fcd.py index b77c14b8406..ca8a06f482c 100644 --- a/cinder/volume/drivers/vmware/fcd.py +++ b/cinder/volume/drivers/vmware/fcd.py @@ -27,6 +27,7 @@ from oslo_vmware import image_transfer from oslo_vmware.objects import datastore from oslo_vmware import vim_util +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import interface @@ -55,7 +56,7 @@ class VMwareVStorageObjectDriver(vmdk.VMwareVcVmdkDriver): # minimum supported vCenter version MIN_SUPPORTED_VC_VERSION = '6.5' - STORAGE_TYPE = 'vstorageobject' + STORAGE_TYPE = constants.VSTORAGE def do_setup(self, context): """Any initialization the volume driver needs to do while starting. diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 065601b09eb..2e81cbaa156 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -37,6 +37,7 @@ from oslo_vmware import image_transfer from oslo_vmware import pbm from oslo_vmware import vim_util +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -369,7 +370,7 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): data = {'volume_backend_name': backend_name, 'vendor_name': 'VMware', 'driver_version': self.VERSION, - 'storage_protocol': 'vmdk', + 'storage_protocol': constants.VMDK, 'reserved_percentage': self.configuration.reserved_percentage, 'shared_targets': False} ds_summaries = self._get_datastore_summaries() diff --git a/cinder/volume/drivers/windows/iscsi.py b/cinder/volume/drivers/windows/iscsi.py index 83cc02d412a..61635612782 100644 --- a/cinder/volume/drivers/windows/iscsi.py +++ b/cinder/volume/drivers/windows/iscsi.py @@ -29,6 +29,7 @@ from oslo_utils import fileutils from oslo_utils import units from oslo_utils import uuidutils +from cinder.common import constants from cinder import exception from cinder.image import image_utils from cinder import interface @@ -334,7 +335,7 @@ class WindowsISCSIDriver(driver.ISCSIDriver): data["volume_backend_name"] = backend_name or self.__class__.__name__ data["vendor_name"] = 'Microsoft' data["driver_version"] = self.VERSION - data["storage_protocol"] = 'iSCSI' + data["storage_protocol"] = constants.ISCSI data['total_capacity_gb'] = total_gb data['free_capacity_gb'] = free_gb data['reserved_percentage'] = self.configuration.reserved_percentage diff --git a/cinder/volume/drivers/zadara/zadara.py b/cinder/volume/drivers/zadara/zadara.py index e97468a6fb3..5a7895e6431 100644 --- a/cinder/volume/drivers/zadara/zadara.py +++ b/cinder/volume/drivers/zadara/zadara.py @@ -22,6 +22,7 @@ from oslo_log import log as logging from oslo_utils import strutils import six +from cinder.common import constants from cinder import exception as cinder_exception from cinder.i18n import _ from cinder import interface @@ -709,9 +710,9 @@ class ZadaraVPSAISCSIDriver(driver.ISCSIDriver): """Retrieve stats info from volume group.""" LOG.debug("Updating volume stats") backend_name = self.configuration.safe_get('volume_backend_name') - storage_protocol = ('iSER' if + storage_protocol = (constants.ISER if (self.configuration.safe_get('zadara_use_iser')) - else 'iSCSI') + else constants.ISCSI) pool_name = self.configuration.zadara_vpsa_poolname (total, free, provisioned) = self.vpsa._get_pool_capacity(pool_name) data = dict( diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 49f430c7006..5f05c0ab767 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -844,9 +844,10 @@ class VolumeManager(manager.CleanableManager, # Shared targets is only relevant for iSCSI connections. # We default to True to be on the safe side. + capabilities = self.driver.capabilities volume.shared_targets = ( - self.driver.capabilities.get('storage_protocol') == 'iSCSI' and - self.driver.capabilities.get('shared_targets', True)) + capabilities.get('storage_protocol') in constants.ISCSI_VARIANTS + and capabilities.get('shared_targets', True)) # TODO(geguileo): service_uuid won't be enough on Active/Active # deployments. There can be 2 services handling volumes from the same # backend. @@ -2761,8 +2762,8 @@ class VolumeManager(manager.CleanableManager, # Append cacheable flag for iSCSI/FC/NVMe-oF and only when # cacheable is not set in driver level - if volume_stats.get('storage_protocol') in [ - 'iSCSI', 'FC', 'NVMe-oF']: + if (volume_stats.get('storage_protocol') + in constants.CACHEABLE_PROTOCOLS): if volume_stats.get('pools'): for pool in volume_stats.get('pools'): if pool.get('cacheable') is None: diff --git a/cinder/volume/targets/iscsi.py b/cinder/volume/targets/iscsi.py index 7303e7e7c68..1e89a06c3ef 100644 --- a/cinder/volume/targets/iscsi.py +++ b/cinder/volume/targets/iscsi.py @@ -15,6 +15,7 @@ import abc from oslo_concurrency import processutils from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder import utils @@ -37,7 +38,7 @@ class ISCSITarget(driver.Target): super(ISCSITarget, self).__init__(*args, **kwargs) self.iscsi_target_prefix = self.configuration.safe_get('target_prefix') self.iscsi_protocol = self.configuration.safe_get('target_protocol') - self.protocol = 'iSCSI' + self.protocol = constants.ISCSI self.volumes_dir = self.configuration.safe_get('volumes_dir') def _get_iscsi_properties(self, volume, multipath=False): diff --git a/cinder/volume/targets/nvmeof.py b/cinder/volume/targets/nvmeof.py index f250f60c7eb..0992de1c960 100644 --- a/cinder/volume/targets/nvmeof.py +++ b/cinder/volume/targets/nvmeof.py @@ -14,6 +14,7 @@ import abc from oslo_log import log as logging +from cinder.common import constants from cinder import exception from cinder.i18n import _ from cinder.volume.targets import driver @@ -31,7 +32,7 @@ class NVMeOF(driver.Target): """Target object for block storage devices with RDMA transport.""" - protocol = 'nvmeof' + protocol = constants.NVMEOF_VARIANT_2 target_protocol_map = { 'nvmet_rdma': 'rdma', 'nvmet_tcp': 'tcp', diff --git a/releasenotes/notes/fix-cacheable-capability-f893520d79c3db60.yaml b/releasenotes/notes/fix-cacheable-capability-f893520d79c3db60.yaml new file mode 100644 index 00000000000..7834068678e --- /dev/null +++ b/releasenotes/notes/fix-cacheable-capability-f893520d79c3db60.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + `Bug #1969366 <https://bugs.launchpad.net/cinder/+bug/1969366>`_: Fixed + reporting of cacheable capability by drivers.