[one-users] OCCI: multipart POST request with java-client

Tino Vazquez tinova at fdi.ucm.es
Mon Aug 30 09:36:04 PDT 2010


Dear Marco,

Can you please send the contents of $ONE_LOCATION/var/econe-server.log?

Regards,

-Tino

--
Constantino Vázquez Blanco | dsa-research.org/tinova
Virtualization Technology Engineer / Researcher
OpenNebula Toolkit | opennebula.org



On Wed, Aug 11, 2010 at 3:19 PM, Strutz, Marco
<marco.strutz at fokus.fraunhofer.de> wrote:
> Hi everyone.
>
>
>
> I want to use the opennebula occi interface (.../storage) to upload images
> to the repository (/srv/cloud/images).
>
> But instead of using the ruby-occi-client (occi-storage create xmlfile) I
> want to do test it with a  java client.
>
>
>
> The multipart-upload seems to work but as response I get the following error
> message (short version, long version please find attached
> [occiUploadErrorMessage.html]):
>
>
>
> "RuntimeError at /storage
>
> Hash is not a valid input stream. It must walk like either a String, an IO,
> or a Source.
>
>     * file: source.rb
>
>     * location: create_from
>
>     * line: 21"
>
>
>
>
>
> Seems to be a parsing problem with the xml configuration of the request?
>
> But if I use the same xml-configuration with "occi-storage create xmlfile"
> then all works fine.
>
>
>
> Any suggestions? Would be really appreciate it.
>
>
>
>
>
>
>
> Thanks
>
> Marco
>
>
>
>
>
>
>
> -----------------------
>
>
>
> the config:
>
> - OpenNebula v1.4
>
> - as java html client I'm using "apache.commons.httpclient" (v3.1).
>
> - occiserver endpoint: http://occi.opennebula.cloud:4567/storage
>
>
>
>
>
> the java html multipart occi client
>
> (...)
>
> //prepare xml configuration
>
> file = new File("/tmp/ttyLinux");
>
> xmlConfiguration = "<DISK>      <NAME>testfile_ttyLinux</NAME>
> <URL>file:////tmp/ttyLinux.img</URL></DISK>";
>
> image = new FilePart("file", file);
>
> configurationPart = new StringPart("occixml", xmlConfiguration);
>
>
>
> //create multiparts
>
> Part[] parts =     { image, configurationPart };
>
> filePost = new PostMethod(“http://occi.opennebula.cloud:4567/storage”;
>
> filePost.setRequestEntity(new MultipartRequestEntity(multiParts,
> filePost.getParams()));
>
>
>
> //load client
>
> client = new HttpClient();
>
> client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>
>
>
> //set credentials
>
> client.getParams().setAuthenticationPreemptive(true); //enable Preemptive
> Authentication
>
> Credentials defaultcreds = new UsernamePasswordCredentials(authUserName,
> authPassword);
>
> AuthScope authScope = new AuthScope(uri.getHost(), uri.getPort(),
> AuthScope.ANY_REALM);
>
> client.getState().setCredentials(authScope, defaultcreds);
>
>
>
> //do post request
>
> client.executeMethod(filePost);
>
> response = filePost.getResponseBodyAsString();
>
> (...)
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>



More information about the Users mailing list