Browse Source

Merge "glusterfs*: fix ssh credential options"

Jenkins 3 years ago
parent
commit
929ab21ae7

+ 2
- 0
manila/opts.py View File

@@ -54,6 +54,7 @@ import manila.share.drivers.emc.driver
54 54
 import manila.share.drivers.emc.plugins.isilon.isilon
55 55
 import manila.share.drivers.generic
56 56
 import manila.share.drivers.glusterfs
57
+import manila.share.drivers.glusterfs.common
57 58
 import manila.share.drivers.glusterfs.layout
58 59
 import manila.share.drivers.glusterfs.layout_directory
59 60
 import manila.share.drivers.glusterfs.layout_volume
@@ -112,6 +113,7 @@ _global_opt_lists = [
112 113
     manila.share.drivers_private_data.private_data_opts,
113 114
     manila.share.drivers.emc.driver.EMC_NAS_OPTS,
114 115
     manila.share.drivers.generic.share_opts,
116
+    manila.share.drivers.glusterfs.common.glusterfs_common_opts,
115 117
     manila.share.drivers.glusterfs.GlusterfsManilaShare_opts,
116 118
     manila.share.drivers.glusterfs.layout.glusterfs_share_layout_opts,
117 119
     manila.share.drivers.glusterfs.layout_directory.

+ 21
- 0
manila/share/drivers/glusterfs/common.py View File

@@ -19,6 +19,7 @@
19 19
 import re
20 20
 import xml.etree.cElementTree as etree
21 21
 
22
+from oslo_config import cfg
22 23
 from oslo_log import log
23 24
 import six
24 25
 
@@ -31,6 +32,26 @@ from manila.share.drivers.ganesha import utils as ganesha_utils
31 32
 LOG = log.getLogger(__name__)
32 33
 
33 34
 
35
+glusterfs_common_opts = [
36
+    cfg.StrOpt('glusterfs_server_password',
37
+               default=None,
38
+               secret=True,
39
+               deprecated_name='glusterfs_native_server_password',
40
+               help='Remote GlusterFS server node\'s login password. '
41
+                    'This is not required if '
42
+                    '\'glusterfs_path_to_private_key\' is '
43
+                    'configured.'),
44
+    cfg.StrOpt('glusterfs_path_to_private_key',
45
+               default=None,
46
+               deprecated_name='glusterfs_native_path_to_private_key',
47
+               help='Path of Manila host\'s private SSH key file.'),
48
+]
49
+
50
+
51
+CONF = cfg.CONF
52
+CONF.register_opts(glusterfs_common_opts)
53
+
54
+
34 55
 class GlusterManager(object):
35 56
     """Interface with a GlusterFS volume."""
36 57
 

+ 2
- 9
manila/share/drivers/glusterfs/layout_directory.py View File

@@ -38,15 +38,6 @@ glusterfs_directory_mapped_opts = [
38 38
                default='$state_path/mnt',
39 39
                help='Base directory containing mount points for Gluster '
40 40
                     'volumes.'),
41
-    cfg.StrOpt('glusterfs_server_password',
42
-               default=None,
43
-               secret=True,
44
-               help="Remote GlusterFS server node's login password. "
45
-                    "This is not required if 'glusterfs_path_to_private_key'"
46
-                    ' is configured.'),
47
-    cfg.StrOpt('glusterfs_path_to_private_key',
48
-               default=None,
49
-               help='Path of Manila host\'s private SSH key file.'),
50 41
 ]
51 42
 
52 43
 CONF = cfg.CONF
@@ -58,6 +49,8 @@ class GlusterfsDirectoryMappedLayout(layout.GlusterfsShareLayoutBase):
58 49
     def __init__(self, driver, *args, **kwargs):
59 50
         super(GlusterfsDirectoryMappedLayout, self).__init__(
60 51
             driver, *args, **kwargs)
52
+        self.configuration.append_config_values(
53
+            common.glusterfs_common_opts)
61 54
         self.configuration.append_config_values(
62 55
             glusterfs_directory_mapped_opts)
63 56
 

+ 4
- 12
manila/share/drivers/glusterfs/layout_volume.py View File

@@ -47,16 +47,6 @@ glusterfs_volume_mapped_opts = [
47 47
                      'shares. Each GlusterFS server should be of the form '
48 48
                      '[remoteuser@]<volserver>, and they are assumed to '
49 49
                      'belong to distinct Gluster clusters.'),
50
-    cfg.StrOpt('glusterfs_native_server_password',
51
-               default=None,
52
-               secret=True,
53
-               help='Remote GlusterFS server node\'s login password. '
54
-                    'This is not required if '
55
-                    '\'glusterfs_native_path_to_private_key\' is '
56
-                    'configured.'),
57
-    cfg.StrOpt('glusterfs_native_path_to_private_key',
58
-               default=None,
59
-               help='Path of Manila host\'s private SSH key file.'),
60 50
     cfg.StrOpt('glusterfs_volume_pattern',
61 51
                default=None,
62 52
                help='Regular expression template used to filter '
@@ -97,6 +87,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
97 87
         super(GlusterfsVolumeMappedLayout, self).__init__(
98 88
             driver, *args, **kwargs)
99 89
         self.gluster_used_vols = set()
90
+        self.configuration.append_config_values(
91
+            common.glusterfs_common_opts)
100 92
         self.configuration.append_config_values(
101 93
             glusterfs_volume_mapped_opts)
102 94
         self.gluster_nosnap_vols_dict = {}
@@ -186,8 +178,8 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
186 178
 
187 179
         return common.GlusterManager(
188 180
             gluster_address, self.driver._execute,
189
-            self.configuration.glusterfs_native_path_to_private_key,
190
-            self.configuration.glusterfs_native_server_password,
181
+            self.configuration.glusterfs_path_to_private_key,
182
+            self.configuration.glusterfs_server_password,
191 183
             requires={'volume': req_volume})
192 184
 
193 185
     def _share_manager(self, share):

+ 4
- 4
manila/tests/share/drivers/glusterfs/test_layout_volume.py View File

@@ -96,9 +96,9 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
96 96
 
97 97
         CONF.set_default('glusterfs_servers',
98 98
                          [self.glusterfs_server1, self.glusterfs_server2])
99
-        CONF.set_default('glusterfs_native_server_password',
99
+        CONF.set_default('glusterfs_server_password',
100 100
                          'fake_password')
101
-        CONF.set_default('glusterfs_native_path_to_private_key',
101
+        CONF.set_default('glusterfs_path_to_private_key',
102 102
                          '/fakepath/to/privatekey')
103 103
         CONF.set_default('glusterfs_volume_pattern',
104 104
                          'manila-share-\d+-#{size}G$')
@@ -141,8 +141,8 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
141 141
 
142 142
         common.GlusterManager.assert_called_once_with(
143 143
             self.glusterfs_target1, self._execute,
144
-            self._layout.configuration.glusterfs_native_path_to_private_key,
145
-            self._layout.configuration.glusterfs_native_server_password,
144
+            self._layout.configuration.glusterfs_path_to_private_key,
145
+            self._layout.configuration.glusterfs_server_password,
146 146
             requires=requires)
147 147
         self.assertEqual(fake_obj, ret)
148 148
 

Loading…
Cancel
Save