I was able to complete the backup of a VM disks and configuration using a web services C++ wrapper from https://github.com/bfzhao/Native-vShpere. I am in to the restore process now.
During backup, I have stored the whole configuration of the VM (vim.vm.configinfo) as a file. During restore process I read the same to a local data structure(VirtualMachineConfigInfo) and fill VirtualMachineConfigSpec based on the document (https://docs.google.com/viewer?a=v&q=cache:QGSJWZ9-OlIJ:www.vmware.com/support/developer/vddk/vcb_vs...) - Creating Virtual Machine section.
When I issue the CreateVM_Task command with the configspec, it fails in the vi client the error shown is "The operation is not supported by the object". Is there a log at the Esx end which can give more details than this to identify where am I going wrong?
Thanks,
./Siva.
Hi Siva!
Good job, well done. Now my interpretation according to the property docs of managed object Folder is that the folder object you have at hand is one of the following:
I would suggest that you actually have the { "vim.Folder", "vim.Datacenter" } - i.e. the root folder - at hand.
What you should have at hand is a folder of the following type:
Which VM folder is the right one depends on your concrete inventory structure.
Please let me know whether things work out 😉
Hi Siva!
With respect to logs take a look at Overview of Cnfiguration Fles and Log Files. I would start with the vpxa.log and hostd.log.
Additionally make sure you do not set all the information of the ConfigInfo object in the ConfigSpec - especially use negative controller/device keys and do not configure any default devices. Further information on what to include and exclude can be found here further down in section "Using VirtualMachineConfigInfo to Create It".
If you can solve it please let me know what the problem was.
Hi,
Thanks for the response Thomas.
One question from your answer - From the document "Designing backup solutions for vmware vsphere"
However, other controllers and devices must be explicitly included in the VirtualMachineConfigSpec.
Some information about devices is also unneeded and can cause problems if supplied. Each controller device
has its vim.vm.device.VirtualController.device field, which is an array of devices that report to the
controller. The server rebuilds this list when a virtual machine is created using the (negative) device key
numbers supplied as a guide.
The relationship between controller and device must be preserved using negative key numbers in the same
relationship as in the hardware array of the VirtualMachineConfigInfo.
Is the negative device key numbers random or specific to a device?
I actually check the log folder /var/log for any changes happened during the error and none of the log files actually got anything written during that period. But will go through all the log information and get back.
Thanks,
./Siva.
Hi,
I rechecked the code where I fill the devices and it seems fine. I might be wrong in the cpufeature addition - can someone explain what the docs mean by the below statement
One other configuration needs substitution. VirtualMachineConfigInfo contains the cpuFeatureMask, field, which is an array of HostCpuIdInfo. The array entries must be converted to ArrayUpdateSpec entries containing the VirtualMachineCpuIdInfoSpec along with the “operation” field, which must contain the value ArrayUpdateOperation::add. The VirtualMachineCpuIdInfoSpec also contains a HostCpuIdInfo array that you can copy from the cpuFeatureMask array in VirtualMachineConfigInfo.
How is it possible to do "converted to ArrayUpdateSpec entries containing the VirtualMachineCpuIdInfoSpec"? Either the doc is wrong or I misunderstood something there. Let me know if something wrong in what I do here.
Piece of code where I am populating VirtualMachineConfigSpec Device and CpuFeatureMast
// vmInfo is a instance of VirtualMachineConfigInfo and vmConfigSpec is VirtualMachineConfigSpec.
// Fill up cpufeature mask
vmConfigSpec.cpuFeatureMask = new vw1__VirtualMachineCpuIdInfoSpec*[vmInfo.__sizecpuFeatureMask];
int __sizecpuFeatureMask = vmInfo.__sizecpuFeatureMask;
for(int cpufeatureSize = 0; cpufeatureSize < __sizecpuFeatureMask; cpufeatureSize++)
{
vmConfigSpec.cpuFeatureMask[cpufeatureSize] = new vw1__VirtualMachineCpuIdInfoSpec;
vmConfigSpec.cpuFeatureMask[cpufeatureSize]->info = vmInfo.cpuFeatureMask[cpufeatureSize];
vmConfigSpec.cpuFeatureMask[cpufeatureSize]->operation = vw1__ArrayUpdateOperation__add;
}
Hi Siva!
As far as I understand things you can choose the negative device numbers freely.
Hi Siva!
How is it possible to do "converted to ArrayUpdateSpec entries containing the VirtualMachineCpuIdInfoSpec"? Either the doc is wrong or I misunderstood something there. Let me know if something wrong in what I do here.
As I see it VirtualMachineCpuIdInfoSpec is a sub class of ArrayUpdateSpec and that fact actually makes the conversion, i.e. - without having tried it yet - I would say your code is good.
Another question:
Besides the error message visible in viClient is there any Fault returned by the CreateVM_Task operation. Maybe your VirtualMachineConfigSpec object is good but the invocation of CreateVM_Task is bad, e.g. maybe the folder in which you are trying to create the VM actually does not support childType "vim.Virtualmachine".
Thanks Thomas. I will check the folder object and other parameters to the function whether they might have a problem. I have checked the logs - vpxa.log and hostd.log, no information that is particularly helpful to the current problem gets printed there.
This problem is really exhausting .
Hi Siva!
I have checked the logs - vpxa.log and hostd.log, no information that is particularly helpful to the current problem gets printed there.
Check this out Configure Logging Options - maybe this can make the logs more verbose.
Don't want to be pushy but is there a Fault returned by the CreateVM_Task operation.
Hurrah - you are right - NotSupportedThrown if the virtual machine is being created within a folder whose childType property is not set to "VirtualMachine".
This is what the error I am getting in the logs. Now I have to figure what this means, atleast some to tinker upon :smileygrin:
Hi Siva!
Good job, well done. Now my interpretation according to the property docs of managed object Folder is that the folder object you have at hand is one of the following:
I would suggest that you actually have the { "vim.Folder", "vim.Datacenter" } - i.e. the root folder - at hand.
What you should have at hand is a folder of the following type:
Which VM folder is the right one depends on your concrete inventory structure.
Please let me know whether things work out 😉
Hi Thomas,
What can I say? It is just becoming redutant that I get in to problems and you coming up with solutions. But this one is just great. If at all you visit Chennai, India sometime, you are getting a big party from me. Thanks a lot for the earlier answers.
You are right in pointing out the folder information. Once that got resolved, all I had to do was small adjustments in the config which are straight forward as the server started to give better errors. Finally I created a VM from the config file - thanks to you.
.
Hi Siva!
Finally I created a VM from the config file - thanks to you.
Hoooooooraaaayyyyyy - this is really good news, congratulations :-)))
What can I say? It is just becoming redutant that I get in to problems and you coming up with solutions. But this one is just great.
Thank's a bunch - if possible any time again
If at all you visit Chennai, India sometime, you are getting a big party from me.
Dancing on the ceiling ??? Will Lionel be there ???
Thanks a lot for the earlier answers.
You are welcome, here is happy if able to help - you know somehow your problems are also mine 😉
Hi..I am also trying out to create VM using c++.Can you please share the code snippet of how you created the vm using config spec file?