Bug fixes for ontap_volume_clone.py (#44225)

This commit is contained in:
Chris Archibald 2018-08-17 06:11:28 -07:00 committed by ansibot
parent e89e4c991c
commit d0a7147224

View file

@ -12,13 +12,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
module: na_ontap_volume_clone module: na_ontap_volume_clone
short_description: Manage NetApp Ontap volume clones. short_description: Manage NetApp ONTAP volume clones.
extends_documentation_fragment: extends_documentation_fragment:
- netapp.na_ontap - netapp.na_ontap
version_added: '2.6' version_added: '2.6'
author: Chris Archibald (carchi@netapp.com), Kevin Hutton (khutton@netapp.com) author: NetApp Ansible Team (ng-ansibleteam@netapp.com)
description: description:
- Create NetApp Ontap volume clones. - Create NetApp ONTAP volume clones.
- A FlexClone License is required to use this module
options: options:
state: state:
description: description:
@ -147,18 +148,16 @@ class NetAppOntapVolumeClone(object):
def does_volume_clone_exists(self): def does_volume_clone_exists(self):
clone_obj = netapp_utils.zapi.NaElement('volume-clone-get') clone_obj = netapp_utils.zapi.NaElement('volume-clone-get')
clone_obj.add_new_child("volume", self.volume) 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: try:
self.server.invoke_successfully(clone_obj, True) results = self.server.invoke_successfully(clone_obj, True)
except: except:
return False 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): def apply(self):
""" """