I have discovered something, if the VM resids in the root of the datastore it will register as soon as the VM resides
in any sub folder then the register fails .
Can anyone else please confirm this finding.
This is actually an issue with how vmware-cmd was written to parse the path when it's specified in the following format: "/vmfs/volumes/....". The script assumes that the VM folder is at the root of the datastore and no sub-directories are used to further separate it, there is a reason when you create a VM it's stored in the root of the datastore unless manipulated manually.
What is happening is the actual path to the .vmx file is being left out. Since the script is just a Perl script, I added a print statement to show you what it was getting for the $vmxpath variable.
Here is an example of a good register:
DEBUG: \[vmStorage.dev-50\] test/test.vmx
As you can see, it takes that VMFS path and actually translates it to it's internal format which is in the form of:
\[datastore name\] vmfolder/vm.vmx
Here is an example of a bad register where a sub-directory is used:
DEBUG: \[vmStorage.dev-50\] development/test
Fault string: A specified parameter was not correct.
Fault detail: InvalidArgument
A specified parameter was not correct.
As you can see, the development folder is parsed but now the test.vmx is left out and hence it's consider a invalid input and the SOAP fault is thrown.
Without having to edit the script to fix this problem, assuming you figure out the correct regex, you can actually use the expected format to register your VM. I don't recall if this is documented in vCLI references but I know it's not common knowledge unless you work with the APIs
You can also register the VM by using the follow form:
As you can see here, if you specify the alternative and the true syntax format, you can get your VM registered even if there are folders between the root datastore and your VM configuration file.
Give this a try and it should work without any modifications
VMware vExpert 2009,2010
VMware scripts and resources at: http://www.virtuallyghetto.com/
If you find this information useful, please award points for "correct" or "helpful".
awesome we tried it and it works a treat, you have just saved we hours of work thanks