I'm trying to create a standalone VM with the API operation createVm.
Here is my xml-template, which will be uploaded via my pythonscript after adding current datetime and StorageProfileHref:
<CreateVmParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:environment_1="http://schemas.dmtf.org/ovf/environment/1" name="test-vm-api" powerOn="false">
<Description>test-vm created through api</Description>
<CreateVm name="test-vm-api2" deployed="false" needsCustomization="false"
nestedHypervisorEnabled="false">
<Description>test-vm created through api2 </Description>
<GuestCustomizationSection>
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
<ComputerName>test-vm-1</ComputerName>
</GuestCustomizationSection>
<VmSpecSection Modified="true">
<ovf:Info>Virtual Machine specification</ovf:Info>
<OsType>ubuntu64Guest</OsType>
<NumCpus>1</NumCpus>
<NumCoresPerSocket>1</NumCoresPerSocket>
<CpuResourceMhz>
<Configured>0</Configured>
</CpuResourceMhz>
<MemoryResourceMb>
<Configured>512</Configured>
</MemoryResourceMb>
<DiskSection>
<DiskSettings>
<DiskId>2000</DiskId>
<SizeMb>16384</SizeMb>
<UnitNumber>0</UnitNumber>
<BusNumber>0</BusNumber>
<AdapterType>5</AdapterType>
<ThinProvisioned>true</ThinProvisioned>
<StorageProfile href="https://somehref" name="*"/>
</DiskSettings>
</DiskSection>
<HardwareVersion>vmx-14</HardwareVersion>
<VirtualCpuType>VM64</VirtualCpuType>
<TimeSyncWithHost>false</TimeSyncWithHost>
</VmSpecSection>
<DateCreated></DateCreated>
<VAppScopedLocalId>test-vm</VAppScopedLocalId>
<VmCapabilities>
<MemoryHotAddEnabled>false</MemoryHotAddEnabled>
<CpuHotAddEnabled>false</CpuHotAddEnabled>
</VmCapabilities>
<BootOptions>
<BootDelay>0</BootDelay>
<EnterBIOSSetup>false</EnterBIOSSetup>
</BootOptions>
</CreateVm>
</CreateVmParams>
Server response:
{
"otherAttributes" : { },
"tenantError" : null,
"stackTrace" : null,
"majorErrorCode" : 500,
"message" : "[ 9578e9c0-9c72-4720-afe5-0d5d5c03f2af ] Unable to perform this action. Contact your cloud administrator.",
"minorErrorCode" : "INTERNAL_SERVER_ERROR",
"vendorSpecificErrorCode" : null,
"vCloudExtension" : [ ]
}
What am I doing wrong? Because I can create a standalone VM if I login in the vCloud Director Browser Portal.
Would be nice if someone could pinpoint the right direction for me.
Server Logs:
Guest Os type is null or 0 - falling back to validating non-FQDN hostnames
So something is wrong with my OsType --> I'll look into this too, but help would be appreciated. :)
Alright...solved! After adding overrideVmDefault it worked!
Edit:
<DiskSettings>
<DiskId>2000</DiskId>
<SizeMb>16384</SizeMb>
<UnitNumber>0</UnitNumber>
<BusNumber>0</BusNumber>
<AdapterType>5</AdapterType>
<ThinProvisioned>true</ThinProvisioned>
<StorageProfile href="https://somehref" name="*"/>
<overrideVmDefault>true</overrideVmDefault> <-----------------add this line to above xml
</DiskSettings>