【问题标题】:PropertyParams when deploying VM from OVF从 OVF 部署 VM 时的 PropertyParams
【发布时间】:2018-06-03 09:50:02
【问题描述】:

我正在使用 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 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)也会失败。

注意I have posted on the vCenter forums as well

【问题讨论】:

    标签: rest vmware vcenter


    【解决方案1】:

    我也遇到了同样的问题,通过浏览vapi结构/com/vmware/vapi/metadata/metamodel/structure/id:&lt;idstructure&gt;成功解决了

    这是我的发现:

    首先,使用过滤器 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"
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 2014-02-20
      • 2018-12-20
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多