-
Notifications
You must be signed in to change notification settings - Fork 174
Folder create on #traverse only creates Parent (not recursive?) #110
Comments
Not sure about this. I'll take a look and see what I can find. Thanks for reporting! |
Seems like it might just not be creating the leaf folder. I attempted changing the path to 'Parent/Child/Offspring' and both Parent and Child folders were created, but not Offspring. Also attempted just passing 'Parent/Child/' to see if the code was maybe just looking for the trailing slash, but that didn't do the trick |
I found out why the leaf folder isn't being created, though I'm not sure what the best approach (if any) would be for a patch. In the traverse method, the path is split into an array and then the last object is popped off (the leaf folder in my case). The original path/array is then created successfully as we already know. The problem comes in the next section in the if statements. In order to create the folder correctly, it needs to fall into the Simply supplying the type of Ex. folder = dc.vmFolder.traverse!('Parent/Child', RbVmomi::VIM::Folder) Curious if there is a way to simplify this for folder creations. A few thoughts came to mind:
if x = p.find(final, type)
x
elsif create and type == RbVmomi::VIM::Datacenter
p.CreateDatacenter(:name => final)
elsif create
p.CreateFolder(:name => final)
else
nil
end Any reason why #2 might not work or if it would break something else? |
Sorry, I never mentioned it. I found the issue to this (the same as you). My concern with changing this is changing how others use this. If people previously used this to create all folders up to the last, then this would be a breaking change. Let me think think on this for a day. I'll make a change either today or tomorrow. Thanks! |
I'm trying to use the traverse method for folders to create a new Folder path within a DC. The top level folder gets created just fine but it doesn't follow through to create the children that I have specified.
My Code:
This code creates the "Parent" folder, but seems to ignore the "Child" folder in the path supplied.
Version of rbvmomi is 1.11.2, version of vsphere is 6.0.0
The text was updated successfully, but these errors were encountered: