From d0a71472242c41efa1661beb55756f89f08bb899 Mon Sep 17 00:00:00 2001 From: Chris Archibald Date: Fri, 17 Aug 2018 06:11:28 -0700 Subject: [PATCH] Bug fixes for ontap_volume_clone.py (#44225) --- .../storage/netapp/na_ontap_volume_clone.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 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 8bcdc636e4..df6ee2b671 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_volume_clone.py @@ -12,13 +12,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' module: na_ontap_volume_clone -short_description: Manage NetApp Ontap volume clones. +short_description: Manage NetApp ONTAP volume clones. extends_documentation_fragment: - netapp.na_ontap version_added: '2.6' -author: Chris Archibald (carchi@netapp.com), Kevin Hutton (khutton@netapp.com) +author: NetApp Ansible Team (ng-ansibleteam@netapp.com) description: -- Create NetApp Ontap volume clones. +- Create NetApp ONTAP volume clones. +- A FlexClone License is required to use this module options: state: description: @@ -147,18 +148,16 @@ class NetAppOntapVolumeClone(object): def does_volume_clone_exists(self): clone_obj = netapp_utils.zapi.NaElement('volume-clone-get') clone_obj.add_new_child("volume", self.volume) - attributes_obj = netapp_utils.zapi.NaElement('desired-attributes') - info_obj = netapp_utils.zapi.NaElement('volume-clone-info') - clone_obj.add_child_elem(attributes_obj) - attributes_obj.add_child_elem(info_obj) - attributes_obj.add_new_child("volume", self.volume) - attributes_obj.add_new_child("vserver", self.vserver) - attributes_obj.add_new_child("parent-volume", self.parent_volume) try: - self.server.invoke_successfully(clone_obj, True) + results = self.server.invoke_successfully(clone_obj, True) except: return False - return True + attributes = results.get_child_by_name('attributes') + info = attributes.get_child_by_name('volume-clone-info') + parent_volume = info.get_child_content('parent-volume') + if parent_volume == self.parent_volume: + return True + self.module.fail_json(msg="Error clone %s already exists for parent %s" % (self.volume, parent_volume)) def apply(self): """