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