从 OVF 部署 VM 时的 PropertyParams [英] PropertyParams when deploying VM from OVF

查看:72
本文介绍了从 OVF 部署 VM 时的 PropertyParams的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the VMWare vCenter REST API to deploy new Virtual Machines from OVF library items. Part of the API allows for additional_paramaters but I am unable to get it to function properly. Specifically, I would like to set the PropertyParams for custom OVF template properties.

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

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

我尝试了很多结构,要么以 POST 成功结束,但参数完全被忽略,要么出现 500 Internal Server 错误,并显示无法转换 properties 结构的消息:

I have tried many structures and either end up with the POST succeeding but the parameters completely ignored, or with a 500 Internal Server error with a message about failing to convert the properties structure:

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

Could not convert field 'properties' of structure 'com.vmware.vcenter.ovf.property_params'

文档中似乎正确的有效负载(但因上述错误而失败):

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

deployment_spec : {
  /* ... */

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

给定一个包含以下内容的 OVF:

Given an OVF that 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>

这对于其他属性类型也失败,例如 boolean.

This also fails for other property types such as boolean.

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

推荐答案

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

I had the same issue, i success to solve it by browsing the vapi structure /com/vmware/vapi/metadata/metamodel/structure/id:<idstructure>

这是我的发现:

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

firstly, get your properties structure by using the filter api :

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

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

Then, to deploy, use the class com.vmware.vcenter.ovh.property_params. It will be more clear with the exemple :

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

这篇关于从 OVF 部署 VM 时的 PropertyParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆