Thursday, August 4, 2011

Uploading the files to the VMWare ESXi server

Every now and then I need to upload the stuff like an ISO image to my ESXi server.
Since I do not use windows, my only remaining option is the CLI - which is big and clunky. However, today I digged a bit and after reading the CLI tools source realized that uploading the file onto an ESXi host is trivially simple:
  1. Browse the datastores till you get to the correct place, take that URL and append the target file name.
  2. perform the HTTP PUT request for that URL, supplying the data.
This way, the only tool you need to upload the files to VMWare ESXi really is curl:
curl -k -X PUT --data-binary @IMAGE.ISO 'https://user:pass@host/folder/FOLDERNAME/IMAGE.ISO?dcPath=DCNAME&dsName=DATASTORE'
EDIT:
The above command is a problem if the files you are uploading are large (say, a VMDK or a DVD image), and the machine you are working on is not memory-rich. You will observe the error message from curl "curl: option --data-binary: out of memory". A better approach seems to be to use "-T" option, which allows to specify the file name to upload:

curl -k -X PUT -T IMAGE.ISO 'https://user:pass@host/folder/FOLDERNAME/IMAGE.ISO?dcPath=DCNAME&dsName=DATASTORE'

No comments: