Hello,
I am facing a strange problem here, trying to create a VM with Php & SOAP !
I managed to connect to my vCenter, and creating an "empty" VM with no additional hardware (no deviceChange section) is working fine ! As soon as I try to add a hardware element (CDRom in this case) It stops working.
Here's the XML code from my SOAP Request :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:CreateVM_Task>
<ns1:_this>group-v689</ns1:_this>
<ns1:config>
<name>testSOAPh</name>
<version>vmx-11</version>
<guestId>RHEL7_64guest</guestId>
<files>
<vmPathName>[vsanDatastore]</vmPathName>
</files>
<numCPUs>1</numCPUs>
<memoryMB>4096</memoryMB>
<deviceChange>
<VirtualDeviceConfigSpec>
<device type="VirtualCdrom">
<key>-42</key>
<connectable>
<startConnected>true</startConnected>
<allowGuestControl>true</allowGuestControl>
<connected>false</connected>
</connectable>
<controllerKey>200</controllerKey>
<unitNumber>0</unitNumber>
</device>
<operation>add</operation>
</VirtualDeviceConfigSpec>
</deviceChange>
</ns1:config>
<ns1:pool>resgroup-27</ns1:pool>
</ns1:CreateVM_Task>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And the error message :
Required property device is missing from data object of type VirtualDeviceConfigSpec
while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec
at line 2, column 400
while parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec
while parsing serialized DataObject of type vim.vm.ConfigSpec
at line 2, column 213
while parsing call information for method CreateVM_Task
at line 2, column 169
while parsing SOAP body
at line 2, column 154
while parsing SOAP envelope
at line 2, column 0
while parsing HTTP request for method createVm
on object of type vim.Folder
I think I am missing something pretty simple ! Like how to imbricate the device type (how to specify that you want to create a VirtualCdrom which is a special type of VirtualDevice) and how to design an ArrayOfVirtualDeviceConfigSpec !
Any ideas ?
Thanks,
GS