Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PropertyParams when deploying VM from OVF

I am using the VMWare vCenter REST API to deploy new Virtual Machines from OVF library items. Part of the API allows for additional_paramaters but I am unable to get it to function properly. Specifically, I would like to set the PropertyParams for custom OVF template properties.

When deploying VM from OVF, I am using the following REST API: POST https://{server}/rest/com/vmware/vcenter/ovf/library-item/id:{ovf_library_item_id}?~action=deploy

I have tried many structures and either end up with the POST succeeding but the parameters completely ignored, or with a 500 Internal Server error with a message about failing to convert the properties structure:

Could not convert field 'properties' of structure 'com.vmware.vcenter.ovf.property_params'

The payload that seems correct from the documentation (but fails with the error above):

deployment_spec : {
  /* ... */

  additional_parameters : [
    {
      type : 'PropertyParams',
      properties : [
        {
          id : 'my_property_name',
          value : 'foo',
        }
      ]
    }
  ]
}

Given an OVF that contains the following:

<ProductSection>
  <Info>Information about the installed software</Info>
  <Product>MyProduct</Product>
  <Vendor>MyCompany</Vendor>
  <Version>1.0</Version>
  <Category>Config</Category>  
  <Property ovf:userConfigurable="true" ovf:type="string" ovf:key="my_property_name" ovf:value="">
    <Label>My Property</Label>
    <Description>A custom property</Description>
  </Property>
</ProductSection>

This also fails for other property types such as boolean.

Note that I have posted on the vCenter forums as well.

like image 790
NuSkooler Avatar asked Nov 07 '22 12:11

NuSkooler


1 Answers

I had the same issue, i success to solve it by browsing the vapi structure /com/vmware/vapi/metadata/metamodel/structure/id:<idstructure>

Here is my finding :

firstly, get your properties structure by using the filter api :

https://{{vc}}/rest/com/vmware/vcenter/ovf/library-item/id:300401a5-4561-4c3d-ac67-67bc7a1a6

Then, to deploy, use the class com.vmware.vcenter.ovh.property_params. It will be more clear with the exemple :

{
"deployment_spec": {
    "accept_all_EULA": true,
    "name": "clientok",
    "default_datastore_id": "datastore-10",
    "additional_parameters": [
    {
        "@class": "com.vmware.vcenter.ovf.property_params",
            "properties": 
            [
                {
                    "instance_id": "",
                    "class_id": "",
                    "description": "The gateway IP for this virtual appliance.",
                    "id": "gateway",
                    "label": "Default Gateway Address",
                    "category": "LAN",
                    "type": "ip",
                    "value": "10.1.2.1",
                    "ui_optional": true
                }

            ],
        "type": "PropertyParams"
        }
    ]
}
like image 149
Thomas Ferriez Avatar answered Nov 15 '22 08:11

Thomas Ferriez