<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>AW: [one-users] OCCI: multipart POST request with java-client</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hello Tino.<BR>
<BR>
The output of $ONE_LOCATION/var/occi-server.log for the multipart POST request:<BR>
<BR>
RuntimeError - Hash is not a valid input stream.  It must walk<BR>
like either a String, an IO, or a Source.:<BR>
 /usr/lib/ruby/1.8/rexml/source.rb:21:in `create_from'<BR>
 /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream='<BR>
 /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'<BR>
 /var/lib/gems/1.8/gems/crack-0.1.7/lib/crack/xml.rb:191:in `new'<BR>
 /var/lib/gems/1.8/gems/crack-0.1.7/lib/crack/xml.rb:191:in `parse'<BR>
 /srv/cloud/one/lib/ruby/cloud/occi/OCCIServer.rb:285:in `post_storage'<BR>
 /srv/cloud/one/lib/ruby/cloud/occi/occi-server.rb:113:in `POST /storage'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `call'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `route'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `route!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `route!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `each'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:601:in `dispatch!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:399:in `call'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/showexceptions.rb:24:in `call'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/commonlogger.rb:18:in `call'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1005:in `synchronize'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in `call'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/chunked.rb:15:in `call'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:76:in `pre_process'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:74:in `catch'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:74:in `pre_process'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:57:in `process'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:42:in `receive_data'<BR>
 /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'<BR>
 /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/backends/base.rb:57:in `start'<BR>
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/server.rb:156:in `start'<BR>
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/thin.rb:14:in `run'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:946:in `run!'<BR>
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/main.rb:25<BR>
 /srv/cloud/one/lib/ruby/cloud/occi/occi-server.rb:156<BR>
<BR>
<BR>
<BR>
best regards<BR>
Marco<BR>
<BR>
-----Ursprüngliche Nachricht-----<BR>
Von: tinova79@gmail.com im Auftrag von Tino Vazquez<BR>
Gesendet: Mo 30.08.2010 18:44<BR>
An: Strutz, Marco<BR>
Cc: users@lists.opennebula.org<BR>
Betreff: Re: [one-users] OCCI: multipart POST request with java-client<BR>
<BR>
Hi,<BR>
<BR>
My apologies, I meant $ONE_LOCATION/var/occi-server.log.<BR>
<BR>
Regards,<BR>
<BR>
-Tino<BR>
<BR>
--<BR>
Constantino Vázquez Blanco | dsa-research.org/tinova<BR>
Virtualization Technology Engineer / Researcher<BR>
OpenNebula Toolkit | opennebula.org<BR>
<BR>
<BR>
<BR>
On Mon, Aug 30, 2010 at 6:36 PM, Tino Vazquez <tinova@fdi.ucm.es> wrote:<BR>
> Dear Marco,<BR>
><BR>
> Can you please send the contents of $ONE_LOCATION/var/econe-server.log?<BR>
><BR>
> Regards,<BR>
><BR>
> -Tino<BR>
><BR>
> --<BR>
> Constantino Vázquez Blanco | dsa-research.org/tinova<BR>
> Virtualization Technology Engineer / Researcher<BR>
> OpenNebula Toolkit | opennebula.org<BR>
><BR>
><BR>
><BR>
> On Wed, Aug 11, 2010 at 3:19 PM, Strutz, Marco<BR>
> <marco.strutz@fokus.fraunhofer.de> wrote:<BR>
>> Hi everyone.<BR>
>><BR>
>><BR>
>><BR>
>> I want to use the opennebula occi interface (.../storage) to upload images<BR>
>> to the repository (/srv/cloud/images).<BR>
>><BR>
>> But instead of using the ruby-occi-client (occi-storage create xmlfile) I<BR>
>> want to do test it with a  java client.<BR>
>><BR>
>><BR>
>><BR>
>> The multipart-upload seems to work but as response I get the following error<BR>
>> message (short version, long version please find attached<BR>
>> [occiUploadErrorMessage.html]):<BR>
>><BR>
>><BR>
>><BR>
>> "RuntimeError at /storage<BR>
>><BR>
>> Hash is not a valid input stream. It must walk like either a String, an IO,<BR>
>> or a Source.<BR>
>><BR>
>>     * file: source.rb<BR>
>><BR>
>>     * location: create_from<BR>
>><BR>
>>     * line: 21"<BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>> Seems to be a parsing problem with the xml configuration of the request?<BR>
>><BR>
>> But if I use the same xml-configuration with "occi-storage create xmlfile"<BR>
>> then all works fine.<BR>
>><BR>
>><BR>
>><BR>
>> Any suggestions? Would be really appreciate it.<BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>> Thanks<BR>
>><BR>
>> Marco<BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>> -----------------------<BR>
>><BR>
>><BR>
>><BR>
>> the config:<BR>
>><BR>
>> - OpenNebula v1.4<BR>
>><BR>
>> - as java html client I'm using "apache.commons.httpclient" (v3.1).<BR>
>><BR>
>> - occiserver endpoint: <A HREF="http://occi.opennebula.cloud:4567/storage">http://occi.opennebula.cloud:4567/storage</A><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>><BR>
>> the java html multipart occi client<BR>
>><BR>
>> (...)<BR>
>><BR>
>> //prepare xml configuration<BR>
>><BR>
>> file = new File("/tmp/ttyLinux");<BR>
>><BR>
>> xmlConfiguration = "<DISK>      <NAME>testfile_ttyLinux</NAME><BR>
>> <URL><A HREF="file:////tmp/ttyLinux.img">file:////tmp/ttyLinux.img</A></URL></DISK>";<BR>
>><BR>
>> image = new FilePart("file", file);<BR>
>><BR>
>> configurationPart = new StringPart("occixml", xmlConfiguration);<BR>
>><BR>
>><BR>
>><BR>
>> //create multiparts<BR>
>><BR>
>> Part[] parts =     { image, configurationPart };<BR>
>><BR>
>> filePost = new PostMethod("<A HREF="http://occi.opennebula.cloud:4567/storage">http://occi.opennebula.cloud:4567/storage</A>";<BR>
>><BR>
>> filePost.setRequestEntity(new MultipartRequestEntity(multiParts,<BR>
>> filePost.getParams()));<BR>
>><BR>
>><BR>
>><BR>
>> //load client<BR>
>><BR>
>> client = new HttpClient();<BR>
>><BR>
>> client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);<BR>
>><BR>
>><BR>
>><BR>
>> //set credentials<BR>
>><BR>
>> client.getParams().setAuthenticationPreemptive(true); //enable Preemptive<BR>
>> Authentication<BR>
>><BR>
>> Credentials defaultcreds = new UsernamePasswordCredentials(authUserName,<BR>
>> authPassword);<BR>
>><BR>
>> AuthScope authScope = new AuthScope(uri.getHost(), uri.getPort(),<BR>
>> AuthScope.ANY_REALM);<BR>
>><BR>
>> client.getState().setCredentials(authScope, defaultcreds);<BR>
>><BR>
>><BR>
>><BR>
>> //do post request<BR>
>><BR>
>> client.executeMethod(filePost);<BR>
>><BR>
>> response = filePost.getResponseBodyAsString();<BR>
>><BR>
>> (...)<BR>
>><BR>
>> _______________________________________________<BR>
>> Users mailing list<BR>
>> Users@lists.opennebula.org<BR>
>> <A HREF="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</A><BR>
>><BR>
>><BR>
><BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>