|
|
@ -24,6 +24,7 @@ version_added: '2.5'
|
|
|
|
author:
|
|
|
|
author:
|
|
|
|
- Abhijeet Kasurde (@Akasurde)
|
|
|
|
- Abhijeet Kasurde (@Akasurde)
|
|
|
|
- Christian Kotte (@ckotte) <christian.kotte@gmx.de>
|
|
|
|
- Christian Kotte (@ckotte) <christian.kotte@gmx.de>
|
|
|
|
|
|
|
|
- Jan Meerkamp (@meerkampdvv)
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- Tested on vSphere 6.5
|
|
|
|
- Tested on vSphere 6.5
|
|
|
|
requirements:
|
|
|
|
requirements:
|
|
|
@ -47,7 +48,6 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the parent folder under which new folder needs to be created.
|
|
|
|
- Name of the parent folder under which new folder needs to be created.
|
|
|
|
- This is case sensitive parameter.
|
|
|
|
- This is case sensitive parameter.
|
|
|
|
- Please specify unique folder name as there is no way to detect duplicate names.
|
|
|
|
|
|
|
|
- "If user wants to create a folder under '/DC0/vm/vm_folder', this value will be 'vm_folder'."
|
|
|
|
- "If user wants to create a folder under '/DC0/vm/vm_folder', this value will be 'vm_folder'."
|
|
|
|
- "If user wants to create a folder under '/DC0/vm/folder1/folder2', this value will be 'folder1/folder2'."
|
|
|
|
- "If user wants to create a folder under '/DC0/vm/folder1/folder2', this value will be 'folder1/folder2'."
|
|
|
|
required: False
|
|
|
|
required: False
|
|
|
@ -191,7 +191,14 @@ class VmwareFolderManager(PyVmomi):
|
|
|
|
if not part_folder_obj:
|
|
|
|
if not part_folder_obj:
|
|
|
|
self.module.fail_json(msg="Could not find folder %s" % part)
|
|
|
|
self.module.fail_json(msg="Could not find folder %s" % part)
|
|
|
|
p_folder_obj = part_folder_obj
|
|
|
|
p_folder_obj = part_folder_obj
|
|
|
|
|
|
|
|
child_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
|
|
|
|
folder_name=folder_name,
|
|
|
|
|
|
|
|
folder_type=folder_type,
|
|
|
|
|
|
|
|
parent_folder=p_folder_obj)
|
|
|
|
|
|
|
|
if child_folder_obj:
|
|
|
|
|
|
|
|
results['result'] = "Folder %s already exists under" \
|
|
|
|
|
|
|
|
" parent folder %s" % (folder_name, parent_folder)
|
|
|
|
|
|
|
|
self.module.exit_json(**results)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
p_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
p_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
folder_name=parent_folder,
|
|
|
|
folder_name=parent_folder,
|
|
|
@ -259,6 +266,22 @@ class VmwareFolderManager(PyVmomi):
|
|
|
|
# Check if the folder already exists
|
|
|
|
# Check if the folder already exists
|
|
|
|
p_folder_obj = None
|
|
|
|
p_folder_obj = None
|
|
|
|
if parent_folder:
|
|
|
|
if parent_folder:
|
|
|
|
|
|
|
|
if "/" in parent_folder:
|
|
|
|
|
|
|
|
parent_folder_parts = parent_folder.strip('/').split('/')
|
|
|
|
|
|
|
|
p_folder_obj = None
|
|
|
|
|
|
|
|
for part in parent_folder_parts:
|
|
|
|
|
|
|
|
part_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
|
|
|
|
folder_name=part,
|
|
|
|
|
|
|
|
folder_type=folder_type,
|
|
|
|
|
|
|
|
parent_folder=p_folder_obj)
|
|
|
|
|
|
|
|
if not part_folder_obj:
|
|
|
|
|
|
|
|
self.module.fail_json(msg="Could not find folder %s" % part)
|
|
|
|
|
|
|
|
p_folder_obj = part_folder_obj
|
|
|
|
|
|
|
|
folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
|
|
|
|
folder_name=folder_name,
|
|
|
|
|
|
|
|
folder_type=folder_type,
|
|
|
|
|
|
|
|
parent_folder=p_folder_obj)
|
|
|
|
|
|
|
|
else:
|
|
|
|
p_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
p_folder_obj = self.get_folder(datacenter_name=datacenter_name,
|
|
|
|
folder_name=parent_folder,
|
|
|
|
folder_name=parent_folder,
|
|
|
|
folder_type=folder_type)
|
|
|
|
folder_type=folder_type)
|
|
|
|