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

Strutz, Marco marco.strutz at fokus.fraunhofer.de
Mon Aug 30 13:11:44 PDT 2010


Hello Tino.

The output of $ONE_LOCATION/var/occi-server.log for the multipart POST request:

RuntimeError - Hash is not a valid input stream.  It must walk 
like either a String, an IO, or a Source.:
 /usr/lib/ruby/1.8/rexml/source.rb:21:in `create_from'
 /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream='
 /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'
 /var/lib/gems/1.8/gems/crack-0.1.7/lib/crack/xml.rb:191:in `new'
 /var/lib/gems/1.8/gems/crack-0.1.7/lib/crack/xml.rb:191:in `parse'
 /srv/cloud/one/lib/ruby/cloud/occi/OCCIServer.rb:285:in `post_storage'
 /srv/cloud/one/lib/ruby/cloud/occi/occi-server.rb:113:in `POST /storage'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `call'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `route'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `route!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `route!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `each'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:601:in `dispatch!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:399:in `call'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/showexceptions.rb:24:in `call'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/commonlogger.rb:18:in `call'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1005:in `synchronize'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in `call'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/chunked.rb:15:in `call'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:76:in `pre_process'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:74:in `catch'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:74:in `pre_process'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:57:in `process'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:42:in `receive_data'
 /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
 /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/backends/base.rb:57:in `start'
 /var/lib/gems/1.8/gems/thin-1.2.7/lib/thin/server.rb:156:in `start'
 /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/thin.rb:14:in `run'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:946:in `run!'
 /var/lib/gems/1.8/gems/sinatra-1.0/lib/sinatra/main.rb:25
 /srv/cloud/one/lib/ruby/cloud/occi/occi-server.rb:156



best regards
Marco

-----Ursprüngliche Nachricht-----
Von: tinova79 at gmail.com im Auftrag von Tino Vazquez
Gesendet: Mo 30.08.2010 18:44
An: Strutz, Marco
Cc: users at lists.opennebula.org
Betreff: Re: [one-users] OCCI: multipart POST request with java-client
 
Hi,

My apologies, I meant $ONE_LOCATION/var/occi-server.log.

Regards,

-Tino

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



On Mon, Aug 30, 2010 at 6:36 PM, Tino Vazquez <tinova at fdi.ucm.es> wrote:
> 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
>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20100830/44f8b3bf/attachment-0003.htm>


More information about the Users mailing list