5

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

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

我尝试了许多结构,要么最终导致 POST 成功,但参数完全被忽略,要么出现 500 Internal Server 错误,并显示有关无法转换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.

请注意,我也在 vCenter 论坛上发帖

4

1 回答 1

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"
        }
    ]
}
于 2018-01-31T17:06:44.610 回答