从 OVF 部署 VM 时的 PropertyParams

PropertyParams when deploying VM from OVF

我正在使用 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 结构的消息结束:

Could not convert field 'properties' of structure '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.

我有同样的问题,我通过浏览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

然后,要部署,请使用 class 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"
        }
    ]
}