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
# (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)
# import untangle
@ -18,38 +18,53 @@ description:
extends_documentation_fragment:
- netapp.na_ontap
module: na_ontap_cifs
options:
path:
description:
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
slash as directory separator
required: false
vserver:
description:
- "Vserver containing the CIFS share."
required: true
share_name:
description:
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)
required: true
share_properties:
description:
- The list of properties for the CIFS share
required: false
version_added: '2.8'
symlink_properties:
description:
- The list of symlink properties for this CIFS share
required: false
version_added: '2.8'
state:
choices: ['present', 'absent']
description:
- "Whether the specified CIFS share should exist or not."
required: false
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
version_added: "2.6"
@ -83,6 +98,7 @@ EXAMPLES = """
path: /
share_properties: show_previous_versions
symlink_properties: disable
vscan_fileop_profile: no_scan
hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}"
password: "{{ netapp_password }}"
@ -116,7 +132,8 @@ class NetAppONTAPCifsShare(object):
path=dict(required=False, type='str'),
vserver=dict(required=True, type='str'),
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(
@ -145,6 +162,7 @@ class NetAppONTAPCifsShare(object):
cifs_iter = netapp_utils.zapi.NaElement('cifs-share-get-iter')
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('vserver', self.parameters.get('vserver'))
query = netapp_utils.zapi.NaElement('query')
query.add_child_elem(cifs_info)
@ -175,6 +193,8 @@ class NetAppONTAPCifsShare(object):
'share_properties': properties_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
@ -196,6 +216,10 @@ class NetAppONTAPCifsShare(object):
cifs_create.add_child_elem(symlink_attrs)
for symlink in self.parameters.get('symlink_properties'):
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:
self.server.invoke_successfully(cifs_create,
@ -240,6 +264,10 @@ class NetAppONTAPCifsShare(object):
cifs_modify.add_child_elem(symlink_attrs)
for property in self.parameters.get('symlink_properties'):
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:
self.server.invoke_successfully(cifs_modify,
enable_tunneling=True)

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

Loading…
Cancel
Save