VMware

This Question is Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
5 Replies Last post: Aug 13, 2009 6:26 AM by bob54321  

403 forbidden status code when trying to PUT vmdks posted: Jul 4, 2009 8:51 AM

Click to view bob54321's profile Lurker 3 posts since
Jul 4, 2009
Hi,

I'm trying to upload a VM in an ovf+vmdk file format via the webservices SDK to a vcenter/esx and am running into some issues. Heres a brief description of what is being done:

  • use the com.vmware.vim25.OvfCreateImportSpecParams method with a VM name, the ESX info, and network mappings
  • the come.vmwarevim25.OvfCreateImportSpecResult that comes back looks ok (no warnings), except all the OvfFileItems have create = false (possibly a sign of something wrong right here)
  • we then go on to create a HttpNfcLease via the importVApp command, and wait on it properly as per the api programming guide - i believe all this works fine
  • when we iterate over the HttpNfcLeaseDeviceUrl.getUrls() and attempt to PUT the content to them, we get the 403's.

In the vpx.log file on the esx's we get the following errors when we try to do this:

2009-07-03 15:22:17.751 0x16eb1b90 info 'HttpNfcServer' DiskUploadWorker PUT request /vmfs/volumes/4a23c7fd-05389109-b84c-0022192b1768/bob17/bob17.vmdk (/nfc/13794651-5df7-49ae-ab1f-e96dc543cdeb/disk-0.vmdk)
2009-07-03 15:22:17.752 0x16eb1b90 info 'HttpNfcServer' DiskUploadWorker File exists, overwrite not allowed: /vmfs/volumes/4a23c7fd-05389109-b84c-0022192b1768/bob17/bob17.vmdk

So obviously something in the import spec or ovf needs to convince ESX that WE actually want to overwrite these files, but i can't figure out what that is. If i pause my code right before the upload, delete all the vmdk files from the ESX, the PUT will succeed, and the VM upload will be successful.

Any tips or points would be appreciated - thanks!

Bob
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
You may want to provide the snippet of code you're using, also it sounds like the issue is you're importing a VM that already exists, specifically duplicated the VMDK(s). Have you tried to provide a different name and see if you get the same error?

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

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

Click to view sthakkar's profile Novice 9 posts since
Aug 7, 2009
Hi there,

I was doing a similar importVapp operation in java as well. How did you go about creating the import spec?

I have been trying to create mine by reading in the ovf file into a string buffer and then subsequently calling:

OvfCreateImportSpecParams cisp = new OvfCreateImportSpecParams();
cisp.setNetworkMapping(null);
cisp.setPropertyMapping(null);
cisp.setIpProtocol("");
cisp.setIpAllocationPolicy("");
cisp.setHostSystem(host.getMOR());
cisp.setEntityName("autovm");
cisp.setLocale("");
OvfCreateImportSpecResult is = om.createImportSpec(strContent, rp, dc.getDatastores()[1], cisp); //where strContent is the ovf data
HttpNfcLease nfcLease = rp.importVApp(is.getImportSpec(), dcVMfolder, host);

I was trying to create the import spec to pass to importVapp but was getting the following error. Did you encounter anything similar?

java.rmi.RemoteException: VI SDK invoke exception:org.dom4j.DocumentException: null Nested exception: null
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:176)
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:119)
at com.vmware.vim25.ws.VimStub.createImportSpec(VimStub.java:1097)
at com.vmware.vim25.mo.OvfManager.createImportSpec(OvfManager.java:69)
<snip>

I've tried escaping the xml (which didn't make much sense) but I read about the error in another forum. As expected, it didn't affect much. I've also double checked my ovf to verify its xml validity.

Does anyone have any insight into what could be causing this?

Thanks in advance!
Click to view tos2k's profile Expert 307 posts since
May 11, 2007
Two questions, no answers :-)

1) Why dont you delete all the files from within your app, if things work perfectly when deleting the files manually?
2) Do you run your app against vCenter? If so, try to run it against ESX directly, and if there is data, run it throught that ESX that "owns" the data.

Tos2k

Developer Social Media

Communities