1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Bug Fixes for ontap_nfs.py (#44210)

* Bug Fixes for ontap_nfs.py

* Fix issues
This commit is contained in:
Chris Archibald 2018-08-16 05:36:19 -07:00 committed by ansibot
parent 11a3d56faf
commit aa44158f80

View file

@ -14,11 +14,11 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = """
module: na_ontap_nfs
short_description: Manage Ontap NFS status
short_description: Manage ONTAP NFS status
extends_documentation_fragment:
- netapp.na_ontap
version_added: '2.6'
author: Suhas Bangalore Shekar (bsuhas@netapp.com)
author: NetApp Ansible Team (ng-ansibleteam@netapp.com)
description:
- Enable or disable nfs on ONTAP
options:
@ -39,6 +39,11 @@ options:
description:
- status of nfsv3.
choices: ['enabled', 'disabled']
nfsv3_fsid_change:
description:
- status of if NFSv3 clients see change in FSID as they traverse filesystems.
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv4:
description:
- status of nfsv4.
@ -55,14 +60,50 @@ options:
nfsv4_id_domain:
description:
- Name of the nfsv4_id_domain to use.
nfsv40_acl:
description:
- status of NFS v4.0 ACL feature
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv40_read_delegation:
description:
- status for NFS v4.0 read delegation feature.
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv40_write_delegation:
description:
- status for NFS v4.0 write delegation feature.
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv41_acl:
description:
- status of NFS v4.1 ACL feature
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv41_read_delegation:
description:
- status for NFS v4.1 read delegation feature.
choices: ['enabled', 'disabled']
version_added: '2.7'
nfsv41_write_delegation:
description:
- status for NFS v4.1 write delegation feature.
choices: ['enabled', 'disabled']
version_added: '2.7'
tcp:
description:
- Enable TCP.
- Enable TCP (support from ONTAP 9.3 onward).
choices: ['enabled', 'disabled']
udp:
description:
- Enable UDP.
- Enable UDP (support from ONTAP 9.3 onward).
choices: ['enabled', 'disabled']
showmount:
description:
- status for if SVM allows showmount
choices: ['enabled', 'disabled']
version_added: '2.7'
"""
EXAMPLES = """
@ -105,12 +146,20 @@ class NetAppONTAPNFS(object):
service_state=dict(required=False, choices=['started', 'stopped']),
vserver=dict(required=True, type='str'),
nfsv3=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv3_fsid_change=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv4=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv41=dict(required=False, default=None, choices=['enabled', 'disabled'], aliases=['nfsv4.1']),
vstorage_state=dict(required=False, default=None, choices=['enabled', 'disabled']),
tcp=dict(required=False, default=None, choices=['enabled', 'disabled']),
udp=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv4_id_domain=dict(required=False, type='str', default=None),
nfsv40_acl=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv40_read_delegation=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv40_write_delegation=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv41_acl=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv41_read_delegation=dict(required=False, default=None, choices=['enabled', 'disabled']),
nfsv41_write_delegation=dict(required=False, default=None, choices=['enabled', 'disabled']),
showmount=dict(required=False, default=None, choices=['enabled', 'disabled'])
))
self.module = AnsibleModule(
@ -125,12 +174,20 @@ class NetAppONTAPNFS(object):
self.service_state = parameters['service_state']
self.vserver = parameters['vserver']
self.nfsv3 = parameters['nfsv3']
self.nfsv3_fsid_change = parameters['nfsv3_fsid_change']
self.nfsv4 = parameters['nfsv4']
self.nfsv41 = parameters['nfsv41']
self.vstorage_state = parameters['vstorage_state']
self.nfsv4_id_domain = parameters['nfsv4_id_domain']
self.udp = parameters['udp']
self.tcp = parameters['tcp']
self.nfsv40_acl = parameters['nfsv40_acl']
self.nfsv40_read_delegation = parameters['nfsv40_read_delegation']
self.nfsv40_write_delegation = parameters['nfsv40_write_delegation']
self.nfsv41_acl = parameters['nfsv41_acl']
self.nfsv41_read_delegation = parameters['nfsv41_read_delegation']
self.nfsv41_write_delegation = parameters['nfsv41_write_delegation']
self.showmount = parameters['showmount']
if HAS_NETAPP_LIB is False:
self.module.fail_json(msg="the python NetApp-Lib module is required")
@ -158,20 +215,36 @@ class NetAppONTAPNFS(object):
int(result.get_child_content('num-records')) >= 1:
attributes_list = result.get_child_by_name('attributes-list').get_child_by_name('nfs-info')
is_nfsv3_enabled = attributes_list.get_child_content('is-nfsv3-enabled')
is_nfsv3_fsid_change_enabled = attributes_list.get_child_content('is-nfsv3-fsid-change-enabled')
is_nfsv40_enabled = attributes_list.get_child_content('is-nfsv40-enabled')
is_nfsv41_enabled = attributes_list.get_child_content('is-nfsv41-enabled')
is_vstorage_enabled = attributes_list.get_child_content('is-vstorage-enabled')
nfsv4_id_domain_value = attributes_list.get_child_content('nfsv4-id-domain')
is_tcp_enabled = attributes_list.get_child_content('is-tcp-enabled')
is_udp_enabled = attributes_list.get_child_content('is-udp-enabled')
is_nfsv40_acl_enabled = attributes_list.get_child_content('is-nfsv40-acl-enabled')
is_nfsv40_write_delegation_enabled = attributes_list.get_child_content('is-nfsv40-write-delegation-enabled')
is_nfsv40_read_delegation_enabled = attributes_list.get_child_content('is-nfsv40-read-delegation-enabled')
is_nfsv41_acl_enabled = attributes_list.get_child_content('is-nfsv41-acl-enabled')
is_nfsv41_write_delegation_enabled = attributes_list.get_child_content('is-nfsv41-write-delegation-enabled')
is_nfsv41_read_delegation_enabled = attributes_list.get_child_content('is-nfsv41-read-delegation-enabled')
is_showmount_enabled = attributes_list.get_child_content('showmount')
nfs_details = {
'is_nfsv3_enabled': is_nfsv3_enabled,
'is_nfsv3_fsid_change_enabled': is_nfsv3_fsid_change_enabled,
'is_nfsv40_enabled': is_nfsv40_enabled,
'is_nfsv41_enabled': is_nfsv41_enabled,
'is_vstorage_enabled': is_vstorage_enabled,
'nfsv4_id_domain': nfsv4_id_domain_value,
'is_tcp_enabled': is_tcp_enabled,
'is_udp_enabled': is_udp_enabled
'is_udp_enabled': is_udp_enabled,
'is_nfsv40_acl_enabled': is_nfsv40_acl_enabled,
'is_nfsv40_write_delegation_enabled': is_nfsv40_write_delegation_enabled,
'is_nfsv40_read_delegation_enabled': is_nfsv40_read_delegation_enabled,
'is_nfsv41_acl_enabled': is_nfsv41_acl_enabled,
'is_nfsv41_write_delegation_enabled': is_nfsv41_write_delegation_enabled,
'is_nfsv41_read_delegation_enabled': is_nfsv41_read_delegation_enabled,
'is_showmount_enabled': is_showmount_enabled
}
return nfs_details
@ -225,6 +298,10 @@ class NetAppONTAPNFS(object):
nfs_modify.add_new_child('is-nfsv3-enabled', 'true')
elif self.nfsv3 == 'disabled':
nfs_modify.add_new_child('is-nfsv3-enabled', 'false')
if self.nfsv3_fsid_change == 'enabled':
nfs_modify.add_new_child('is-nfsv3-fsid-change-enabled', 'true')
elif self.nfsv3_fsid_change == 'disabled':
nfs_modify.add_new_child('is-nfsv3-fsid-change-enabled', 'false')
if self.nfsv4 == 'enabled':
nfs_modify.add_new_child('is-nfsv40-enabled', 'true')
elif self.nfsv4 == 'disabled':
@ -245,6 +322,34 @@ class NetAppONTAPNFS(object):
nfs_modify.add_new_child('is-udp-enabled', 'true')
elif self.udp == 'disabled':
nfs_modify.add_new_child('is-udp-enabled', 'false')
if self.nfsv40_acl == 'enabled':
nfs_modify.add_new_child('is-nfsv40-acl-enabled', 'true')
elif self.nfsv40_acl == 'disabled':
nfs_modify.add_new_child('is-nfsv40-acl-enabled', 'false')
if self.nfsv40_read_delegation == 'enabled':
nfs_modify.add_new_child('is-nfsv40-read-delegation-enabled', 'true')
elif self.nfsv40_read_delegation == 'disabled':
nfs_modify.add_new_child('is-nfsv40-read-delegation-enabled', 'false')
if self.nfsv40_write_delegation == 'enabled':
nfs_modify.add_new_child('is-nfsv40-write-delegation-enabled', 'true')
elif self.nfsv40_write_delegation == 'disabled':
nfs_modify.add_new_child('is-nfsv40-write-delegation-enabled', 'false')
if self.nfsv41_acl == 'enabled':
nfs_modify.add_new_child('is-nfsv41-acl-enabled', 'true')
elif self.nfsv41_acl == 'disabled':
nfs_modify.add_new_child('is-nfsv41-acl-enabled', 'false')
if self.nfsv41_read_delegation == 'enabled':
nfs_modify.add_new_child('is-nfsv41-read-delegation-enabled', 'true')
elif self.nfsv41_read_delegation == 'disabled':
nfs_modify.add_new_child('is-nfsv41-read-delegation-enabled', 'false')
if self.nfsv41_write_delegation == 'enabled':
nfs_modify.add_new_child('is-nfsv41-write-delegation-enabled', 'true')
elif self.nfsv41_write_delegation == 'disabled':
nfs_modify.add_new_child('is-nfsv41-write-delegation-enabled', 'false')
if self.showmount == 'enabled':
nfs_modify.add_new_child('showmount', 'true')
elif self.showmount == 'disabled':
nfs_modify.add_new_child('showmount', 'false')
try:
self.server.invoke_successfully(nfs_modify,
enable_tunneling=True)
@ -302,10 +407,17 @@ class NetAppONTAPNFS(object):
def is_modify_needed():
if (((self.nfsv3 is not None) and state_changed(self.nfsv3, nfs_service_details['is_nfsv3_enabled'])) or
((self.nfsv3_fsid_change is not None) and state_changed(self.nfsv3_fsid_change, nfs_service_details['is_nfsv3_fsid_change_enabled'])) or
((self.nfsv4 is not None) and state_changed(self.nfsv4, nfs_service_details['is_nfsv40_enabled'])) or
((self.nfsv41 is not None) and state_changed(self.nfsv41, nfs_service_details['is_nfsv41_enabled'])) or
((self.tcp is not None) and state_changed(self.tcp, nfs_service_details['is_tcp_enabled'])) or
((self.udp is not None) and state_changed(self.udp, nfs_service_details['is_udp_enabled'])) or
((self.nfsv40_acl is not None) and state_changed(self.nfsv40_acl, nfs_service_details['is_nfsv40_acl_enabled'])) or
((self.nfsv40_write_delegation is not None) and state_changed(self.nfsv40_write_delegation,
nfs_service_details['is_nfsv40_write_delegation_enabled'])) or
((self.nfsv40_write_delegation is not None) and state_changed(self.nfsv40_write_delegation,
nfs_service_details['is_nfsv40_write_delegation_enabled'])) or
((self.showmount is not None) and state_changed(self.showmount, nfs_service_details['is_showmount_enabled'])) or
((self.vstorage_state is not None) and state_changed(self.vstorage_state, nfs_service_details['is_vstorage_enabled']))):
return True
return False