Set vscan_fileop_profile for na_ontap_cifs (#57373)

* new features

* update unit tests
pull/58987/head
Chris Archibald 5 years ago committed by Jake Jackson
parent 36da7e462a
commit 6e3d54ae81

@ -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+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# import untangle # import untangle
@ -18,38 +18,53 @@ description:
extends_documentation_fragment: extends_documentation_fragment:
- netapp.na_ontap - netapp.na_ontap
module: na_ontap_cifs module: na_ontap_cifs
options: options:
path: path:
description: description:
The file system path that is shared through this CIFS share. The path is the full, user visible path relative The file system path that is shared through this CIFS share. The path is the full, user visible path relative
to the vserver root, and it might be crossing junction mount points. The path is in UTF8 and uses forward to the vserver root, and it might be crossing junction mount points. The path is in UTF8 and uses forward
slash as directory separator slash as directory separator
required: false required: false
vserver: vserver:
description: description:
- "Vserver containing the CIFS share." - "Vserver containing the CIFS share."
required: true required: true
share_name: share_name:
description: description:
The name of the CIFS share. The CIFS share name is a UTF-8 string with the following characters being The name of the CIFS share. The CIFS share name is a UTF-8 string with the following characters being
illegal; control characters from 0x00 to 0x1F, both inclusive, 0x22 (double quotes) illegal; control characters from 0x00 to 0x1F, both inclusive, 0x22 (double quotes)
required: true required: true
share_properties: share_properties:
description: description:
- The list of properties for the CIFS share - The list of properties for the CIFS share
required: false required: false
version_added: '2.8' version_added: '2.8'
symlink_properties: symlink_properties:
description: description:
- The list of symlink properties for this CIFS share - The list of symlink properties for this CIFS share
required: false required: false
version_added: '2.8' version_added: '2.8'
state: state:
choices: ['present', 'absent'] choices: ['present', 'absent']
description: description:
- "Whether the specified CIFS share should exist or not." - "Whether the specified CIFS share should exist or not."
required: false required: false
default: present default: present
vscan_fileop_profile:
choices: ['no_scan', 'standard', 'strict', 'writes_only']
description:
- Profile_set of file_ops to which vscan on access scanning is applicable.
required: false
version_added: '2.9'
short_description: NetApp ONTAP Manage cifs-share short_description: NetApp ONTAP Manage cifs-share
version_added: "2.6" version_added: "2.6"
@ -83,6 +98,7 @@ EXAMPLES = """
path: / path: /
share_properties: show_previous_versions share_properties: show_previous_versions
symlink_properties: disable symlink_properties: disable
vscan_fileop_profile: no_scan
hostname: "{{ netapp_hostname }}" hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}" username: "{{ netapp_username }}"
password: "{{ netapp_password }}" password: "{{ netapp_password }}"
@ -116,7 +132,8 @@ class NetAppONTAPCifsShare(object):
path=dict(required=False, type='str'), path=dict(required=False, type='str'),
vserver=dict(required=True, type='str'), vserver=dict(required=True, type='str'),
share_properties=dict(required=False, type='list'), share_properties=dict(required=False, type='list'),
symlink_properties=dict(required=False, type='list') symlink_properties=dict(required=False, type='list'),
vscan_fileop_profile=dict(required=False, type='str', choices=['no_scan', 'standard', 'strict', 'writes_only'])
)) ))
self.module = AnsibleModule( self.module = AnsibleModule(
@ -145,6 +162,7 @@ class NetAppONTAPCifsShare(object):
cifs_iter = netapp_utils.zapi.NaElement('cifs-share-get-iter') cifs_iter = netapp_utils.zapi.NaElement('cifs-share-get-iter')
cifs_info = netapp_utils.zapi.NaElement('cifs-share') cifs_info = netapp_utils.zapi.NaElement('cifs-share')
cifs_info.add_new_child('share-name', self.parameters.get('share_name')) cifs_info.add_new_child('share-name', self.parameters.get('share_name'))
cifs_info.add_new_child('vserver', self.parameters.get('vserver'))
query = netapp_utils.zapi.NaElement('query') query = netapp_utils.zapi.NaElement('query')
query.add_child_elem(cifs_info) query.add_child_elem(cifs_info)
@ -175,6 +193,8 @@ class NetAppONTAPCifsShare(object):
'share_properties': properties_list, 'share_properties': properties_list,
'symlink_properties': symlink_list 'symlink_properties': symlink_list
} }
if cifs_attrs.get_child_by_name('vscan-fileop-profile'):
return_value['vscan_fileop_profile'] = cifs_attrs['vscan-fileop-profile']
return return_value return return_value
@ -196,6 +216,10 @@ class NetAppONTAPCifsShare(object):
cifs_create.add_child_elem(symlink_attrs) cifs_create.add_child_elem(symlink_attrs)
for symlink in self.parameters.get('symlink_properties'): for symlink in self.parameters.get('symlink_properties'):
symlink_attrs.add_new_child('cifs-share-symlink-properties', symlink) symlink_attrs.add_new_child('cifs-share-symlink-properties', symlink)
if self.parameters.get('vscan_fileop_profile'):
fileop_attrs = netapp_utils.zapi.NaElement('vscan-fileop-profile')
fileop_attrs.set_content(self.parameters['vscan_fileop_profile'])
cifs_create.add_child_elem(fileop_attrs)
try: try:
self.server.invoke_successfully(cifs_create, self.server.invoke_successfully(cifs_create,
@ -240,6 +264,10 @@ class NetAppONTAPCifsShare(object):
cifs_modify.add_child_elem(symlink_attrs) cifs_modify.add_child_elem(symlink_attrs)
for property in self.parameters.get('symlink_properties'): for property in self.parameters.get('symlink_properties'):
symlink_attrs.add_new_child('cifs-share-symlink-properties', property) symlink_attrs.add_new_child('cifs-share-symlink-properties', property)
if self.parameters.get('vscan_fileop_profile'):
fileop_attrs = netapp_utils.zapi.NaElement('vscan-fileop-profile')
fileop_attrs.set_content(self.parameters['vscan_fileop_profile'])
cifs_modify.add_child_elem(fileop_attrs)
try: try:
self.server.invoke_successfully(cifs_modify, self.server.invoke_successfully(cifs_modify,
enable_tunneling=True) enable_tunneling=True)

@ -75,8 +75,11 @@ class MockONTAPConnection(object):
data = {'num-records': 1, 'attributes-list': {'cifs-share': { data = {'num-records': 1, 'attributes-list': {'cifs-share': {
'share-name': 'test', 'share-name': 'test',
'path': '/test', 'path': '/test',
'share-properties': {'cifs-share-properties': 'browsable'}, 'vscan-fileop-profile': 'standard',
'symlink-properties': {'cifs-share-symlink-properties': 'enable'}, 'share-properties': [{'cifs-share-properties': 'browsable'},
{'cifs-share-properties': 'oplocks'}],
'symlink-properties': [{'cifs-share-symlink-properties': 'enable'},
{'cifs-share-symlink-properties': 'read_only'}],
}}} }}}
xml.translate_struct(data) xml.translate_struct(data)
print(xml.to_string()) print(xml.to_string())
@ -104,6 +107,7 @@ class TestMyModule(unittest.TestCase):
path = '/test' path = '/test'
share_properties = 'browsable,oplocks' share_properties = 'browsable,oplocks'
symlink_properties = 'disable' symlink_properties = 'disable'
vscan_fileop_profile = 'standard'
vserver = 'abc' vserver = 'abc'
else: else:
hostname = '10.193.77.37' hostname = '10.193.77.37'
@ -113,6 +117,7 @@ class TestMyModule(unittest.TestCase):
path = '/test' path = '/test'
share_properties = 'show_previous_versions' share_properties = 'show_previous_versions'
symlink_properties = 'disable' symlink_properties = 'disable'
vscan_fileop_profile = 'no_scan'
vserver = 'abc' vserver = 'abc'
return dict({ return dict({
'hostname': hostname, 'hostname': hostname,
@ -122,6 +127,7 @@ class TestMyModule(unittest.TestCase):
'path': path, 'path': path,
'share_properties': share_properties, 'share_properties': share_properties,
'symlink_properties': symlink_properties, 'symlink_properties': symlink_properties,
'vscan_fileop_profile': vscan_fileop_profile,
'vserver': vserver 'vserver': vserver
}) })

Loading…
Cancel
Save