2

我正在尝试使用 API 操作createVm创建一个独立的 VM 。
这是我的 xml 模板,在添加当前日期时间和 StorageProfileHref 后将通过我的 pythonscript 上传:

<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>

服务器响应:

{
  "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" : [ ]
}

我究竟做错了什么?因为如果我登录 vCloud Director 浏览器门户,我可以创建一个独立的 VM。
如果有人能为我指出正确的方向,那就太好了。

服务器日志:

Guest Os type is null or 0 - falling back to validating non-FQDN hostnames

所以我的 OsType 出了点问题 --> 我也会调查一下,但我们将不胜感激。:)

4

1 回答 1

3

好吧……解决了!添加 overrideVmDefault 后它起作用了!

编辑:

<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>
于 2020-07-02T10:16:50.660 回答