Создайте виртуальную машину из шаблона в vcenter, используя vSphere REST API - PullRequest
0 голосов
/ 01 октября 2018

Я пытаюсь клонировать шаблон в виртуальную машину.

 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.

...