Added comment field to na_ontap_volume module (#59566)
* Added comment field to na_ontap_volume module * fixed zapi attribute name in create_volume_options(), and fix to ensure comment field can be set back to an empty string
This commit is contained in:
parent
7f06db8211
commit
f62f1ab54c
2 changed files with 29 additions and 6 deletions
|
@ -291,6 +291,12 @@ options:
|
||||||
choices: ['protected', 'unprotected']
|
choices: ['protected', 'unprotected']
|
||||||
type: str
|
type: str
|
||||||
version_added: '2.9'
|
version_added: '2.9'
|
||||||
|
|
||||||
|
comment:
|
||||||
|
description:
|
||||||
|
- Sets a comment associated with the volume.
|
||||||
|
type: str
|
||||||
|
version_added: '2.9'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -312,6 +318,7 @@ EXAMPLES = """
|
||||||
wait_for_completion: True
|
wait_for_completion: True
|
||||||
space_slo: none
|
space_slo: none
|
||||||
nvfail_enabled: False
|
nvfail_enabled: False
|
||||||
|
comment: ansible created volume
|
||||||
hostname: "{{ netapp_hostname }}"
|
hostname: "{{ netapp_hostname }}"
|
||||||
username: "{{ netapp_username }}"
|
username: "{{ netapp_username }}"
|
||||||
password: "{{ netapp_password }}"
|
password: "{{ netapp_password }}"
|
||||||
|
@ -480,7 +487,9 @@ class NetAppOntapVolume(object):
|
||||||
space_slo=dict(type='str', required=False, choices=['none', 'thick', 'semi-thick']),
|
space_slo=dict(type='str', required=False, choices=['none', 'thick', 'semi-thick']),
|
||||||
tiering_policy=dict(type='str', required=False, choices=['snapshot-only', 'auto',
|
tiering_policy=dict(type='str', required=False, choices=['snapshot-only', 'auto',
|
||||||
'backup', 'none']),
|
'backup', 'none']),
|
||||||
vserver_dr_protection=dict(type='str', required=False, choices=['protected', 'unprotected'])
|
vserver_dr_protection=dict(type='str', required=False, choices=['protected', 'unprotected']),
|
||||||
|
comment=dict(type='str', required=False)
|
||||||
|
|
||||||
))
|
))
|
||||||
self.module = AnsibleModule(
|
self.module = AnsibleModule(
|
||||||
argument_spec=self.argument_spec,
|
argument_spec=self.argument_spec,
|
||||||
|
@ -587,6 +596,10 @@ class NetAppOntapVolume(object):
|
||||||
return_value['junction_path'] = volume_id_attributes['junction-path']
|
return_value['junction_path'] = volume_id_attributes['junction-path']
|
||||||
else:
|
else:
|
||||||
return_value['junction_path'] = ''
|
return_value['junction_path'] = ''
|
||||||
|
if volume_id_attributes.get_child_by_name('comment'):
|
||||||
|
return_value['comment'] = volume_id_attributes['comment']
|
||||||
|
else:
|
||||||
|
return_value['comment'] = None
|
||||||
if volume_id_attributes.get_child_by_name('style-extended'):
|
if volume_id_attributes.get_child_by_name('style-extended'):
|
||||||
return_value['style_extended'] = volume_id_attributes['style-extended']
|
return_value['style_extended'] = volume_id_attributes['style-extended']
|
||||||
else:
|
else:
|
||||||
|
@ -708,6 +721,8 @@ class NetAppOntapVolume(object):
|
||||||
options['export-policy'] = self.parameters['policy']
|
options['export-policy'] = self.parameters['policy']
|
||||||
if self.parameters.get('junction_path'):
|
if self.parameters.get('junction_path'):
|
||||||
options['junction-path'] = self.parameters['junction_path']
|
options['junction-path'] = self.parameters['junction_path']
|
||||||
|
if self.parameters.get('comment'):
|
||||||
|
options['volume-comment'] = self.parameters['comment']
|
||||||
if self.parameters.get('type'):
|
if self.parameters.get('type'):
|
||||||
options['volume-type'] = self.parameters['type']
|
options['volume-type'] = self.parameters['type']
|
||||||
if self.parameters.get('percent_snapshot_space') is not None:
|
if self.parameters.get('percent_snapshot_space') is not None:
|
||||||
|
@ -919,6 +934,10 @@ class NetAppOntapVolume(object):
|
||||||
if self.parameters.get('vserver_dr_protection') is not None:
|
if self.parameters.get('vserver_dr_protection') is not None:
|
||||||
self.create_volume_attribute(vol_mod_attributes, 'volume-vserver-dr-protection-attributes',
|
self.create_volume_attribute(vol_mod_attributes, 'volume-vserver-dr-protection-attributes',
|
||||||
'vserver-dr-protection', self.parameters['vserver_dr_protection'])
|
'vserver-dr-protection', self.parameters['vserver_dr_protection'])
|
||||||
|
# volume-id-attributes
|
||||||
|
if self.parameters.get('comment') is not None:
|
||||||
|
self.create_volume_attribute(vol_mod_attributes, 'volume-id-attributes',
|
||||||
|
'comment', self.parameters['comment'])
|
||||||
# End of Volume-attributes sub attributes
|
# End of Volume-attributes sub attributes
|
||||||
attributes.add_child_elem(vol_mod_attributes)
|
attributes.add_child_elem(vol_mod_attributes)
|
||||||
query = netapp_utils.zapi.NaElement('query')
|
query = netapp_utils.zapi.NaElement('query')
|
||||||
|
@ -1007,7 +1026,7 @@ class NetAppOntapVolume(object):
|
||||||
self.move_volume()
|
self.move_volume()
|
||||||
if attribute in ['space_guarantee', 'policy', 'unix_permissions', 'tiering_policy',
|
if attribute in ['space_guarantee', 'policy', 'unix_permissions', 'tiering_policy',
|
||||||
'snapshot_policy', 'percent_snapshot_space', 'snapdir_access', 'atime_update',
|
'snapshot_policy', 'percent_snapshot_space', 'snapdir_access', 'atime_update',
|
||||||
'nvfail_enabled', 'space_slo', 'qos_policy_group', 'qos_adaptive_policy_group', 'vserver_dr_protection']:
|
'nvfail_enabled', 'space_slo', 'qos_policy_group', 'qos_adaptive_policy_group', 'vserver_dr_protection', 'comment']:
|
||||||
self.volume_modify_attributes(modify)
|
self.volume_modify_attributes(modify)
|
||||||
if attribute == 'junction_path':
|
if attribute == 'junction_path':
|
||||||
if modify.get('junction_path') == '':
|
if modify.get('junction_path') == '':
|
||||||
|
|
|
@ -90,7 +90,8 @@ class MockONTAPConnection(object):
|
||||||
'volume-id-attributes': {
|
'volume-id-attributes': {
|
||||||
'containing-aggregate-name': vol_details['aggregate'],
|
'containing-aggregate-name': vol_details['aggregate'],
|
||||||
'junction-path': vol_details['junction_path'],
|
'junction-path': vol_details['junction_path'],
|
||||||
'style-extended': 'flexvol'
|
'style-extended': 'flexvol',
|
||||||
|
'comment': vol_details['comment']
|
||||||
},
|
},
|
||||||
'volume-language-attributes': {
|
'volume-language-attributes': {
|
||||||
'language-code': 'en'
|
'language-code': 'en'
|
||||||
|
@ -146,7 +147,8 @@ class MockONTAPConnection(object):
|
||||||
'volume-id-attributes': {
|
'volume-id-attributes': {
|
||||||
'aggr-list': vol_details['aggregate'],
|
'aggr-list': vol_details['aggregate'],
|
||||||
'junction-path': vol_details['junction_path'],
|
'junction-path': vol_details['junction_path'],
|
||||||
'style-extended': 'flexgroup'
|
'style-extended': 'flexgroup',
|
||||||
|
'comment': vol_details['comment']
|
||||||
},
|
},
|
||||||
'volume-language-attributes': {
|
'volume-language-attributes': {
|
||||||
'language-code': 'en'
|
'language-code': 'en'
|
||||||
|
@ -259,7 +261,8 @@ class TestMyModule(unittest.TestCase):
|
||||||
'qos_adaptive_policy_group': 'performance',
|
'qos_adaptive_policy_group': 'performance',
|
||||||
'percent_snapshot_space': 60,
|
'percent_snapshot_space': 60,
|
||||||
'language': 'en',
|
'language': 'en',
|
||||||
'vserver_dr_protection': 'unprotected'
|
'vserver_dr_protection': 'unprotected',
|
||||||
|
'comment': 'test comment'
|
||||||
}
|
}
|
||||||
|
|
||||||
def mock_args(self, tag=None):
|
def mock_args(self, tag=None):
|
||||||
|
@ -283,7 +286,8 @@ class TestMyModule(unittest.TestCase):
|
||||||
'percent_snapshot_space': 60,
|
'percent_snapshot_space': 60,
|
||||||
'type': 'type',
|
'type': 'type',
|
||||||
'nvfail_enabled': True,
|
'nvfail_enabled': True,
|
||||||
'space_slo': 'thick'
|
'space_slo': 'thick',
|
||||||
|
'comment': self.mock_vol['comment']
|
||||||
}
|
}
|
||||||
if tag is None:
|
if tag is None:
|
||||||
args['aggregate_name'] = self.mock_vol['aggregate']
|
args['aggregate_name'] = self.mock_vol['aggregate']
|
||||||
|
|
Loading…
Reference in a new issue