0

I'm trying to figure out how to assign a VM to a folder that does not contain a unique name. I'm currently testing with the clone_vm.py template. With the sample, I have the ability to set the folder, but it does not work correctly if there's nested folders with the same name (example below). I would like to make sure the folder assigned is the "Linux/Dev" folder, but I can only pass "Dev" and hope that it picks the right one. The line of code below is how the folder is being set.

destfolder = get_obj(content, [vim.Folder], vm_folder)

Linux

    |------Dev

    |------Prod

Windows

    |------Dev

    |------Prod

Thanks!

user3704433
  • 33
  • 1
  • 5

1 Answers1

0

The best way to do that is to use a search_index.FindByInventoryPath and get the folder by the path. It can be a little confusing because of hidden folders but the MOB can help you. I answered a question where I covered how to use that search method see this answer.

Michael Rice
  • 7,974
  • 1
  • 15
  • 18
  • Hi Michael, thanks for the suggestion. I used the FindByInventoryPath to grab the correct folder and everything works great. – user3704433 Dec 08 '17 at 16:05