我正在使用VMWare vCenter REST从OVF库项部署新的虚拟机。API的一部分允许使用additional_paramaters,但我无法使它正常工作。具体来说,我想为定制的OVF模板属性设置PropertyParams。
在从OVF部署VM时,我使用以下REST: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 ),这也会失败。
发布于 2018-01-31 17:06:44
我有同样的问题,我成功地通过浏览vapi结构/com/vmware/vapi/metadata/metamodel/structure/id:<idstructure>来解决它。
这是我的发现:
首先,使用filter获取属性结构:
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"
}
]
}https://stackoverflow.com/questions/47912744
复制相似问题