vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
753 stars 311 forks source link

VMDK issues with creating VM #182

Open JimCircadian opened 5 years ago

JimCircadian commented 5 years ago

Environment

- python version:
Python 3.6.8

- vSphere version: 6.7

- Operating System/Shell (used to run SDK-based apps): bash / centos7

## Steps or code snippet to reproduce

vmdkspec = Disk.VmdkCreateSpec( capacity=64 * 1024 ** 3, name="a-test-disk", storage_policy=None, ) boot_disk = Disk.CreateSpec(type=Disk.HostBusAdapterType.SCSI, scsi=ScsiAddressSpec(bus=0, unit=0), new_vmdk=vmdkspec)

... vm_create_spec = VM.CreateSpec(name="a-test-name", hardware_version=Hardware.Version.VMX_11, cpu=Cpu.UpdateSpec(count=2, cores_per_socket=1, hot_add_enabled=False, hot_remove_enabled=False), memory=Memory.UpdateSpec(size_mib=2 * 1024, hot_add_enabled=False), guest_os=GuestOS.CENTOS_7, placement=placement_spec, disks=[primary_disk], nics=[nic], boot=boot_spec, boot_devices=boot_device_order,)


## Actual behavior

Two things (related, I promise!) 

Firstly, I can't see any way to thin provision the disks via the REST API when creating the VM, is this not possible?

Secondly, on attempting to provision the VM I get the following error:

INFO:root:Resource pool group-v1172 and folder resgroup-1053 with datastore datastore-952 selected INFO:root:Creating VM Traceback (most recent call last): File "create_vm.py", line 70, in vm = client.vcenter.VM.create(vm_create_spec) File "/home/jambyr/.virtualenvs/vmware/lib/python3.6/site-packages/com/vmware/vcenter_client.py", line 3660, in create 'spec': spec, File "/home/jambyr/.virtualenvs/vmware/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke return self._api_interface.native_invoke(ctx, _method_name, kwargs) File "/home/jambyr/.virtualenvs/vmware/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 298, in native_invoke self._rest_converter_mode) com.vmware.vapi.std.errors_client.Unsupported: {messages : [LocalizableMessage(id='com.vmware.api.vcenter.vm.device.disk.unsupported_gos_get_disk_size', default_message="Unable to get recommended disk size for the guest OS. Guest OS 'CENTOS_7' is not supported.", args=['CENTOS_7'], params=None, localized=None)], data : None, error_type : None}



## Expected behavior

I would expect by defining the vmdkspec / disk spec that it shouldn't be trying to pull the recommended disk size from the CENTOS_7 profile. Also I was expecting (perhaps via the vmdkspec) to be able to specify the provisioning type. 

Any help gratefully received!

All the best
JimCircadian commented 5 years ago

It turns out using GuestOS.CENTOS or GuestOS.RHEL-7 works fine. I guess this is the based on the host version?

Though the disk also ended up being thin provisioned, I'd be interested to understand whether it's a missing feature of the REST API to specify the provisioning type?

Thanks in advance.

jobingeo commented 5 years ago

The REST API vmdk create spec doesn't support desired provisioning like LAZY, THICK, THIN etc.

Only few config is supported in vmdk create spec (which you already covered as in your code snippet), https://vmware.github.io/vsphere-automation-sdk-python/vsphere/cloud/com.vmware.vcenter.vm.html#com.vmware.vcenter.vm.hardware_client.Disk.VmdkCreateSpec

JimCircadian commented 4 years ago

If there's anything I can do to help advance this, let me know! ;-) I think it's still a really useful feature to have!

strahinjanis commented 3 years ago

"...The REST API vmdk create spec doesn't support desired provisioning like LAZY, THICK, THIN etc...." stuck with this as well, is there any estimation when we can expect that to be available? The provisioning of HDD (vmdk) is OK, but it's odd to think in direction to convert from thin to tick (or vice versa) because of lack of ability to specify that in advance.