Contributor
Contributor

Adding custom properties to a VM

Hi,

I am trying to create a VM from a template which contains some custom properties. I am using the vCloud Java API version 1.5. I can't intuitively figure out which API or Element I should use to set the custom properties.

Here is what I have for configuring the VM Template Item which works properly for the networking configuration. Please show me how I can pass custom properties as well.

    private static SourcedCompositionItemParamType addVAppTemplateItem(String vAppNetwork, MsgType networkInfo, String vmHref, String ipAddress, String vmName) {
        SourcedCompositionItemParamType vappTemplateItem = new SourcedCompositionItemParamType();
        ReferenceType vappTemplateVMRef = new ReferenceType();
        vappTemplateVMRef.setHref(vmHref);
        vappTemplateVMRef.setName(vmName);
        vappTemplateItem.setSource(vappTemplateVMRef);
        NetworkConnectionSectionType networkConnectionSectionType = new NetworkConnectionSectionType();
        networkConnectionSectionType.setInfo(networkInfo);
        NetworkConnectionType networkConnectionType = new NetworkConnectionType();
        networkConnectionType.setNetwork(vAppNetwork);
        networkConnectionType.setIpAddressAllocationMode(IpAddressAllocationModeType.MANUAL.value());
        networkConnectionType.setIpAddress(ipAddress);
        networkConnectionType.setIsConnected(true);
        networkConnectionSectionType.getNetworkConnection().add(networkConnectionType);
        InstantiationParamsType vmInstantiationParamsType = new InstantiationParamsType();
        List<JAXBElement<? extends SectionType>> vmSections = vmInstantiationParamsType.getSection();
        vmSections.add(new ObjectFactory().createNetworkConnectionSection(networkConnectionSectionType));
        vappTemplateItem.setInstantiationParams(vmInstantiationParamsType);
        return vappTemplateItem;
    }

Tags (1)
0 Kudos
3 Replies
Contributor
Contributor

0 Kudos
VMware Employee
VMware Employee

If you want to pass some guest customization values. Use the GuestCustomizationSection similar to the NetworkConnectionSection that you have user.

If you want to pass runtime information for the vm. I dont think you can send that information as part of the compose/recompose. You can instead create the vapp and then go to the vm's ProductSection to update the runtime information which you want to pass in.

If you want to just tag the vcloud resources use Metadata tagging which is available for almost all the vcloud resources.

Regards,

Rajesh Kamal.

Contributor
Contributor

Since I was setting OVF or 'run time properties' I did need to update the product section. As Kamal said this cannot be done at the time you are creating the vApp and has to be done only later.

0 Kudos