From 994063bbf9131475540e9d14c95e921dc4967e76 Mon Sep 17 00:00:00 2001 From: Chris Archibald Date: Thu, 14 Feb 2019 18:12:50 -0800 Subject: [PATCH] Add junction path to ontap_volume_clone (#51391) * changes to clusteR * Revert "changes to clusteR" This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80. * add new option * Fix issues --- .../storage/netapp/na_ontap_volume_clone.py | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py b/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py index 486501c794..61988ff5cf 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py @@ -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) from __future__ import absolute_import, division, print_function __metaclass__ = type @@ -55,20 +55,25 @@ options: description: - The volume-type setting which should be used for the volume clone. choices: ['rw', 'dp'] + junction_path: + version_added: '2.8' + description: + - Junction path of the volume. ''' EXAMPLES = """ - name: create volume clone na_ontap_volume_clone: - state=present - username=admin - password=netapp1! - hostname=10.193.74.27 - vserver=vs_hack - parent_volume=normal_volume - volume=clone_volume_7 - space_reserve=none - parent_snapshot=backup1 + state: present + username: "{{ netapp username }}" + password: "{{ netapp password }}" + hostname: "{{ netapp hostname }}" + vserver: vs_hack + parent_volume: normal_volume + volume: clone_volume_7 + space_reserve: none + parent_snapshot: backup1 + junction_path: /clone_volume_7 """ RETURN = """ @@ -100,6 +105,7 @@ class NetAppOntapVolumeClone(object): qos_policy_group_name=dict(required=False, type='str', default=None), space_reserve=dict(required=False, choices=['volume', 'none'], default=None), volume_type=dict(required=False, choices=['rw', 'dp']), + junction_path=dict(required=False, type='str', default=None) )) self.module = AnsibleModule( @@ -119,6 +125,7 @@ class NetAppOntapVolumeClone(object): self.volume = parameters['volume'] self.volume_type = parameters['volume_type'] self.vserver = parameters['vserver'] + self.junction_path = parameters['junction_path'] if HAS_NETAPP_LIB is False: self.module.fail_json(msg="the python NetApp-Lib module is required") @@ -143,6 +150,8 @@ class NetAppOntapVolumeClone(object): clone_obj.add_new_child("parent-vserver", self.parent_vserver) if self.volume_type: clone_obj.add_new_child("volume-type", self.volume_type) + if self.junction_path: + clone_obj.add_new_child("junction-path", self.junction_path) self.server.invoke_successfully(clone_obj, True) def does_volume_clone_exists(self): @@ -150,7 +159,7 @@ class NetAppOntapVolumeClone(object): clone_obj.add_new_child("volume", self.volume) try: results = self.server.invoke_successfully(clone_obj, True) - except Exception: + except netapp_utils.zapi.NaApiError: return False attributes = results.get_child_by_name('attributes') info = attributes.get_child_by_name('volume-clone-info')