I am trying to use the documentation as contained in this vmware doc: vSphere Documentation Center
When I connect to vCenter using the following.. "https://<server_ip>/folder/file_transfer/myiso.iso?dcPath=DC&dsName=DS" , it takes over an hour and a half to copy the 4GB iso to the datastore. Using the vCenter Client Datastore Browser, it only take 4-5 minutes. I also enabled the ability to upload to vCenter by enabling http in the config files and see the same results as with the Datastore Browser (4-5 minutes). This is not an option since credentials will be given over http. So, it's the SSL on vCenter that is the bottleneck. I don't have access to the host credentials only the vCenter ones, so I can't directly upload to the host.
The interesting thing in all of this is I found out how the datastore browser works and I can't find any docs on how to use the same service or wsdls or apis. When I trace the upload in the datastore browser. I see it authenticate over Https and then the vCenter sdk service provides SOAP packets containing objects such as NCFFileManagment and a namespace of "internalvim25". The trace shows that the vCenter server will reply and give the DS browser a host, a port, and a location to put the files up on the host. This is all done over a service they call NFC on port 902 on the host not vCenter.
My problem is there is no documentation on how to use this NFC service or the internalvim25 (although the name suggests it's not public)
Does any one know how to allow files to be uploaded over http after you are authenticated over SSL? Here's some of my sample code that is currently very, very slow....
URL url = new URL("https://<serverip>/folder/file_transfer/myiso2.iso?dcPath=Public-vms&dsName=jb-vmware-share"); String fileName = "C:\\Users\\D\\Downloads\\big\\big1\\big.iso"; HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); String authString = "Administrator:*****"; String encoding = Base64.encode(authString.getBytes()); conn.setRequestProperty("Authorization", "Basic " + encoding); conn.setRequestProperty("Host", "name.lab.com"); conn.setRequestProperty("Host", "server.test"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("User-Agent", "Agent/2.2.2"); File file = new File(fileName); if (!file.exists()) { System.out.println("not found " + fileName); return; } if (file.isDirectory()) { System.out.println("not files"); return; } long fileSize = file.length(); conn.setRequestProperty("Content-Length", Long.toString(fileSize)); conn.setFixedLengthStreamingMode(fileSize); conn.setRequestMethod("PUT"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); FileInputStream in = new FileInputStream(fileName); byte[] buf = new byte[2097152]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); }
I appreciate any help you all can offer.