VMware {code} Community
gravelld
Contributor
Contributor

InvalidName when registering a VM via VirtualCenter

If I make the following conceptual call to VC:

vc.registerVM_Task(rootVmFolder, extantPathToVm, null, false, extantResourcePool, null);

I get:

"sanfs:%2f%2fvmfs_uuid:4905a8d4-7c40e3a2-0219-000bdb920512%2fMachine 7%2fMachine " is invalid or too long

Indeed, the above string is eighty characters long. This would suggest I am giving VC the above as a name for the machine, however I'm actually giving it null (as above) in the hope it will use the VMX file's displayName as the name. If I specify a name then it works.

Furthermore, if I connect directly to ESX and do the same thing, rather than use VC, it works.

It appears that VC is generating itself an 'interim' VM name using the path to the VMX file, but this is too long. Given that the SDK suggests it should be possible to not specify a name and the displayName will be used, I'd venture to suggest this is a bug with VC.

In my use case it's difficult for me to provide a name to workaround this as this is fully automated code and there's no way (I know of) of finding the contents of the VMX file to populate the name myself.

Has anyone seen anything similar and do they have workarounds?

0 Kudos
2 Replies
tos2k
Expert
Expert

Hi!

One thing i dont understand:

service.RegisterVM_Task(vmFolderRef,

vm.vmx,

name_of_vm, false, resourcePoolRef,

hostRef)

Why dont you pass the Vm-name explicitely?

HTH, Tos2k

0 Kudos
gravelld
Contributor
Contributor

Because I don't know what the VM name should be. All I have is the list of VMX files that should be registered. This is a fully automated system with no human involvement.

0 Kudos