NuS*_*ler 5 rest vmware vcenter
我正在使用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内部服务器错误,并显示有关无法转换properties结构的消息:
无法转换结构'com.vmware.vcenter.ovf.property_params'的字段'属性'
从文档中看起来正确的有效负载(但失败并出现上述错误):
deployment_spec : {
/* ... */
additional_parameters : [
{
type : 'PropertyParams',
properties : [
{
id : 'my_property_name',
value : 'foo',
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
给定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>
Run Code Online (Sandbox Code Playgroud)
对于其他属性类型,这也是失败的boolean.
请注意,我也已在vCenter论坛上发布.
小智 2
我遇到了同样的问题,我通过浏览 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"
}
]
}
Run Code Online (Sandbox Code Playgroud)