PropertyParams when deploying VM from OVF

I use the VMware vCenter REST API to deploy new virtual machines from OVF library items. The API part allows the use of additional_paramaters , but I cannot get it to function properly. In particular, I would like to set PropertyParams for custom OVF template properties.

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

I tried many structures and either finished POST, but completely ignored the parameters, or with a 500 Internal Server error with a message about the impossibility to convert the properties structure:

Failed to convert properties of field 'structure' com.vmware.vcenter.ovf.property_params'

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

 deployment_spec : { /* ... */ additional_parameters : [ { type : 'PropertyParams', properties : [ { id : 'my_property_name', value : 'foo', } ] } ] } 

For OVF, which 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> 

It is also not suitable for other types of properties, such as boolean .

Please note that I also posted on the vCenter forums .

+5
source share
1 answer

I had the same problem, I managed to solve it by looking at the structure vapi /com/vmware/vapi/metadata/metamodel/structure/id:<idstructure>

Here is my conclusion:

first, get the property structure using the api filter:

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

Then, to deploy, use the com.vmware.vcenter.ovh.property_params class. This will be more clear with an example:

 { "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" } ] } 
+1
source

Source: https://habr.com/ru/post/1274231/


All Articles