From 42f6a55c0a81cdc2b35bc48b452143e9a7a8bd20 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Fri, 18 Sep 2015 15:56:58 +0200 Subject: [PATCH] glusterfs*: fix ssh credential options glusterfs and glusterfs_native had a distinct set of options to specify ssh credentials (glusterfs_server_password vs glusterfs_native_server_password and glusterfs_path_to_private_key vs glusterfs_native_path_to_private_key). There is no reason to keep these separate; but worsening the situations these options have been moved to layouts in an ad-hoc manner, breaking certain driver/layout combos whereby the credential option used by the driver is not provided by the chosen layout and thus it was undefined. Fix all the mess by defining glusterfs_server_password and glusterfs_path_to_private_key in glusterfs.common, and providing the native variants as deprecated aliases. Change-Id: I48f8673858d2bff95e66bb7e72911e87030fdc0e Closes-Bug: #1497212 --- manila/opts.py | 2 ++ manila/share/drivers/glusterfs/common.py | 21 +++++++++++++++++++ .../drivers/glusterfs/layout_directory.py | 11 ++-------- .../share/drivers/glusterfs/layout_volume.py | 16 ++++---------- .../drivers/glusterfs/test_layout_volume.py | 8 +++---- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/manila/opts.py b/manila/opts.py index c07a5f3497..3c848b5dc5 100644 --- a/manila/opts.py +++ b/manila/opts.py @@ -54,6 +54,7 @@ import manila.share.drivers.emc.driver import manila.share.drivers.emc.plugins.isilon.isilon import manila.share.drivers.generic import manila.share.drivers.glusterfs +import manila.share.drivers.glusterfs.common import manila.share.drivers.glusterfs.layout import manila.share.drivers.glusterfs.layout_directory import manila.share.drivers.glusterfs.layout_volume @@ -112,6 +113,7 @@ _global_opt_lists = [ manila.share.drivers_private_data.private_data_opts, manila.share.drivers.emc.driver.EMC_NAS_OPTS, manila.share.drivers.generic.share_opts, + manila.share.drivers.glusterfs.common.glusterfs_common_opts, manila.share.drivers.glusterfs.GlusterfsManilaShare_opts, manila.share.drivers.glusterfs.layout.glusterfs_share_layout_opts, manila.share.drivers.glusterfs.layout_directory. diff --git a/manila/share/drivers/glusterfs/common.py b/manila/share/drivers/glusterfs/common.py index 9044006f69..8882822e51 100644 --- a/manila/share/drivers/glusterfs/common.py +++ b/manila/share/drivers/glusterfs/common.py @@ -19,6 +19,7 @@ import re import xml.etree.cElementTree as etree +from oslo_config import cfg from oslo_log import log import six @@ -31,6 +32,26 @@ from manila.share.drivers.ganesha import utils as ganesha_utils LOG = log.getLogger(__name__) +glusterfs_common_opts = [ + cfg.StrOpt('glusterfs_server_password', + default=None, + secret=True, + deprecated_name='glusterfs_native_server_password', + help='Remote GlusterFS server node\'s login password. ' + 'This is not required if ' + '\'glusterfs_path_to_private_key\' is ' + 'configured.'), + cfg.StrOpt('glusterfs_path_to_private_key', + default=None, + deprecated_name='glusterfs_native_path_to_private_key', + help='Path of Manila host\'s private SSH key file.'), +] + + +CONF = cfg.CONF +CONF.register_opts(glusterfs_common_opts) + + class GlusterManager(object): """Interface with a GlusterFS volume.""" diff --git a/manila/share/drivers/glusterfs/layout_directory.py b/manila/share/drivers/glusterfs/layout_directory.py index cbdab3f52b..5936eb63ea 100644 --- a/manila/share/drivers/glusterfs/layout_directory.py +++ b/manila/share/drivers/glusterfs/layout_directory.py @@ -38,15 +38,6 @@ glusterfs_directory_mapped_opts = [ default='$state_path/mnt', help='Base directory containing mount points for Gluster ' 'volumes.'), - cfg.StrOpt('glusterfs_server_password', - default=None, - secret=True, - help="Remote GlusterFS server node's login password. " - "This is not required if 'glusterfs_path_to_private_key'" - ' is configured.'), - cfg.StrOpt('glusterfs_path_to_private_key', - default=None, - help='Path of Manila host\'s private SSH key file.'), ] CONF = cfg.CONF @@ -58,6 +49,8 @@ class GlusterfsDirectoryMappedLayout(layout.GlusterfsShareLayoutBase): def __init__(self, driver, *args, **kwargs): super(GlusterfsDirectoryMappedLayout, self).__init__( driver, *args, **kwargs) + self.configuration.append_config_values( + common.glusterfs_common_opts) self.configuration.append_config_values( glusterfs_directory_mapped_opts) diff --git a/manila/share/drivers/glusterfs/layout_volume.py b/manila/share/drivers/glusterfs/layout_volume.py index 5bd6cf7445..ec494f2ec1 100644 --- a/manila/share/drivers/glusterfs/layout_volume.py +++ b/manila/share/drivers/glusterfs/layout_volume.py @@ -47,16 +47,6 @@ glusterfs_volume_mapped_opts = [ 'shares. Each GlusterFS server should be of the form ' '[remoteuser@], and they are assumed to ' 'belong to distinct Gluster clusters.'), - cfg.StrOpt('glusterfs_native_server_password', - default=None, - secret=True, - help='Remote GlusterFS server node\'s login password. ' - 'This is not required if ' - '\'glusterfs_native_path_to_private_key\' is ' - 'configured.'), - cfg.StrOpt('glusterfs_native_path_to_private_key', - default=None, - help='Path of Manila host\'s private SSH key file.'), cfg.StrOpt('glusterfs_volume_pattern', default=None, help='Regular expression template used to filter ' @@ -97,6 +87,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase): super(GlusterfsVolumeMappedLayout, self).__init__( driver, *args, **kwargs) self.gluster_used_vols = set() + self.configuration.append_config_values( + common.glusterfs_common_opts) self.configuration.append_config_values( glusterfs_volume_mapped_opts) self.gluster_nosnap_vols_dict = {} @@ -186,8 +178,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase): return common.GlusterManager( gluster_address, self.driver._execute, - self.configuration.glusterfs_native_path_to_private_key, - self.configuration.glusterfs_native_server_password, + self.configuration.glusterfs_path_to_private_key, + self.configuration.glusterfs_server_password, requires={'volume': req_volume}) def _share_manager(self, share): diff --git a/manila/tests/share/drivers/glusterfs/test_layout_volume.py b/manila/tests/share/drivers/glusterfs/test_layout_volume.py index db3655fa35..f83b30764f 100644 --- a/manila/tests/share/drivers/glusterfs/test_layout_volume.py +++ b/manila/tests/share/drivers/glusterfs/test_layout_volume.py @@ -96,9 +96,9 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase): CONF.set_default('glusterfs_servers', [self.glusterfs_server1, self.glusterfs_server2]) - CONF.set_default('glusterfs_native_server_password', + CONF.set_default('glusterfs_server_password', 'fake_password') - CONF.set_default('glusterfs_native_path_to_private_key', + CONF.set_default('glusterfs_path_to_private_key', '/fakepath/to/privatekey') CONF.set_default('glusterfs_volume_pattern', 'manila-share-\d+-#{size}G$') @@ -141,8 +141,8 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase): common.GlusterManager.assert_called_once_with( self.glusterfs_target1, self._execute, - self._layout.configuration.glusterfs_native_path_to_private_key, - self._layout.configuration.glusterfs_native_server_password, + self._layout.configuration.glusterfs_path_to_private_key, + self._layout.configuration.glusterfs_server_password, requires=requires) self.assertEqual(fake_obj, ret)