从OVF部署VM时的PropertyParams

时间:2017-12-20 19:01:23

标签: rest vmware vcenter

我正在使用VMWare vCenter REST API从OVF库项目部署新的虚拟机。 API的一部分允许additional_paramaters,但我无法使其正常运行。具体来说,我想为自定义OVF模板属性设置PropertyParams

从OVF部署VM时,我使用以下REST API: POST https://{server}/rest/com/vmware/vcenter/ovf/library-item/id:{ovf_library_item_id}?~action=deploy

我已经尝试了很多结构,最终结果是POST成功,但参数完全被忽略,或者出现500内部服务器错误,并显示有关未能转换properties结构的消息:

  

无法转换字段'属性'结构' com.vmware.vcenter.ovf.property_params'

从文档中看似正确的有效负载(但失败并出现上述错误):

deployment_spec : {
  /* ... */

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

给定包含以下内容的OVF:

<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>

对于其他属性类型(例如boolean

)也是如此

请注意I have posted on the vCenter forums as well

1 个答案:

答案 0 :(得分:1)

我有同样的问题,我成功通过浏览vapi结构来解决它/com/vmware/vapi/metadata/metamodel/structure/id:<idstructure>

以下是我的发现:

首先,使用过滤器api获取属性结构:

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

然后,要部署,请使用com.vmware.vcenter.ovh.property_params类。用例子来说会更清楚:

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