VMware {code} Community
sivadevel
Enthusiast
Enthusiast
Jump to solution

CreateVM_Task failure during restore process.

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
togtog
Hot Shot
Hot Shot
Jump to solution

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:

  • { "vim.Folder", "vim.Datacenter" } - Identifies the root folder and its descendant folders. Data center folders can contain child data center folders and Datacenter managed objects. Datacenter objects contain virtual machine, compute resource, network entity, and datastore folders.
  • { "vim.Folder", "vim.ComputeResource" } - Identifies a compute resource folder, which contains child compute resource folders and ComputeResource hierarchies.
  • { "vim.Folder", "vim.Network" } - Identifies a network entity folder. Network entity folders can contain Network, and DistributedVirtualSwitch managed objects.
  • { "vim.Folder", "vim.Datastore" } - Identifies a datastore folder. Datastore folders can contain child datastore folders and Datastore managed objects.


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:

  • { "vim.Folder", "vim.Virtualmachine", "vim.VirtualApp" } - Identifies a virtual machine folder. A virtual machine folder may contain child virtual machine folders. It also can contain VirtualMachine managed objects, templates, and VirtualApp managed objects.

Which VM folder is the right one depends on your concrete inventory structure.

Please let me know whether things work out 😉

Thomas G.

View solution in original post

Reply
0 Kudos
12 Replies
togtog
Hot Shot
Hot Shot
Jump to solution

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.

Thomas G.
sivadevel
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
sivadevel
Enthusiast
Enthusiast
Jump to solution

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;
    }

Reply
0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

Hi Siva!

As far as I understand things you can choose the negative device numbers freely.

Thomas G.
Reply
0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

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".

Thomas G.
Reply
0 Kudos
sivadevel
Enthusiast
Enthusiast
Jump to solution

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 Smiley Sad.

Reply
0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

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.

Thomas G.
Reply
0 Kudos
sivadevel
Enthusiast
Enthusiast
Jump to solution

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:

Reply
0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

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:

  • { "vim.Folder", "vim.Datacenter" } - Identifies the root folder and its descendant folders. Data center folders can contain child data center folders and Datacenter managed objects. Datacenter objects contain virtual machine, compute resource, network entity, and datastore folders.
  • { "vim.Folder", "vim.ComputeResource" } - Identifies a compute resource folder, which contains child compute resource folders and ComputeResource hierarchies.
  • { "vim.Folder", "vim.Network" } - Identifies a network entity folder. Network entity folders can contain Network, and DistributedVirtualSwitch managed objects.
  • { "vim.Folder", "vim.Datastore" } - Identifies a datastore folder. Datastore folders can contain child datastore folders and Datastore managed objects.


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:

  • { "vim.Folder", "vim.Virtualmachine", "vim.VirtualApp" } - Identifies a virtual machine folder. A virtual machine folder may contain child virtual machine folders. It also can contain VirtualMachine managed objects, templates, and VirtualApp managed objects.

Which VM folder is the right one depends on your concrete inventory structure.

Please let me know whether things work out 😉

Thomas G.
Reply
0 Kudos
sivadevel
Enthusiast
Enthusiast
Jump to solution

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.

.

Reply
0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

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 😉

Thomas G.
Reply
0 Kudos
sgupta12345
Contributor
Contributor
Jump to solution

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?

Reply
0 Kudos