Comment 6 for bug 1884490

Revision history for this message
Pedro GuimarĂ£es (pguimaraes) wrote :

Going a little deeper, FindFolder seems to be the right place to run any changes since createvm.go also uses it to recover VMs' RootVMFolder before running the actual creation command:
https://github.com/juju/juju/blob/develop/provider/vsphere/internal/vsphereclient/createvm.go#L319

It seems govmomi is not returning the entire absolute path with:
https://github.com/juju/juju/blob/develop/provider/vsphere/internal/vsphereclient/client.go#L120

My suggestion is to add an extra check, as such (after L120 check):
if !strings.HasPrefix(folderPath, fi.datacenterPath(ctx, datacenter)) {
 c.logger.Debugf("Discovered a DC folder, adding it tot he begining of the path")
        // ADD IT TO THE BEGINNING OF THE PATH
}

I am not sure that datacenterPath will return the entire root path, with DC folder.