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

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 8e56b999e6cf6a65de339e516f7134a6b6b39cba.
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 #!/usr/bin/python
# (c) 2018, NetApp, Inc # (c) 2018-2019, NetApp, Inc
# GNU General Public License v3.0+ # GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # (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'] choices: ['default', 'dp_destination', 'sync_source', 'sync_destination']
version_added: '2.7' 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 = """ EXAMPLES = """
@ -214,7 +218,8 @@ class NetAppOntapSVM(object):
ipspace=dict(type='str', required=False), ipspace=dict(type='str', required=False),
snapshot_policy=dict(type='str', required=False), snapshot_policy=dict(type='str', required=False),
language=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( self.module = AnsibleModule(
@ -281,7 +286,8 @@ class NetAppOntapSVM(object):
'language': vserver_info.get_child_content('language'), 'language': vserver_info.get_child_content('language'),
'snapshot_policy': vserver_info.get_child_content('snapshot-policy'), 'snapshot_policy': vserver_info.get_child_content('snapshot-policy'),
'allowed_protocols': protocols, '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 return vserver_details
def create_vserver(self): 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, 'ipspace', 'ipspace')
self.add_parameter_to_dict(options, 'snapshot_policy', 'snapshot-policy') 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, 'subtype', 'vserver-subtype')
self.add_parameter_to_dict(options, 'comment', 'comment')
vserver_create = netapp_utils.zapi.NaElement.create_node_with_children('vserver-create', **options) vserver_create = netapp_utils.zapi.NaElement.create_node_with_children('vserver-create', **options)
try: try:
self.server.invoke_successfully(vserver_create, self.server.invoke_successfully(vserver_create,
@ -301,6 +308,9 @@ class NetAppOntapSVM(object):
self.module.fail_json(msg='Error provisioning SVM %s: %s' self.module.fail_json(msg='Error provisioning SVM %s: %s'
% (self.parameters['name'], to_native(e)), % (self.parameters['name'], to_native(e)),
exception=traceback.format_exc()) 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): def delete_vserver(self):
vserver_delete = netapp_utils.zapi.NaElement.create_node_with_children( 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']) vserver_modify.add_new_child('language', self.parameters['language'])
if attribute == 'snapshot_policy': if attribute == 'snapshot_policy':
vserver_modify.add_new_child('snapshot_policy', self.parameters['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': if attribute == 'allowed_protocols':
allowed_protocols = netapp_utils.zapi.NaElement('allowed-protocols') allowed_protocols = netapp_utils.zapi.NaElement('allowed-protocols')
for protocol in self.parameters['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 import NetAppOntapSVM as svm_module # module under test
if not netapp_utils.has_netapp_lib(): 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): def set_module_args(args):
@ -77,6 +77,7 @@ class MockONTAPConnection(object):
'root-volume': vserver['root_volume'], 'root-volume': vserver['root_volume'],
'root-volume-aggregate': vserver['root_volume_aggregate'], 'root-volume-aggregate': vserver['root_volume_aggregate'],
'language': vserver['language'], 'language': vserver['language'],
'comment': vserver['comment'],
'snapshot-policy': vserver['snapshot_policy'], 'snapshot-policy': vserver['snapshot_policy'],
'vserver-subtype': vserver['subtype'], 'vserver-subtype': vserver['subtype'],
'allowed-protocols': [{'protocol': 'nfs'}, {'protocol': 'cifs'}], 'allowed-protocols': [{'protocol': 'nfs'}, {'protocol': 'cifs'}],
@ -103,7 +104,8 @@ class TestMyModule(unittest.TestCase):
'ipspace': 'ansible_ipspace', 'ipspace': 'ansible_ipspace',
'subtype': 'default', 'subtype': 'default',
'language': 'c.utf_8', 'language': 'c.utf_8',
'snapshot_policy': 'old_snapshot_policy' 'snapshot_policy': 'old_snapshot_policy',
'comment': 'this is a comment'
} }
def mock_args(self): def mock_args(self):
@ -112,6 +114,7 @@ class TestMyModule(unittest.TestCase):
'root_volume': self.mock_vserver['root_volume'], 'root_volume': self.mock_vserver['root_volume'],
'root_volume_aggregate': self.mock_vserver['root_volume_aggregate'], 'root_volume_aggregate': self.mock_vserver['root_volume_aggregate'],
'ipspace': self.mock_vserver['ipspace'], 'ipspace': self.mock_vserver['ipspace'],
'comment': self.mock_vserver['comment'],
'subtype': 'default', 'subtype': 'default',
'hostname': 'test', 'hostname': 'test',
'username': 'test_user', 'username': 'test_user',