VMware {code} Community
kimroz
Contributor
Contributor

Unable to apply profile to a VM programmatically at the time of configure and clone of a VM.

We are encountering an issue while asigning policy to a VM using vSphere SDK.

Issue: at the time of un-registering a VM the VM loses its profile, while registering it again we wish to reapply the policy.

As per our understanding this can be done using re-configuring the VM. We tried to apply the policy to the VM at the time of reconfiguration using the property VirtualMachineDefinedProfileSpec.

https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.vm.DefinedProfileSpec...

Please find the code snippet for the same below:

l_VMConfSpec --> configuration specs for VM config specification.

ns2__VirtualMachineDefinedProfileSpec *pVDevProfileConfSpec2 = soap_new_ns2__VirtualMachineDefinedProfileSpec(m_vim.soap, -1);

pVDevProfileConfSpec2->profileData = soap_new_ns2__VirtualMachineProfileRawData(m_vim.soap, -1);

pVDevProfileConfSpec2->profileId = m_wsStoragePolicyId; //unique id of profile

l_VMConfSpec.vmProfile.push_back(pVDevProfileConfSpec2);

No error is returned from VMware at the time of reconfiguration.

Is this the correct way to assign profile to a VM?


tianhao64

0 Kudos
1 Reply
_vladi_
VMware Employee
VMware Employee

Hi,

This question is not related to vSphere Web Client SDK.

Please post it on the vSphere Management SDK forum here.

Cheers,

Vladimir

0 Kudos