41
41
description:
42
42
- Enable/Disable the rquota protocol.
43
43
type: bool
44
+ nfs_rdma_enabled:
45
+ description:
46
+ - Enables or disables RDMA for NFS.
47
+ - Supported on PowerScale 9.8 and later.
48
+ type: bool
44
49
nfsv3:
45
50
description:
46
51
- Enable/disable NFSv3 protocol.
53
58
nfsv3_rdma_enabled:
54
59
description:
55
60
- To enable/disable RDMA for NFSv3 protocol.
61
+ - For PowerScale 9.8 I(nfsv3_rdma_enabled) is not supported
62
+ and I(nfs_rdma_enabled) is used for both nfsv3 and nfsv4.
56
63
type: bool
57
64
nfsv4:
58
65
description:
102
109
nfsv40_enabled: true
103
110
nfsv41_enabled: true
104
111
nfsv42_enabled: false
112
+ nfs_rdma_enabled: true
105
113
rpc_minthreads: 17
106
114
rpc_maxthreads: 20
107
115
rquota_enabled: true
@@ -176,11 +184,13 @@ class NFSGlobalSettings:
176
184
def __init__ (self ):
177
185
""" Define all parameters required by this module"""
178
186
self .module_params = utils .get_powerscale_management_host_parameters ()
179
- self .module_params .update (self .get_nfs_global_settings_parameters ())
187
+ self .module_params .update (self .get_nfs_global_settings_parameters ())
188
+ mutually_exclusive = [['nfsv3.nfsv3_rdma_enabled' , 'nfs_rdma_enabled' ]]
180
189
# Initialize the ansible module
181
190
self .module = AnsibleModule (
182
191
argument_spec = self .module_params ,
183
- supports_check_mode = True
192
+ supports_check_mode = True ,
193
+ mutually_exclusive = mutually_exclusive
184
194
)
185
195
# Result is a dictionary that contains changed status, NFS global
186
196
# settings details
@@ -197,12 +207,33 @@ def __init__(self):
197
207
198
208
self .api_client = utils .get_powerscale_connection (self .module .params )
199
209
self .isi_sdk = utils .get_powerscale_sdk ()
210
+ cluster_api = utils .isi_sdk .ClusterApi (self .api_client )
211
+ major = str (cluster_api .get_cluster_config ().to_dict ()['onefs_version' ]['release' ].split ('.' )[0 ])
212
+ minor = str (cluster_api .get_cluster_config ().to_dict ()['onefs_version' ]['release' ].split ('.' )[1 ])
213
+ self .array_version = major + "." + minor
214
+
200
215
LOG .info ('Got python SDK instance for provisioning on PowerScale ' )
201
216
check_mode_msg = f'Check mode flag is { self .module .check_mode } '
202
217
LOG .info (check_mode_msg )
203
218
204
219
self .protocol_api = self .isi_sdk .ProtocolsApi (self .api_client )
205
220
221
+ def validate_input (self ):
222
+ """
223
+ Validate the input parameters based on the array version.
224
+ This method checks whether certain parameters are allowed based on the array version.
225
+ If the array version is 9.8 or later, the nfsv3.nfsv3_rdma_enabled parameter is not allowed.
226
+ If the array version is earlier than 9.8, the nfs_rdma_enabled parameter is not allowed.
227
+ """
228
+ params = self .module .params
229
+
230
+ if utils .parse_version (self .array_version ) < utils .parse_version ("9.8" ):
231
+ if params .get ("nfs_rdma_enabled" ) is not None :
232
+ self .module .fail_json (msg = "nfs_rdma_enabled is not allowed when array version is earlier than 9.8." )
233
+ else :
234
+ if params .get ("nfsv3" ) and params .get ("nfsv3" ).get ("nfsv3_rdma_enabled" ) is not None :
235
+ self .module .fail_json (msg = "nfsv3.nfsv3_rdma_enabled is not allowed when array version is 9.8 or later." )
236
+
206
237
def get_nfs_global_settings_details (self ):
207
238
"""
208
239
Get details of NFS global settings
@@ -249,14 +280,14 @@ def is_nfsv3v4_modify_required(self, settings_params, settings_details, modify_d
249
280
nfsv4_keys = ["nfsv4_enabled" , "nfsv40_enabled" , "nfsv41_enabled" , "nfsv42_enabled" ]
250
281
if settings_params ["nfsv4" ] is not None :
251
282
for key in nfsv4_keys :
252
- if settings_params ["nfsv4" ][key ] is not None and \
283
+ if key in settings_params [ "nfsv4" ] and settings_params ["nfsv4" ][key ] is not None and \
253
284
settings_details [key ] != settings_params ["nfsv4" ][key ]:
254
285
modify_dict [key ] = settings_params ["nfsv4" ][key ]
255
286
256
287
nfsv3_keys = ["nfsv3_enabled" , "nfsv3_rdma_enabled" ]
257
288
if settings_params ["nfsv3" ] is not None :
258
289
for key in nfsv3_keys :
259
- if settings_params ["nfsv3" ][key ] is not None and \
290
+ if key in settings_params [ "nfsv3" ] and settings_params ["nfsv3" ][key ] is not None and \
260
291
settings_details [key ] != settings_params ["nfsv3" ][key ]:
261
292
modify_dict [key ] = settings_params ["nfsv3" ][key ]
262
293
@@ -267,9 +298,9 @@ def is_nfs_global_modify_required(self, settings_params, settings_details):
267
298
Check whether modification is required in NFS global settings
268
299
"""
269
300
modify_dict = {}
270
- keys = ["service" , "rpc_maxthreads" , "rpc_minthreads" , "rquota_enabled" ]
301
+ keys = ["service" , "rpc_maxthreads" , "rpc_minthreads" , "rquota_enabled" , "nfs_rdma_enabled" ]
271
302
for key in keys :
272
- if settings_params [key ] is not None and \
303
+ if key in settings_params and settings_params [key ] is not None and \
273
304
settings_details [key ] != settings_params [key ]:
274
305
modify_dict [key ] = settings_params [key ]
275
306
@@ -284,6 +315,7 @@ def get_nfs_global_settings_parameters(self):
284
315
service = dict (type = 'bool' ), rpc_maxthreads = dict (type = 'int' ),
285
316
rpc_minthreads = dict (type = 'int' ),
286
317
rquota_enabled = dict (type = 'bool' ),
318
+ nfs_rdma_enabled = dict (type = 'bool' ),
287
319
nfsv3 = dict (
288
320
type = 'dict' , options = dict (
289
321
nfsv3_enabled = dict (type = 'bool' ),
@@ -319,6 +351,7 @@ def handle(self, nfs_global_obj, nfs_global_params, nfs_global_details):
319
351
320
352
class NFSGlobalSettingsHandler :
321
353
def handle (self , nfs_global_obj , nfs_global_params ):
354
+ nfs_global_obj .validate_input ()
322
355
nfs_global_details = nfs_global_obj .get_nfs_global_settings_details ()
323
356
NFSGlobalSettingsModifyHandler ().handle (
324
357
nfs_global_obj = nfs_global_obj , nfs_global_params = nfs_global_params ,
0 commit comments