From 0f7f413c6b0f5968dee6a41c609d5b60c7f4c588 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 18 Mar 2020 16:33:19 +0100 Subject: [PATCH] SAN: Add missing driver options Drivers can now report the configuration options that are relevant for them with the `get_driver_options` method, but most of them are just reporting their unique options and not the ones they share with other drivers (ie: `san_ip`, `san_login`, `san_password`). This patch adds additional options to SanDriver drivers so they return a more meaningful list of options. To help with this it adds a helper method called `_get_oslo_driver_opts` which can return a list of oslo options from names. This includes very common options such as `max_over_subscription_ratio`, `reserved_percentage`, and `replication_device`, but doesn't include the `volume_backend_name` configuration option, since that's common to ALL Cinder drivers. Change-Id: I0ba2bbf1b707f93081cad8fabcc8dafb7b7d67d2 --- cinder/volume/driver.py | 6 +++++ cinder/volume/drivers/dell_emc/powermax/fc.py | 10 ++++++--- .../volume/drivers/dell_emc/powermax/iscsi.py | 11 +++++++--- cinder/volume/drivers/dell_emc/xtremio.py | 10 ++++++--- cinder/volume/drivers/hpe/hpe_3par_common.py | 12 +++++++--- cinder/volume/drivers/infinidat.py | 12 +++++++--- .../drivers/kaminario/kaminario_common.py | 9 +++++--- cinder/volume/drivers/lvm.py | 22 ++++++++++++++++--- cinder/volume/drivers/pure.py | 10 ++++++--- cinder/volume/drivers/qnap.py | 10 ++++++--- cinder/volume/drivers/solidfire.py | 10 ++++++--- .../volume/drivers/synology/synology_iscsi.py | 11 +++++++--- 12 files changed, 100 insertions(+), 33 deletions(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 8bba82a59f5..2dac17670c4 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -1929,6 +1929,12 @@ class BaseVD(object): raise NotImplementedError() + @staticmethod + def _get_oslo_driver_opts(*cfg_names): + """Return an oslo driver options list from argument string (names).""" + return [CONF.backend_defaults._group._opts[cfg_name]['opt'] + for cfg_name in cfg_names] + @six.add_metaclass(abc.ABCMeta) class CloneableImageVD(object): diff --git a/cinder/volume/drivers/dell_emc/powermax/fc.py b/cinder/volume/drivers/dell_emc/powermax/fc.py index 59555c3c138..6c83d78db2a 100644 --- a/cinder/volume/drivers/dell_emc/powermax/fc.py +++ b/cinder/volume/drivers/dell_emc/powermax/fc.py @@ -137,9 +137,13 @@ class PowerMaxFCDriver(san.SanDriver, driver.FibreChannelDriver): active_backend_id=self.active_backend_id) self.zonemanager_lookup_service = fczm_utils.create_lookup_service() - @staticmethod - def get_driver_options(): - return common.powermax_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'driver_ssl_cert_verify', + 'max_over_subscription_ratio', 'reserved_percentage', + 'replication_device') + return common.powermax_opts + additional_opts def check_for_setup_error(self): pass diff --git a/cinder/volume/drivers/dell_emc/powermax/iscsi.py b/cinder/volume/drivers/dell_emc/powermax/iscsi.py index 4921bb6417b..fccd456b57b 100644 --- a/cinder/volume/drivers/dell_emc/powermax/iscsi.py +++ b/cinder/volume/drivers/dell_emc/powermax/iscsi.py @@ -142,9 +142,14 @@ class PowerMaxISCSIDriver(san.SanISCSIDriver): configuration=self.configuration, active_backend_id=self.active_backend_id)) - @staticmethod - def get_driver_options(): - return common.powermax_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'driver_ssl_cert_verify', + 'max_over_subscription_ratio', 'reserved_percentage', + 'replication_device', 'use_chap_auth', 'chap_username', + 'chap_password') + return common.powermax_opts + additional_opts def check_for_setup_error(self): pass diff --git a/cinder/volume/drivers/dell_emc/xtremio.py b/cinder/volume/drivers/dell_emc/xtremio.py index 52e3b2a1927..88735be1e01 100644 --- a/cinder/volume/drivers/dell_emc/xtremio.py +++ b/cinder/volume/drivers/dell_emc/xtremio.py @@ -446,9 +446,13 @@ class XtremIOVolumeDriver(san.SanDriver): self._stats = {} self.client = XtremIOClient3(self.configuration, self.cluster_id) - @staticmethod - def get_driver_options(): - return XTREMIO_OPTS + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'driver_ssl_cert_verify', + 'driver_ssl_cert_path', 'max_over_subscription_ratio', + 'reserved_percentage') + return XTREMIO_OPTS + additional_opts def _obj_from_result(self, res): typ, idx = res['links'][0]['href'].split('/')[-2:] diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 139599ad42f..547c2e30606 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -58,6 +58,7 @@ from cinder.i18n import _ from cinder.objects import fields from cinder import utils from cinder.volume import configuration +from cinder.volume import driver from cinder.volume import qos_specs from cinder.volume import volume_types from cinder.volume import volume_utils @@ -367,9 +368,14 @@ class HPE3PARCommon(object): def get_version(self): return self.VERSION - @staticmethod - def get_driver_options(): - return hpe3par_opts + @classmethod + def get_driver_options(cls): + additional_opts = driver.BaseVD._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'reserved_percentage', + 'max_over_subscription_ratio', 'replication_device', 'target_port', + 'san_ssh_port', 'ssh_conn_timeout', 'san_private_key', + 'target_ip_address') + return hpe3par_opts + additional_opts def check_flags(self, options, required_flags): for flag in required_flags: diff --git a/cinder/volume/drivers/infinidat.py b/cinder/volume/drivers/infinidat.py index 75068a0447e..e174da1b6b1 100644 --- a/cinder/volume/drivers/infinidat.py +++ b/cinder/volume/drivers/infinidat.py @@ -130,9 +130,15 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): self.configuration.append_config_values(infinidat_opts) self._lookup_service = fczm_utils.create_lookup_service() - @staticmethod - def get_driver_options(): - return infinidat_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'use_chap_auth', + 'chap_username', 'chap_password', 'san_thin_provision', + 'use_multipath_for_image_xfer', 'enforce_multipath_for_image_xfer', + 'num_volume_device_scan_tries', 'volume_dd_blocksize', + 'max_over_subscription_ratio') + return infinidat_opts + additional_opts def _setup_and_get_system_object(self, management_address, auth): system = infinisdk.InfiniBox(management_address, auth=auth) diff --git a/cinder/volume/drivers/kaminario/kaminario_common.py b/cinder/volume/drivers/kaminario/kaminario_common.py index 9e704df1f0d..d3f6a9c8c44 100644 --- a/cinder/volume/drivers/kaminario/kaminario_common.py +++ b/cinder/volume/drivers/kaminario/kaminario_common.py @@ -135,9 +135,12 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver): k2_lock_sfx = self.configuration.safe_get('san_ip') self.k2_lock_name = "%s-%s" % (K2_LOCK_PREFIX, k2_lock_sfx) - @staticmethod - def get_driver_options(): - return kaminario_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'replication_device', + 'volume_dd_blocksize') + return kaminario_opts + additional_opts @utils.trace def check_for_setup_error(self): diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 02dcc4ac721..023720cf707 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -112,9 +112,25 @@ class LVMVolumeDriver(driver.VolumeDriver): self.protocol = self.target_driver.protocol self._sparse_copy_volume = False - @staticmethod - def get_driver_options(): - return volume_opts + @classmethod + def get_driver_options(cls): + # Imports required to have config options + from cinder.volume.targets import spdknvmf # noqa + + additional_opts = cls._get_oslo_driver_opts( + 'target_ip_address', 'target_helper', 'target_protocol', + 'volume_clear', 'volume_clear_size', 'reserved_percentage', + 'max_over_subscription_ratio', 'volume_dd_blocksize', + 'target_prefix', 'volumes_dir', 'iscsi_secondary_ip_addresses', + 'target_port', + 'iscsi_write_cache', 'iscsi_target_flags', # TGT + 'iet_conf', 'iscsi_iotype', # IET + 'nvmet_port_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 + ) + return volume_opts + additional_opts def _sizestr(self, size_in_g): return '%sg' % size_in_g diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index d65c8ba6c2b..ccc55b06f76 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -219,9 +219,13 @@ class PureBaseVolumeDriver(san.SanDriver): 'platform': platform.platform() } - @staticmethod - def get_driver_options(): - return PURE_OPTS + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'driver_ssl_cert_verify', 'driver_ssl_cert_path', + 'use_chap_auth', 'replication_device', 'reserved_percentage', + 'max_over_subscription_ratio') + return PURE_OPTS + additional_opts def parse_replication_configs(self): self._replication_pg_name = ( diff --git a/cinder/volume/drivers/qnap.py b/cinder/volume/drivers/qnap.py index 80ddbe2a971..8cdabdbd9cc 100644 --- a/cinder/volume/drivers/qnap.py +++ b/cinder/volume/drivers/qnap.py @@ -106,9 +106,13 @@ class QnapISCSIDriver(san.SanISCSIDriver): self.target_iqns = [] self.nasInfoCache = {} - @staticmethod - def get_driver_options(): - return qnap_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'target_ip_address', 'san_login', 'san_password', 'use_chap_auth', + 'chap_username', 'chap_password', 'driver_ssl_cert_verify', + 'reserved_percentage') + return qnap_opts + additional_opts def _check_config(self): """Ensure that the flags we care about are set.""" diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 9c37b07bcb4..8ab9fa04a9d 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -321,9 +321,13 @@ class SolidFireDriver(san.SanISCSIDriver): except SolidFireAPIException: pass - @staticmethod - def get_driver_options(): - return sf_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'san_ip', 'san_login', 'san_password', 'driver_ssl_cert_verify', + 'replication_device', 'reserved_percentage', + 'max_over_subscription_ratio') + return sf_opts + additional_opts def _init_vendor_properties(self): properties = {} diff --git a/cinder/volume/drivers/synology/synology_iscsi.py b/cinder/volume/drivers/synology/synology_iscsi.py index 8123f5a64ba..6d9ee86c515 100644 --- a/cinder/volume/drivers/synology/synology_iscsi.py +++ b/cinder/volume/drivers/synology/synology_iscsi.py @@ -44,9 +44,14 @@ class SynoISCSIDriver(driver.ISCSIDriver): self.configuration.append_config_values(common.cinder_opts) self.stats = {} - @staticmethod - def get_driver_options(): - return common.cinder_opts + @classmethod + def get_driver_options(cls): + additional_opts = cls._get_oslo_driver_opts( + 'target_ip_address', 'target_protocol', 'target_port', + 'driver_use_ssl', 'use_chap_auth', 'chap_username', + 'chap_password', 'iscsi_secondary_ip_addresses', 'target_prefix', + 'reserved_percentage', 'max_over_subscription_ratio') + return common.cinder_opts + additional_opts def do_setup(self, context): self.common = common.SynoCommon(self.configuration, 'iscsi')