VMware {code} Community
hnguyenvmware
Contributor
Contributor

Unable to upload vmx file on esx 4.1

Hello everyone,

I have a stranger error that I was hoping someone could enlighten me on. Basically I'm trying to upload a vmx file via http to my esx server. There is a strange condition where the esx4.1 server will hang on the upload when the folder doesn't exist. This is not the case on my other esx4.0 server where if the folder doesn't exist it's created automatically. The esx4.1 server will accept the file if the folder does exist. Please see the following output of my curl command:

# /usr/bin/curl -S -k -v -u "root:pass" -T "/mnt/backups/temp/vmxtoupload.vmx" --url https://esx40.host.com/folder/myfolder/mytest.vmx?dsName=datastore2
* About to connect() to esx40.host.com port 443
*   Trying 192.168.10.95... connected
* Connected to esx40.host.com (192.168.10.95) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLv2, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Request CERT (13):
SSLv3, TLS handshake, Server finished (14):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Client key exchange (16):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSL connection using AES256-SHA
* Server certificate:
*        subject: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./OU=VMware ESX
Server
Certificate/emailAddress=ssl-certificates@vmware.com/CN=localhost.localdomain/unstructuredName=1228240911,564d7761726520496e632e
*        start date: 2008-12-02 18:01:51 GMT
*        expire date: 2028-02-01 18:01:51 GMT
*        common name: localhost.localdomain (does not match 'esx40.host.com')
*        issuer: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./OU=VMware ESX
Server
Certificate/emailAddress=ssl-certificates@vmware.com/CN=localhost.localdomain/unstructuredName=1228240911,564d7761726520496e632e
* SSL certificate verify result: self signed certificate (18), continuing
anyway.
* Server auth using Basic with user 'root'
> PUT /folder/myfolder/mytest.vmx?dsName=datastore2 HTTP/1.1
> Authorization: Basic cm9vdDp6bUBuZEBxQA==
> User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: esx40.host.com
> Accept: */*
> Content-Length: 2603
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Date: Mon, 25 Oct 2010 14:41:49 GMT
< Set-Cookie: vmware_soap_session="521c3773-a5b4-d8f6-cf50-74fcea963cc8";
Path=/; 
< Connection: close
< Content-Length: 0
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

# /usr/bin/curl -S -k -v -u "root:pass" -T "/mnt/backups/temp/vmxtoupload.vmx" --url https://esx41.host.com/folder/myfolder/mytest.vmx?dsName=datastore2
* About to connect() to esx41.host.com port 443
*   Trying 192.168.10.122... connected
* Connected to esx41.host.com (192.168.10.122) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLv2, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Server finished (14):
SSLv3, TLS handshake, Client key exchange (16):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSL connection using AES256-SHA
* Server certificate:
*        subject: /C=US/ST=California/L=Palo Alto/O=VMware, Inc/OU=VMware ESX
Server Default
Certificate/emailAddress=ssl-certificates@vmware.com/CN=localhost.localdomain/unstructuredName=1281136974,564d7761726520496e632e
*        start date: 2010-08-06 23:22:54 GMT
*        expire date: 2022-02-04 23:22:54 GMT
*        common name: localhost.localdomain (does not match
'esx41.host.com')
*        issuer: /O=VMware Installer
* SSL certificate verify result: unable to get local issuer certificate (20),
continuing anyway.
* Server auth using Basic with user 'root'
> PUT /folder/myfolder/mytest.vmx?dsName=datastore2 HTTP/1.1
> Authorization: Basic cm9vdDp6bUBuZEBxQA==
> User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: esx41.host.com
> Accept: */*
> Content-Length: 2603
> Expect: 100-continue

Reply
0 Kudos
5 Replies
hnguyenvmware
Contributor
Contributor

I've recently looked at fileaccess.pl sample that is included in the vmware-vcli package VMware-vSphere-CLI-4.1.0-254719.i386.tar.gz

It seems even the vmware provided sample is unable to perform a put request.

# time ./fileaccess.pl --url
"https://esx41.host.com/sdk/vimService" --username root --password pass
--operation put --localpath "/root/testfile.txt"
--remotepath "myfolder/mytest.txt" --filetype datastore --datastorename
datastore2 --datacentername ha-datacenter

Copying the file /root/testfile.txt to myfolder/mytest.txt
under datastore datastore2 abd datacenter ha-datacenter
Put operation unsuccessful: response status code 500

real    3m0.765s
user    0m0.326s
sys     0m0.386s

Reply
0 Kudos
lamw
Community Manager
Community Manager

Have you taken a look at vifs which is part of the vCLI, I assume it's using the same method of HTTP get/put.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware VCP3,4

VMware VCAP4-DCA

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
hnguyenvmware
Contributor
Contributor

Thanks William, unfortunately vifs stalls similarly. It does indeed also rely on the same VMware::VIExt module that fileaccess.pl uses thus same PUT request. Looking at the documentation for vifs . It seems PUT in vifs was not designed to create new files?

--put | -p <local_path> <remote_path>
Uploads a file from the machine on which you run the vCLI commands to the ESX/ESXi host. This operation uses HTTP PUT. This command can replace existing host files but cannot create new files.

I do see a --mkdir command which would allow me to kind of hack around the problem. Still doesn't resolve the why PUT works on older versions of esx or that if the creation of new directories isn't allowed on esx4.1 why a proper HTTP header isn't being sent back instead of just waiting till timeout.

Reply
0 Kudos
hnguyenvmware
Contributor
Contributor

Still haven't worked out the original problem but implemented a vifs mkdir hack that works for now.

Reply
0 Kudos
esprinee
Contributor
Contributor

Hi,

So basically you use the curl to create a file, then using PUT to upload the file from local to datastore?

Thanks

Yingchun

Reply
0 Kudos