Skip to content

Commit

Permalink
ADS diff mode enhancements (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavneet-Sharma authored Nov 20, 2024
1 parent f380887 commit d6a589a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions plugins/modules/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
import PowerScaleBase
from ansible_collections.dellemc.powerscale.plugins.module_utils.storage.dell \
import utils
import copy

LOG = utils.get_logger('nfs')

Expand Down Expand Up @@ -822,9 +823,12 @@ def modify_nfs_export(self, path, access_zone, ignore_unresolvable_hosts):
'''
Modify NFS export in system
'''
nfs_details = copy.deepcopy(self.result.get('NFS_export_details'))

nfs_export = self.isi_sdk.NfsExport()
client_flag = map_root_flag = map_non_root_flag = False
client_flag, nfs_export = self._check_client_status(nfs_export)

map_root = set_nfs_map(self.module.params.get('map_root'), 'map_root', self.result.get('NFS_export_details'))
if map_root:
nfs_export.map_root = map_root
Expand All @@ -848,22 +852,28 @@ def modify_nfs_export(self, path, access_zone, ignore_unresolvable_hosts):
map_non_root_flag, security_flag]):
LOG.info(
'No change detected for the NFS Export, returning changed = False')
if self.module._diff:
self.result.update({"diff": {"before": nfs_details, "after": nfs_details}})
return False
else:
nfs_export.read_only = read_only_value if read_only_flag else None
nfs_export.all_dirs = all_dirs_value if all_dirs_flag else None
nfs_export.description = description_value if description_flag else None
LOG.debug('Modifying NFS Export with %s details', nfs_export)
return self.perform_modify_nfs_export(nfs_export, path, access_zone, ignore_unresolvable_hosts)

def perform_modify_nfs_export(self, nfs_export, path, access_zone, ignore_unresolvable_hosts):
return self.perform_modify_nfs_export(nfs_export, path, access_zone, ignore_unresolvable_hosts, nfs_details)

def perform_modify_nfs_export(self, nfs_export, path, access_zone, ignore_unresolvable_hosts, nfs_details):
'''
Modify NFS export in PowerScale system
'''
modified_details = copy.deepcopy(nfs_details)
filtered_dict = {key: value for key, value in nfs_export.to_dict().items() if value is not None}
modified_details.update(filtered_dict)

if self.module._diff:
self.result.update({"diff": {"before": self.result.get("NFS_export_details"), "after": nfs_export.to_dict()}})
self.result.update({"diff": {"before": nfs_details, "after": modified_details}})

self.result['NFS_export_details'] = nfs_details
try:
if not self.module.check_mode:
if ignore_unresolvable_hosts is not True:
Expand Down

0 comments on commit d6a589a

Please sign in to comment.