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
This commit is contained in:
parent
a8e5154cf3
commit
42f6a55c0a
@ -54,6 +54,7 @@ import manila.share.drivers.emc.driver
|
|||||||
import manila.share.drivers.emc.plugins.isilon.isilon
|
import manila.share.drivers.emc.plugins.isilon.isilon
|
||||||
import manila.share.drivers.generic
|
import manila.share.drivers.generic
|
||||||
import manila.share.drivers.glusterfs
|
import manila.share.drivers.glusterfs
|
||||||
|
import manila.share.drivers.glusterfs.common
|
||||||
import manila.share.drivers.glusterfs.layout
|
import manila.share.drivers.glusterfs.layout
|
||||||
import manila.share.drivers.glusterfs.layout_directory
|
import manila.share.drivers.glusterfs.layout_directory
|
||||||
import manila.share.drivers.glusterfs.layout_volume
|
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_private_data.private_data_opts,
|
||||||
manila.share.drivers.emc.driver.EMC_NAS_OPTS,
|
manila.share.drivers.emc.driver.EMC_NAS_OPTS,
|
||||||
manila.share.drivers.generic.share_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.GlusterfsManilaShare_opts,
|
||||||
manila.share.drivers.glusterfs.layout.glusterfs_share_layout_opts,
|
manila.share.drivers.glusterfs.layout.glusterfs_share_layout_opts,
|
||||||
manila.share.drivers.glusterfs.layout_directory.
|
manila.share.drivers.glusterfs.layout_directory.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import re
|
import re
|
||||||
import xml.etree.cElementTree as etree
|
import xml.etree.cElementTree as etree
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -31,6 +32,26 @@ from manila.share.drivers.ganesha import utils as ganesha_utils
|
|||||||
LOG = log.getLogger(__name__)
|
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):
|
class GlusterManager(object):
|
||||||
"""Interface with a GlusterFS volume."""
|
"""Interface with a GlusterFS volume."""
|
||||||
|
|
||||||
|
@ -38,15 +38,6 @@ glusterfs_directory_mapped_opts = [
|
|||||||
default='$state_path/mnt',
|
default='$state_path/mnt',
|
||||||
help='Base directory containing mount points for Gluster '
|
help='Base directory containing mount points for Gluster '
|
||||||
'volumes.'),
|
'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
|
CONF = cfg.CONF
|
||||||
@ -58,6 +49,8 @@ class GlusterfsDirectoryMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
def __init__(self, driver, *args, **kwargs):
|
def __init__(self, driver, *args, **kwargs):
|
||||||
super(GlusterfsDirectoryMappedLayout, self).__init__(
|
super(GlusterfsDirectoryMappedLayout, self).__init__(
|
||||||
driver, *args, **kwargs)
|
driver, *args, **kwargs)
|
||||||
|
self.configuration.append_config_values(
|
||||||
|
common.glusterfs_common_opts)
|
||||||
self.configuration.append_config_values(
|
self.configuration.append_config_values(
|
||||||
glusterfs_directory_mapped_opts)
|
glusterfs_directory_mapped_opts)
|
||||||
|
|
||||||
|
@ -47,16 +47,6 @@ glusterfs_volume_mapped_opts = [
|
|||||||
'shares. Each GlusterFS server should be of the form '
|
'shares. Each GlusterFS server should be of the form '
|
||||||
'[remoteuser@]<volserver>, and they are assumed to '
|
'[remoteuser@]<volserver>, and they are assumed to '
|
||||||
'belong to distinct Gluster clusters.'),
|
'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',
|
cfg.StrOpt('glusterfs_volume_pattern',
|
||||||
default=None,
|
default=None,
|
||||||
help='Regular expression template used to filter '
|
help='Regular expression template used to filter '
|
||||||
@ -97,6 +87,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
super(GlusterfsVolumeMappedLayout, self).__init__(
|
super(GlusterfsVolumeMappedLayout, self).__init__(
|
||||||
driver, *args, **kwargs)
|
driver, *args, **kwargs)
|
||||||
self.gluster_used_vols = set()
|
self.gluster_used_vols = set()
|
||||||
|
self.configuration.append_config_values(
|
||||||
|
common.glusterfs_common_opts)
|
||||||
self.configuration.append_config_values(
|
self.configuration.append_config_values(
|
||||||
glusterfs_volume_mapped_opts)
|
glusterfs_volume_mapped_opts)
|
||||||
self.gluster_nosnap_vols_dict = {}
|
self.gluster_nosnap_vols_dict = {}
|
||||||
@ -186,8 +178,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
|
|
||||||
return common.GlusterManager(
|
return common.GlusterManager(
|
||||||
gluster_address, self.driver._execute,
|
gluster_address, self.driver._execute,
|
||||||
self.configuration.glusterfs_native_path_to_private_key,
|
self.configuration.glusterfs_path_to_private_key,
|
||||||
self.configuration.glusterfs_native_server_password,
|
self.configuration.glusterfs_server_password,
|
||||||
requires={'volume': req_volume})
|
requires={'volume': req_volume})
|
||||||
|
|
||||||
def _share_manager(self, share):
|
def _share_manager(self, share):
|
||||||
|
@ -96,9 +96,9 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
|||||||
|
|
||||||
CONF.set_default('glusterfs_servers',
|
CONF.set_default('glusterfs_servers',
|
||||||
[self.glusterfs_server1, self.glusterfs_server2])
|
[self.glusterfs_server1, self.glusterfs_server2])
|
||||||
CONF.set_default('glusterfs_native_server_password',
|
CONF.set_default('glusterfs_server_password',
|
||||||
'fake_password')
|
'fake_password')
|
||||||
CONF.set_default('glusterfs_native_path_to_private_key',
|
CONF.set_default('glusterfs_path_to_private_key',
|
||||||
'/fakepath/to/privatekey')
|
'/fakepath/to/privatekey')
|
||||||
CONF.set_default('glusterfs_volume_pattern',
|
CONF.set_default('glusterfs_volume_pattern',
|
||||||
'manila-share-\d+-#{size}G$')
|
'manila-share-\d+-#{size}G$')
|
||||||
@ -141,8 +141,8 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
|||||||
|
|
||||||
common.GlusterManager.assert_called_once_with(
|
common.GlusterManager.assert_called_once_with(
|
||||||
self.glusterfs_target1, self._execute,
|
self.glusterfs_target1, self._execute,
|
||||||
self._layout.configuration.glusterfs_native_path_to_private_key,
|
self._layout.configuration.glusterfs_path_to_private_key,
|
||||||
self._layout.configuration.glusterfs_native_server_password,
|
self._layout.configuration.glusterfs_server_password,
|
||||||
requires=requires)
|
requires=requires)
|
||||||
self.assertEqual(fake_obj, ret)
|
self.assertEqual(fake_obj, ret)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user