Skip to content

Instantly share code, notes, and snippets.

@dav1x
Last active March 24, 2017 19:33
Show Gist options
  • Save dav1x/202d7096d89c04c49f8c120020d458e9 to your computer and use it in GitHub Desktop.
Save dav1x/202d7096d89c04c49f8c120020d458e9 to your computer and use it in GitHub Desktop.
def state_add_folder(self):
changed = True
result = None
self.dc_obj = find_datacenter_by_name(self.content, self.datacenter)
self.cluster_obj = find_cluster_by_name_datacenter(self.dc_obj, self.cluster)
self.folder_expanded = self.folder.split("/")
index = 0
for f in self.folder_expanded:
if not self.get_obj([vim.Folder],f):
if index == 0:
#First object gets created on the datacenter
task = self.dc_obj.vmFolder.CreateFolder(name=f)
else:
parent_f = self.get_obj([vim.Folder],self.folder_expanded[index - 1])
task = parent_f.CreateFolder(name=f)
index = index + 1
self.module.exit_json(changed = changed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment