Hello everybody,
I'm currently trying to write a scriptable task which creates an empty VM, which should be placed in a storagePod aka datastore cluster.
I played around a lot and I'm not really able to achieve the result which I want to achieve due to the fact that I have a problem with initial placement of
the VM files using VcVirtualMachineFileInfo.
var files = new VcVirtualMachineFileInfo();
files.vmPathName = " ";
According to
this should work as it says:
For CreateVm and AddDisk, the manually selected datastore must be specified in ConfigSpec.files or ConfigSpec.deviceChange.device.backing.datastore,
the fields should will be unset if the user wants SDRS to recommend the datastore.
Looking at
https://github.com/lamw/vghetto-scripts/blob/master/perl/datastoreClusterVMProvisioning.pl
this also gives the impression that this should work as William uses
files => VirtualMachineFileInfo->new(
vmPathName => ""
)
When I try to use
files.vmPathName = " ";
I receive an error, which looks as follows
DynamicWrapper (Instance) : [VcVirtualMachineFileInfo]-[class com.vmware.o11n.plugin.vsphere_gen.FileInfo_2Wrapper] -- VALUE : (vim.vm.FileInfo) {
dynamicType = null,
dynamicProperty = null,
vmPathName = ,
snapshotDirectory = null,
suspendDirectory = null,
logDirectory = null,
ftMetadataDirectory = null
}
Workflow execution stack:
item: 'Create VM - SP/item4', state: 'failed', business state: 'Create the VM', exception: 'Task 'createVm' error: Invalid datastore path ' '. (Dynamic Script Module name : vim3WaitTaskEnd#20)'
workflow: 'Create VM - SP' (85860245-6211-435a-b23b-2b50f205dde1)
At the moment I'm only able to create the empty VM by using
var files = new VcVirtualMachineFileInfo();
files.vmPathName = "[" + vmStoragePod.childEntity[0].info.name + "]";
where vmStoragePod is the storagePod I've selected for the deployment.
Would be nice if somebody can bring me on the right track which lets me pick
files.vmPathName = " ";
Thank you very much,
Lars
Have you tried with
files.vmPathName = ""; // empty string "" is different than a single space string " "
or not set vmPathName field at all (it is not required If I'm not mistaken)
Hello Illian,
thank you for the quick response, but it isn't that easy ...
Using
files.vmPathName = "";
is not working. That's what I've tried first, the space between the "" from my initial posting was an error which resulted from editing the code to often ![]()
Not setting vmPathName leads to this error
item: 'Create VM - SP/item4', state: 'failed', business state: 'Create the VM', exception: 'Task 'createVm' error: A specified parameter was not correct: config.files.vmpathname (Dynamic Script Module name : vim3WaitTaskEnd#20)'
workflow: 'Create VM - SP' (85860245-6211-435a-b23b-2b50f205dde1)
Completing commenting out
/* var files = new VcVirtualMachineFileInfo();
files.vmPathName = "";
*/
throws this error
[2019-02-11 11:02:29.826] [E] (com.vmware.library.vc.basic/vim3WaitTaskEnd) Error in (Dynamic Script Module name : vim3WaitTaskEnd#20) Task 'createVm' error: A specified parameter was not correct: config.files
[2019-02-11 11:02:29.834] [E] Workflow execution stack:
Regards,
Lars
