Bug Fixes for ontap_export_policy_rule.py (#44196)

* Bug Fixes for ontap_export_policy_rule.py
This commit is contained in:
Chris Archibald 2018-08-22 09:03:56 -07:00 committed by John R Barker
parent 86a48af541
commit 5b19d67873

View file

@ -20,7 +20,7 @@ short_description: Manage ONTAP Export rules
extends_documentation_fragment:
- netapp.na_ontap
version_added: '2.6'
author: Suhas Bangalore Shekar (bsuhas@netapp.com), Archana Ganeshan (garchana@netapp.com)
author: NetApp Ansible Team (ng-ansibleteam@netapp.com)
description:
- Create or delete or modify export rules in ONTAP
@ -59,8 +59,8 @@ options:
allow_suid:
description:
- If 'true', NFS server will honor SetUID bits in SETATTR operation. Default value is 'true'
choices: ['True', 'False']
- If 'true', NFS server will honor SetUID bits in SETATTR operation. Default value on creation is 'true'
type: bool
protocol:
description:
@ -155,8 +155,8 @@ class NetAppontapExportRule(object):
super_user_security=dict(required=False,
type='str', default=None,
choices=['any', 'none', 'never', 'krb5', 'krb5i', 'krb5p', 'ntlm', 'sys']),
allow_suid=dict(required=False, choices=['True', 'False']),
rule_index=dict(required=False, type='int', default=None),
allow_suid=dict(required=False, type='bool'),
rule_index=dict(required=False, type='int'),
vserver=dict(required=True, type='str'),
))
@ -178,6 +178,7 @@ class NetAppontapExportRule(object):
self.client_match = parameters['client_match']
self.ro_rule = parameters['ro_rule']
self.rw_rule = parameters['rw_rule']
self.rule_index = parameters['rule_index']
self.allow_suid = parameters['allow_suid']
self.vserver = parameters['vserver']
self.super_user_security = parameters['super_user_security']
@ -230,8 +231,8 @@ class NetAppontapExportRule(object):
'rw-rule').get_child_content('security-flavor')
export_rule_super_user_security = export_policy_rule_details.get_child_by_name(
'super-user-security').get_child_content('security-flavor')
export_rule_allow_suid = export_policy_rule_details.get_child_content(
'is-allow-set-uid-enabled')
export_rule_allow_suid = True if export_policy_rule_details.get_child_content(
'is-allow-set-uid-enabled') == 'true' else False
export_rule_client_match = export_policy_rule_details.get_child_content(
'client-match')
export_vserver = export_policy_rule_details.get_child_content(
@ -296,17 +297,14 @@ class NetAppontapExportRule(object):
"""
create rule for the export policy.
"""
options = {'policy-name': self.policy_name,
'client-match': self.client_match}
if self.allow_suid is not None:
export_rule_create = netapp_utils.zapi.NaElement.create_node_with_children(
'export-rule-create', **{'policy-name': self.policy_name,
'client-match': self.client_match,
'is-allow-set-uid-enabled': str(self.allow_suid)
})
else:
export_rule_create = netapp_utils.zapi.NaElement.create_node_with_children(
'export-rule-create', **{'policy-name': self.policy_name,
'client-match': self.client_match
})
options['is-allow-set-uid-enabled'] = 'true' if self.allow_suid else 'false'
if self.rule_index is not None:
options['rule-index'] = str(self.rule_index)
export_rule_create = netapp_utils.zapi.NaElement.create_node_with_children(
'export-rule-create', **options)
export_rule_create.add_node_with_children(
'ro-rule', **{'security-flavor': self.ro_rule})
export_rule_create.add_node_with_children(
@ -432,7 +430,7 @@ class NetAppontapExportRule(object):
'export-rule-modify',
**{'policy-name': self.policy_name,
'rule-index': rule_index,
'is-allow-set-uid-enabled': str(self.allow_suid)})
'is-allow-set-uid-enabled': 'true' if self.allow_suid else 'false'})
try:
self.server.invoke_successfully(export_rule_modify_allow_suid,
enable_tunneling=True)
@ -466,28 +464,28 @@ class NetAppontapExportRule(object):
if export_policy_rule_exists: # modify
rule_index = export_policy_rule_exists['rule-index']
if rule_index:
if (self.protocol is not None) and \
(export_policy_rule_exists['protocol'] != self.protocol):
if self.protocol is not None and \
export_policy_rule_exists['protocol'] != self.protocol:
export_rule_protocol_changed = True
changed = True
if self.ro_rule is not None and \
(export_policy_rule_exists['ro-rule'] != self.ro_rule):
export_policy_rule_exists['ro-rule'] != self.ro_rule:
export_rule_ro_rule_changed = True
changed = True
if self.rw_rule is not None and \
(export_policy_rule_exists['rw-rule'] != self.rw_rule):
export_policy_rule_exists['rw-rule'] != self.rw_rule:
export_rule_rw_rule_changed = True
changed = True
if (self.allow_suid is not None) and \
(export_policy_rule_exists['is-allow-set-uid-enabled'] != self.allow_suid):
if self.allow_suid is not None and \
export_policy_rule_exists['is-allow-set-uid-enabled'] != self.allow_suid:
export_rule_allow_suid_enabled = True
changed = True
if (self.super_user_security is not None) and \
(export_policy_rule_exists['super-user-security'] != self.super_user_security):
if self.super_user_security is not None and \
export_policy_rule_exists['super-user-security'] != self.super_user_security:
export_rule_superuser_changed = True
changed = True
if self.client_match is not None and \
(export_policy_rule_exists['client-match'] != self.client_match):
export_policy_rule_exists['client-match'] != self.client_match:
export_rule_clientmatch_changed = True
changed = True
else: # create
@ -500,17 +498,17 @@ class NetAppontapExportRule(object):
if not export_policy_rule_exists:
self.create_export_policy_rule()
else:
if export_rule_protocol_changed is True:
if export_rule_protocol_changed:
self.modify_protocol(rule_index)
if export_rule_ro_rule_changed is True:
if export_rule_ro_rule_changed:
self.modify_ro_rule(rule_index)
if export_rule_rw_rule_changed is True:
if export_rule_rw_rule_changed:
self.modify_rw_rule(rule_index)
if export_rule_allow_suid_enabled is True:
if export_rule_allow_suid_enabled:
self.modify_allow_suid(rule_index)
if export_rule_clientmatch_changed is True:
if export_rule_clientmatch_changed:
self.modify_client_match(rule_index)
if export_rule_superuser_changed is True:
if export_rule_superuser_changed:
self.modify_super_user_security(rule_index)
elif self.state == 'absent':
self.delete_export_policy_rule(rule_index)