Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADS diff mode enhancements #136

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading