VMware Cloud Community
PeterNZ
Contributor
Contributor

Programmatic VCloud provisioning - unable to customise vm when creating vapp from template

I have a specific issue with VMs not respecting the hostname and IP address specified through the API.

The vCloud Director portal appears to show the correct details but the instances themselves have the details from the vApp Template.

I’ve attached a code snippet. There are two methods: StartInstances which either calls vApp.RecomposeVapp (for adding VMs from a template to  an existing vApp) or _vdc.ComposeVapp (to add to a new vApp).

I’ve noted that once the VM is created, the guest customization is not enabled (see image attached). The screenshot shows the VM stopped.

I believe this is the root cause of the machine name and ip address not being set within the instance. Any assistance on how to enable the customization in these two use cases would be appreciated.

I’ve had a look at the guest customization example plus the 1.5 API guide, but it has not been much help.

Cheers,

Peter

0 Kudos
2 Replies
rkamal
VMware Employee
VMware Employee

Hi,

I see in your code you are setting the ComputerName and the Info properties. There is also another property which says whether the guest customization is enabled or not. Try setting that to true and then perform the recompose/compose.

                    Items = new object[] { new GuestCustomizationSectionType { ComputerName = vappTemplateVmRef.name, Info = new Msg_Type() }

http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/GuestCustomizat...

Regards,

Rajesh Kamal.

0 Kudos
PeterNZ
Contributor
Contributor

Simple fix:

                vappTemplateItem.InstantiationParams = new InstantiationParamsType
                {
                    Items = new object[] { new GuestCustomizationSectionType { ComputerName = vappTemplateVmRef.name, Info = new Msg_Type(), Enabled=true, EnabledSpecified=true, ChangeSid=true, ChangeSidSpecified=true } }
                };

Many thanks,

Peter

0 Kudos