Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload a vmdk to vsan datastore leaves disk unusable #1064

Open
Klaas- opened this issue Feb 6, 2024 · 4 comments
Open

upload a vmdk to vsan datastore leaves disk unusable #1064

Klaas- opened this issue Feb 6, 2024 · 4 comments
Labels

Comments

@Klaas-
Copy link

Klaas- commented Feb 6, 2024

Describe the bug

Hi,
uploading a vmdk with pyvmomi to a vsan datastore seem to leave the resulting file in an unusable state.

This pops up for me because I am using vsphere_copy in ansible (which is using the sdk in background).

For simplicity I reproduced the issue with the sample datastore upload python:
https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/upload_file_to_datastore.py

Version 8.0.2.0.1
Python 3.11 on a RHEL8.9

vmdk is a stream optimized v6 image, using the same file and uploading it via the webui through firefox results in a usable vmdk.

Uploading the vmdk via api results in an error when trying to use in vsphere:
"Unsupported or invalid disk type 22 for 'scsi0:0'. Ensure that the disk has been imported."

vCenter: 7.0.3 Build: 22357613 (VxRail 7.0.482)

Reproduction steps

  1. have a stream optimized vmdk + a vsphere + vsan
  2. python3.11 upload_file_to_datastore.py -s vsphere_server -o 443 -u [email protected] -p "password" --disable-ssl-verification --datastore-name VxRail-Virtual-SAN-Datastore-id --local-file-path ~/diskimages/file.vmdk --remote-file-path import/file.vmdk
  3. create a VM that uses that VMDK as disk
    ...

Expected behavior

Works, no error

Additional context

Actual behavior:
VM does not start; error "Unsupported or invalid disk type 22 for 'scsi0:0'. Ensure that the disk has been imported."

@Klaas- Klaas- added the bug label Feb 6, 2024
@Klaas-
Copy link
Author

Klaas- commented Feb 8, 2024

I figured it out, so not sure if this belongs here or somewhere else :)

While comparing what the sample/sdk does to what the WebUI does I noticed that the webui sets an additional argument that is not documented as far as I could find

So if you set the option like this:

        params = {"dsName": datastore.info.name,
                  "dcPath": datacenter.name,
                  "diskFormat": "StreamVmdk"
                 }

It works fine. Not sure if this is considered to be a problem in the sdk/example but it for sure is missing from the api documentation https://vdc-download.vmware.com/vmwb-repository/dcr-public/c369f363-3f34-4acb-8620-e861a6c24013/1c6e721f-2d3b-4740-bf94-3409efb5f08b/WebServicesSDKprogramming802.pdf

@mariolenz
Copy link

I didn't find any documentation about this diskFormat parameter. I didn't really find any documentation about uploading files at all.

It would be really great to see this officially documented somewhere ;-)

softwarefactory-project-zuul bot pushed a commit to ansible-collections/community.vmware that referenced this issue Feb 15, 2024
#1995)

Add possiblity to tell vsphere_copy which diskformat is being uploaded

SUMMARY
Add possiblity to tell vsphere_copy which diskformat is being uploaded
ISSUE TYPE


Feature Pull Request

COMPONENT NAME
vsphere_copy
ADDITIONAL INFORMATION
Related issue: vmware/pyvmomi#1064
- name: Copy file to datastore using other_system
  community.vmware.vsphere_copy:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    src: /other/local/streamOptimized.vmdk
    datacenter: DC2 Someplace
    datastore: datastore2
    path: disk_imports/streamOptimized.vmdk
    timeout: 360
    diskformat: StreamVmdk

Reviewed-by: Mario Lenz <[email protected]>
Reviewed-by: Alexander Nikitin <[email protected]>
Reviewed-by: Klaas Demter
@Klaas-
Copy link
Author

Klaas- commented Feb 21, 2024

And a small follow up, there seems to be a second issue with python 3.10+ which is creating errors during large put requests ( happens often like 9/10 times - python/cpython#110467 ), this also seems to be happening on 3.9 but not as often :) so now I just use python 3.9 and I do automatic retries if upload fails :)

@Klaas-
Copy link
Author

Klaas- commented Feb 23, 2024

and to document my workaround for the python file upload issue: I now just execute curl, it seems to have a 100% success rate :)

curl -u "user:pass" "https://vsphere.tld/folder/DIRNAME/FILENAME.vmdk?dsName=VxRail-Virtual-SAN-Datastore-UUID&dcPath=DATACENTERNAME&diskFormat=StreamVmdk" -H 'Content-type: application/octet-stream' -T /path/to/local.vmdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants