使用vSphere REST API在vcenter中从模板创建VM

时间:2018-10-01 03:40:40

标签: rest vsphere vcenter

我正在尝试将模板克隆到VM。

 var options1 = { method: 'POST',
rejectUnauthorized: false, 
headers : {"Content-Type": "application/json",
           "vmware-api-session-id": token },
  url: 'https://ipaddress/rest/vcenter/vm',
  body: {
    spec:
        { id: 'VM2',
          parentid: 'vm-172',
          name: 'testapp',
          tag: 'Development' }},
  json: true };
   console.log(options1)
  request(options1, function (error, response, body) {
    if (error) throw new Error(error);
    console.log(body.value["messages"])
    console.log(response.statusCode)
    console.log(JSON.parse(body)["value"])

  ;})

以下是vcenter返回的错误:

[ { args: [ 'com.vmware.vcenter.VM.create' ],
    default_message:
     'Unable to validate input to method com.vmware.vcenter.VM.create',
    id: 'vapi.invoke.input.invalid' },
  { args: [ 'spec' ],
    default_message: 'Found invalid field spec in structure.',
    id: 'vapi.data.structure.field.invalid' },
  { args: [ 'com.vmware.vcenter.VM.create_spec', 'guest_OS' ],
    default_message:
     'Structure \'com.vmware.vcenter.VM.create_spec\' is missing a field: guest_OS',
    id: 'vapi.data.structure.field.missing' } ]

我没有找到任何资源来展示如何使用REST API将模板克隆到VM。

0 个答案:

没有答案