-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Summary
Another bug related to incorrect assumption that a value, in this case a file path, doesn't contain spaces.
A have legacy VM that has the following path for vmx file
/vmfs/volumes/datastore-ssd-1/Storage\ Windows\ Server\ 2012\ R2/Storage\ Windows\ Server\ 2012\ R2.vmx
Both getDstVmxFile and readVMXContents functions have quite similar code:
command = fmt.Sprintf("vim-cmd vmsvc/get.config %s | grep vmPathName|awk '{print $NF}'|sed 's/[\"|,]//g'", vm.Id)
stdout, _ = esxi.Execute(command, "get dst_vmx")
dstVmx := stdout
awk '{print $NF}' prints the last column, where columns are sliced by space/tab.
The next command sed 's/[\"|,]//g' removes trailing double quote and comma.
Therefore in my case the output would be just R2.vmx.
Obviously, the downstream code is not able to find and read the file, resulting in some garbage values.
Also, I noticed that both functions are calling remote command execution vim-cmd vmsvc/get.config %s | grep vmPathName twice, first one to get the datastore name and the second to get vmx file path.
This seems unnecessary and expensive as a single call already returns a string that can be parsed by the plugin itself to extract required values therefore saving on a second remote call and execution.
Diagnostics
What version of the provider are you running?
The plugin version is 1.0.0
Message from the maintainers:
Impacted by this bug? Give it a π. We prioritise the issues with the most π.