Browse Source

Merge "Fix ganesha for 0.0.0.0/0 access"

Zuul 4 months ago
parent
commit
61159cb80b

+ 4
- 0
manila/share/drivers/ganesha/__init__.py View File

@@ -129,6 +129,9 @@ class GaneshaNASHelper(NASHelperBase):
129 129
         """Allow access to the share."""
130 130
         if access['access_type'] != 'ip':
131 131
             raise exception.InvalidShareAccess('Only IP access type allowed')
132
+
133
+        access = ganesha_utils.fixup_access_rule(access)
134
+
132 135
         cf = {}
133 136
         accid = access['id']
134 137
         name = share['name']
@@ -240,6 +243,7 @@ class GaneshaNASHelper2(GaneshaNASHelper):
240 243
 
241 244
         wanted_rw_clients, wanted_ro_clients = [], []
242 245
         for rule in access_rules:
246
+            rule = ganesha_utils.fixup_access_rule(rule)
243 247
             if rule['access_level'] == 'rw':
244 248
                 wanted_rw_clients.append(rule['access_to'])
245 249
             elif rule['access_level'] == 'ro':

+ 13
- 0
manila/share/drivers/ganesha/utils.py View File

@@ -134,3 +134,16 @@ def validate_access_rule(supported_access_types, supported_access_levels,
134 134
          'details': "%(access_level)s"})
135 135
 
136 136
     return valid
137
+
138
+
139
+def fixup_access_rule(access_rule):
140
+    """Adjust access rule as required for ganesha to handle it properly.
141
+
142
+    :param access_rule: Access rules to be validated.
143
+    :return: access_rule
144
+    """
145
+    if access_rule['access_to'] == '0.0.0.0/0':
146
+        access_rule['access_to'] = '0.0.0.0'
147
+        LOG.debug("Set access_to field to '0.0.0.0' in ganesha back end.")
148
+
149
+    return access_rule

+ 20
- 0
manila/tests/share/drivers/ganesha/test_utils.py View File

@@ -98,6 +98,26 @@ class GaneshaUtilsTests(test.TestCase):
98 98
         self.assertRaises(trouble, ganesha_utils.validate_access_rule,
99 99
                           ['ip'], ['ro'], fake_access(rule), abort=True)
100 100
 
101
+    @ddt.data({'rule': {'access_type': 'ip',
102
+                        'access_level': 'rw',
103
+                        'access_to': '10.10.10.12'},
104
+               'result': {'access_type': 'ip',
105
+                          'access_level': 'rw',
106
+                          'access_to': '10.10.10.12'},
107
+               },
108
+              {'rule': {'access_type': 'ip',
109
+                        'access_level': 'rw',
110
+                        'access_to': '0.0.0.0/0'},
111
+               'result': {'access_type': 'ip',
112
+                          'access_level': 'rw',
113
+                          'access_to': '0.0.0.0'},
114
+               },
115
+              )
116
+    @ddt.unpack
117
+    def test_fixup_access_rules(self, rule, result):
118
+
119
+        self.assertEqual(result, ganesha_utils.fixup_access_rule(rule))
120
+
101 121
 
102 122
 @ddt.ddt
103 123
 class SSHExecutorTestCase(test.TestCase):

+ 6
- 0
releasenotes/notes/fix-ganesha-allow-access-for-all-ips-09773a79dc76ad44.yaml View File

@@ -0,0 +1,6 @@
1
+---
2
+fixes:
3
+  - |
4
+    Drivers using ganesha can now handle 'manila access-allow
5
+    <share-id> ip 0.0.0.0/0' as a way to allow access to the share
6
+    from all IPs.

Loading…
Cancel
Save