[one-users] OCCI: multipart POST request with java-client
Strutz, Marco
marco.strutz at fokus.fraunhofer.de
Fri Sep 10 04:51:41 PDT 2010
Hi Tino.
I have installed the beta of Opennebula 2.0 and tested the OCCI-Server again.
It seems the issue still exists. I have tried different programs (my java client, curl and occi-storage) with different options.
The good news: occi-storage command still works fine! (-:
(occi-storage create xmlConfiguration.xml)
The bad: the others doing not so good:
The occi-server is up and running. I have added a ttylinux to the image repository (via oneimage) and printed out the occi-server-representation:
$curl -u oneadmin:[sha1-password] http://virtualbox.one.de:4567/storage
<STORAGE COLLECTION>
<STORAGE href=http://virtualbox.one.de:4567/storage/0 name="testfile_ttyLinux"/>
</STORAGE_COLLECTION>
Afterwards it failed to add some more files to the storage-endpoint via occi:
$occi-storage -M create xmlConfiguration.xml
#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>
[ImageAllocate] Error trying to CREATE IMAGE Returned error code [-1].
$cat occi-server.log
(...)
127.0.0.1 - - [10/Sep/2010 12:18:24] "POST /storage HTTP/1.1" 500 70 0.5345
$curl -u oneadmin:[sha1-password] -F occixml=@/tmp/xmlConfiguration.xml -F file=@/tmp/ttylinux.img http://virtualbox.one.de:4567/storage -o one2_curlA.html
$curl -u oneadmin:[sha1-password] -F occixml=</tmp/xmlConfiguration.xml -F file=@/tmp/ttylinux.img http://virtualbox.one.de:4567/storage -o one2_curlB.html
$cat one2_curlB.html
Wrong type!
Any ideas? Do I have to change any content-types for the multipart post-request? Should I try different options? What would you suggest?
Please let me know If you need more log-files..
Thanks
Marco
-----Original Message-----
From: tinova79 at gmail.com [mailto:tinova79 at gmail.com] On Behalf Of Tino Vazquez
Sent: Tuesday, September 07, 2010 12:50 PM
To: Strutz, Marco
Cc: users at lists.opennebula.org
Subject: Re: [one-users] OCCI: multipart POST request with java-client
Hi Marco,
We have greatly improved the code of the OCCI server in the latest
v2.0 release.
Would you mind trying this out to see if the problem appears more clearly in the logs?
Regards,
-Tino
--
Constantino Vázquez Blanco | dsa-research.org/tinova Virtualization Technology Engineer / Researcher OpenNebula Toolkit | opennebula.org
On Mon, Aug 30, 2010 at 10:11 PM, Strutz, Marco <marco.strutz at fokus.fraunhofer.de> wrote:
> 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(5
>>> 000);
>>>
>>>
>>>
>>> //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 --------------
A non-text attachment was scrubbed...
Name: one2_curlA_occi-server.log
Type: application/octet-stream
Size: 7667 bytes
Desc: one2_curlA_occi-server.log
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20100910/d3df493b/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20100910/d3df493b/attachment-0001.html>
More information about the Users
mailing list