|
|
@ -28,22 +28,21 @@ requirements:
|
|
|
|
- PyVmomi
|
|
|
|
- PyVmomi
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
name:
|
|
|
|
name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the VM to work with.
|
|
|
|
- Name of the VM to work with.
|
|
|
|
- This is required if uuid is not supplied.
|
|
|
|
- This is required if C(uuid) parameter is not supplied.
|
|
|
|
uuid:
|
|
|
|
uuid:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- UUID of the instance to manage if known, this is VMware's BIOS UUID.
|
|
|
|
- UUID of the instance to manage if known, this is VMware's BIOS UUID.
|
|
|
|
- This is required if name is not supplied.
|
|
|
|
- This is required if C(name) parameter is not supplied.
|
|
|
|
datacenter:
|
|
|
|
datacenter:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Destination datacenter for the find operation.
|
|
|
|
- Destination datacenter for the find operation.
|
|
|
|
- Deprecated in 2.5, will be removed in 2.9 release.
|
|
|
|
- Deprecated in 2.5, will be removed in 2.9 release.
|
|
|
|
required: True
|
|
|
|
|
|
|
|
extends_documentation_fragment: vmware.documentation
|
|
|
|
extends_documentation_fragment: vmware.documentation
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: Find Guest's Folder using name
|
|
|
|
- name: Find Guest's Folder using name
|
|
|
|
vmware_guest_find:
|
|
|
|
vmware_guest_find:
|
|
|
|
hostname: 192.168.1.209
|
|
|
|
hostname: 192.168.1.209
|
|
|
@ -68,6 +67,9 @@ folders:
|
|
|
|
description: List of folders for user specified virtual machine
|
|
|
|
description: List of folders for user specified virtual machine
|
|
|
|
returned: on success
|
|
|
|
returned: on success
|
|
|
|
type: list
|
|
|
|
type: list
|
|
|
|
|
|
|
|
sample: [
|
|
|
|
|
|
|
|
'/DC0/vm',
|
|
|
|
|
|
|
|
]
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -75,9 +77,7 @@ from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
from ansible.module_utils.vmware import PyVmomi, get_all_objs, vmware_argument_spec
|
|
|
|
from ansible.module_utils.vmware import PyVmomi, get_all_objs, vmware_argument_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import pyVmomi
|
|
|
|
|
|
|
|
from pyVmomi import vim
|
|
|
|
from pyVmomi import vim
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -86,8 +86,6 @@ except ImportError:
|
|
|
|
class PyVmomiHelper(PyVmomi):
|
|
|
|
class PyVmomiHelper(PyVmomi):
|
|
|
|
def __init__(self, module):
|
|
|
|
def __init__(self, module):
|
|
|
|
super(PyVmomiHelper, self).__init__(module)
|
|
|
|
super(PyVmomiHelper, self).__init__(module)
|
|
|
|
self.datacenter = None
|
|
|
|
|
|
|
|
self.folders = None
|
|
|
|
|
|
|
|
self.name = self.params['name']
|
|
|
|
self.name = self.params['name']
|
|
|
|
self.uuid = self.params['uuid']
|
|
|
|
self.uuid = self.params['uuid']
|
|
|
|
|
|
|
|
|
|
|
@ -112,11 +110,13 @@ def main():
|
|
|
|
argument_spec.update(
|
|
|
|
argument_spec.update(
|
|
|
|
name=dict(type='str'),
|
|
|
|
name=dict(type='str'),
|
|
|
|
uuid=dict(type='str'),
|
|
|
|
uuid=dict(type='str'),
|
|
|
|
datacenter=dict(removed_in_version=2.9, type='str', required=True)
|
|
|
|
datacenter=dict(removed_in_version=2.9, type='str')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(argument_spec=argument_spec,
|
|
|
|
module = AnsibleModule(argument_spec=argument_spec,
|
|
|
|
required_one_of=[['name', 'uuid']])
|
|
|
|
required_one_of=[['name', 'uuid']],
|
|
|
|
|
|
|
|
mutually_exclusive=[['name', 'uuid']],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
pyv = PyVmomiHelper(module)
|
|
|
|
pyv = PyVmomiHelper(module)
|
|
|
|
# Check if the VM exists before continuing
|
|
|
|
# Check if the VM exists before continuing
|
|
|
|