Allow comment for na_ontap_svm (#52300)

* Revert "changes to clusteR"

This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80.

* updates

* doc changes

* Revert "Revert "changes to clusteR""

This reverts commit 8e56b999e6.
This commit is contained in:
Chris Archibald 2019-03-18 09:53:48 -07:00 committed by John R Barker
parent 8d7efa7d32
commit baf255e4c1
2 changed files with 21 additions and 6 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# (c) 2018, NetApp, Inc
# (c) 2018-2019, NetApp, Inc
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@ -163,7 +163,11 @@ options:
choices: ['default', 'dp_destination', 'sync_source', 'sync_destination']
version_added: '2.7'
comment:
description:
- When specified as part of a vserver-create, this field represents the comment associated with the Vserver.
- When part of vserver-get-iter call, this will return the list of matching Vservers.
version_added: '2.8'
'''
EXAMPLES = """
@ -214,7 +218,8 @@ class NetAppOntapSVM(object):
ipspace=dict(type='str', required=False),
snapshot_policy=dict(type='str', required=False),
language=dict(type='str', required=False),
subtype=dict(choices=['default', 'dp_destination', 'sync_source', 'sync_destination'])
subtype=dict(choices=['default', 'dp_destination', 'sync_source', 'sync_destination']),
comment=dict(type="str", required=False)
))
self.module = AnsibleModule(
@ -281,7 +286,8 @@ class NetAppOntapSVM(object):
'language': vserver_info.get_child_content('language'),
'snapshot_policy': vserver_info.get_child_content('snapshot-policy'),
'allowed_protocols': protocols,
'ipspace': vserver_info.get_child_content('ipspace')}
'ipspace': vserver_info.get_child_content('ipspace'),
'comment': vserver_info.get_child_content('comment')}
return vserver_details
def create_vserver(self):
@ -293,6 +299,7 @@ class NetAppOntapSVM(object):
self.add_parameter_to_dict(options, 'ipspace', 'ipspace')
self.add_parameter_to_dict(options, 'snapshot_policy', 'snapshot-policy')
self.add_parameter_to_dict(options, 'subtype', 'vserver-subtype')
self.add_parameter_to_dict(options, 'comment', 'comment')
vserver_create = netapp_utils.zapi.NaElement.create_node_with_children('vserver-create', **options)
try:
self.server.invoke_successfully(vserver_create,
@ -301,6 +308,9 @@ class NetAppOntapSVM(object):
self.module.fail_json(msg='Error provisioning SVM %s: %s'
% (self.parameters['name'], to_native(e)),
exception=traceback.format_exc())
# add allowed-protocols after creation, since vserver-create doesn't allow this attribute during creation
if self.parameters.get('allowed_protocols'):
self.modify_vserver({'allowed_protocols': self.parameters['allowed_protocols']})
def delete_vserver(self):
vserver_delete = netapp_utils.zapi.NaElement.create_node_with_children(
@ -339,6 +349,8 @@ class NetAppOntapSVM(object):
vserver_modify.add_new_child('language', self.parameters['language'])
if attribute == 'snapshot_policy':
vserver_modify.add_new_child('snapshot_policy', self.parameters['snapshot_policy'])
if attribute == 'comment':
vserver_modify.add_new_child('comment', self.parameters['comment'])
if attribute == 'allowed_protocols':
allowed_protocols = netapp_utils.zapi.NaElement('allowed-protocols')
for protocol in self.parameters['allowed_protocols']:

View file

@ -17,7 +17,7 @@ from ansible.modules.storage.netapp.na_ontap_svm \
import NetAppOntapSVM as svm_module # module under test
if not netapp_utils.has_netapp_lib():
pytestmark = pytest.skip('skipping as missing required netapp_lib')
pytestmark = pytest.mark.skip('skipping as missing required netapp_lib')
def set_module_args(args):
@ -77,6 +77,7 @@ class MockONTAPConnection(object):
'root-volume': vserver['root_volume'],
'root-volume-aggregate': vserver['root_volume_aggregate'],
'language': vserver['language'],
'comment': vserver['comment'],
'snapshot-policy': vserver['snapshot_policy'],
'vserver-subtype': vserver['subtype'],
'allowed-protocols': [{'protocol': 'nfs'}, {'protocol': 'cifs'}],
@ -103,7 +104,8 @@ class TestMyModule(unittest.TestCase):
'ipspace': 'ansible_ipspace',
'subtype': 'default',
'language': 'c.utf_8',
'snapshot_policy': 'old_snapshot_policy'
'snapshot_policy': 'old_snapshot_policy',
'comment': 'this is a comment'
}
def mock_args(self):
@ -112,6 +114,7 @@ class TestMyModule(unittest.TestCase):
'root_volume': self.mock_vserver['root_volume'],
'root_volume_aggregate': self.mock_vserver['root_volume_aggregate'],
'ipspace': self.mock_vserver['ipspace'],
'comment': self.mock_vserver['comment'],
'subtype': 'default',
'hostname': 'test',
'username': 'test_user',