[one-users] OCCI Interface - HTTP commands

Daniel Molina dmolina at opennebula.org
Tue Mar 22 04:20:41 PDT 2011


I think the problem is the authentication. Would you mind to try using
the OCCI client provided with OpenNebula or curl?

$ occi-compute --url http://localhost:4567 --username <user>
--password <pass> list

or

$ curl -u <user>:<sha1_pass> http://localhost:4567/compute

You can get the sha1_pass using oneuser list.

2011/3/22 João Soares <joaosoares at ua.pt>:
> Hi Daniel,
>
> The output of the log file is the following:
>
> NoMethodError - private method `split' called for nil:NilClass:
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/auth/abstract/request.rb:14:in
> `parts'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/auth/abstract/request.rb:22:in
> `params'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/auth/basic.rb:48:in
> `credentials'
>  /usr/lib/one/ruby/cloud/occi/OCCIServer.rb:66:in `get_client'
>  /usr/lib/one/ruby/cloud/occi/OCCIServer.rb:92:in `get_computes'
>  /usr/lib/one/ruby/cloud/occi/occi-server.rb:101:in `GET /compute'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1125:in `call'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1125:in `compile!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:709:in
> `instance_eval'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:709:in
> `route_eval'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:693:in `route!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:741:in
> `process_route'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:738:in `catch'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:738:in
> `process_route'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:692:in `route!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:691:in `each'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:691:in `route!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:826:in `dispatch!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:619:in `call!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:791:in
> `instance_eval'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:791:in `invoke'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:791:in `catch'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:791:in `invoke'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:619:in `call!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:604:in `call'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/showexceptions.rb:21:in
> `call'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/methodoverride.rb:24:in `call'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/commonlogger.rb:18:in `call'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1237:in `call'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1263:in
> `synchronize'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1237:in `call'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/content_length.rb:13:in `call'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/chunked.rb:15:in `call'
>  /var/lib/gems/1.8/gems/thin-1.2.8/lib/thin/connection.rb:84:in
> `pre_process'
>  /var/lib/gems/1.8/gems/thin-1.2.8/lib/thin/connection.rb:82:in `catch'
>  /var/lib/gems/1.8/gems/thin-1.2.8/lib/thin/connection.rb:82:in
> `pre_process'
>  /var/lib/gems/1.8/gems/thin-1.2.8/lib/thin/connection.rb:57:in `process'
>  /var/lib/gems/1.8/gems/thin-1.2.8/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.8/lib/thin/backends/base.rb:61:in `start'
>  /var/lib/gems/1.8/gems/thin-1.2.8/lib/thin/server.rb:159:in `start'
>  /var/lib/gems/1.8/gems/rack-1.2.2/lib/rack/handler/thin.rb:14:in `run'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/base.rb:1208:in `run!'
>  /var/lib/gems/1.8/gems/sinatra-1.2.0/lib/sinatra/main.rb:25
>  /usr/lib/one/ruby/cloud/occi/occi-server.rb:159
> 127.0.0.1 - - [22/Mar/2011 10:46:24] "GET /compute HTTP/1.1" 500 122391
> 0.1457
>
> ___________________________________________________________________________
>
> Regarding my VM, this is the output...
>
> <VM>
>  <ID>
>  129
>  </ID>
>  <UID>
>  5
>  </UID>
>  <NAME>
>  MyCompute
>  </NAME>
>  <LAST_POLL>
>  1300790571
>  </LAST_POLL>
>  <STATE>
>  3
>  </STATE>
>  <LCM_STATE>
>  3
>  </LCM_STATE>
>  <STIME>
>  1300717277
>  </STIME>
>  <ETIME>
>  0
>  </ETIME>
>  <DEPLOY_ID>
>  one-129
>  </DEPLOY_ID>
>  <MEMORY>
>  65536
>  </MEMORY>
>  <CPU>
>  1
>  </CPU>
>  <NET_TX>
>  0
>  </NET_TX>
>  <NET_RX>
>  7
>  </NET_RX>
>  <LAST_SEQ>
>  0
>  </LAST_SEQ>
>  <TEMPLATE>
>  <CONTEXT>
>   <DATA>
>    <![CDATA[DATA1]]>
>   </DATA>
>   <HOSTNAME>
>    <![CDATA[MAINHOST]]>
>   </HOSTNAME>
>   <TARGET>
>    <![CDATA[hdb]]>
>   </TARGET>
>  </CONTEXT>
>  <CPU>
>   <![CDATA[0.5]]>
>  </CPU>
>  <DISK>
>   <CLONE>
>    <![CDATA[YES]]>
>   </CLONE>
>   <DISK_ID>
>    <![CDATA[0]]>
>   </DISK_ID>
>   <IMAGE>
>    <![CDATA[FEDORA DESKTOP]]>
>   </IMAGE>
>   <IMAGE_ID>
>    <![CDATA[2]]>
>   </IMAGE_ID>
>   <READONLY>
>    <![CDATA[NO]]>
>   </READONLY>
>   <SAVE>
>    <![CDATA[NO]]>
>   </SAVE>
>   <SOURCE>
>
> <![CDATA[/var/lib/one//images/68a84d5700b0dfe79e90717a9de49a926f405a30]]>
>   </SOURCE>
>   <TARGET>
>    <![CDATA[hda]]>
>   </TARGET>
>   <TYPE>
>    <![CDATA[DISK]]>
>   </TYPE>
>  </DISK>
>  <INSTANCE_TYPE>
>   <![CDATA[small]]>
>  </INSTANCE_TYPE>
>  <MEMORY>
>   <![CDATA[64]]>
>  </MEMORY>
>  <NAME>
>   <![CDATA[MyCompute]]>
>  </NAME>
>  <NIC>
>   <BRIDGE>
>    <![CDATA[eth0]]>
>   </BRIDGE>
>   <IP>
>    <![CDATA[192.168.1.12]]>
>   </IP>
>   <MAC>
>    <![CDATA[02:00:c0:a8:01:0c]]>
>   </MAC>
>   <NETWORK>
>    <![CDATA[MyServiceNetwork]]>
>   </NETWORK>
>   <NETWORK_ID>
>    <![CDATA[5]]>
>   </NETWORK_ID>
>  </NIC>
>  <OS>
>   <INITRD>
>    <![CDATA[/boot/initrd.img-2.6.24-28-xen]]>
>   </INITRD>
>   <KERNEL>
>    <![CDATA[/boot/vmlinuz-2.6.24-28-xen]]>
>   </KERNEL>
>  </OS>
>  <VMID>
>   <![CDATA[129]]>
>  </VMID>
>  </TEMPLATE>
>  <HISTORY>
>  <SEQ>
>   0
>  </SEQ>
>  <HOSTNAME>
>   cluster01.dyndns-work.com
>  </HOSTNAME>
>  <HID>
>   32
>  </HID>
>  <STIME>
>   1300717278
>  </STIME>
>  <ETIME>
>   0
>  </ETIME>
>  <PSTIME>
>   1300717278
>  </PSTIME>
>  <PETIME>
>   1300717280
>  </PETIME>
>  <RSTIME>
>   1300717280
>  </RSTIME>
>  <RETIME>
>   0
>  </RETIME>
>  <ESTIME>
>   0
>  </ESTIME>
>  <EETIME>
>   0
>  </EETIME>
>  <REASON>
>   0
>  </REASON>
>  </HISTORY>
> </VM>
>
>
> _____________________________________________________________________
>
> If I do "GET /compute" I get the same output as "GET /compute/".
>
> Thanks,
>
> João
>
> -----Original Message-----
> From: Daniel Molina [mailto:dmolina at opennebula.org]
> Sent: terça-feira, 22 de Março de 2011 10:17
> To: João Soares
> Cc: users at lists.opennebula.org
> Subject: Re: [one-users] OCCI Interface - HTTP commands
>
> Hi,
>
> Comments inline,
>
> 2011/3/21 João Soares <joaosoares at ua.pt>:
>> Hi,
>>
>>
>>
>> I am trying to use the OCCI interface, I am able to launch VMs through the
>> “occi-compute” command, but I am having some issues when trying to use for
>> example the GET request:
>>
>> I create a VM by using the occi-compute which returns me the ID 129. Then:
>>
>>
>>
>> telnet localhost 4567
>>
>>
>>
>> GET /compute/129 HTTP/1.1
>>
>>
>>
>> Trying ::1...
>> Trying 127.0.0.1...
>> Connected to localhost.
>> Escape character is '^]'.
>> GET /compute/129 HTTP/1.1
>>
>> HTTP/1.1 500 Internal Server Error
>> Content-Type: text/html
>> Content-Length: 122449
>> Connection: keep-alive
>> Server: thin 1.2.8 codename Black Keys
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
>>   <title>NoMethodError at /compute/129</title>
>>
>>   <script type="text/javascript">
>>   //<!--
>>   function toggle(id) {
>>     var pre  = document.getElementById("pre-" + id);
>>     var post = document.getElementById("post-" + id);
>>     var context = document.getElementById("context-" + id);
>>
>>     if (pre.style.display == 'block') {
>>       pre.style.display = 'none';
>>       post.style.display = 'none';
>>       context.style.background = "none";
>>     } else {
>>       pre.style.display = 'block';
>>       post.style.display = 'block';
>>       context.style.background = "#fffed9";
>>     }
>>   }
>>
>>   function toggleBacktrace(){
>>
>> ................................................... (continues)……
>>
>>            <td>rack.version</td>
>>            <td class="code"><div>[1, 0]</div></td>
>>          </tr>
>>
>>          <tr>
>>            <td>sinatra.error</td>
>>            <td class="code"><div>#<NoMethodError: private method
>> `split' called for nil:NilClass></div></td>
>>          </tr>
>>
>>       </table>
>>       <div class="clear"></div>
>>     </div> <!-- /RACK ENV -->
>>
>>     <p id="explanation">You're seeing this error because you have
>> enabled the <code>show_exceptions</code> setting.</p>
>>   </div> <!-- /WRAP -->
>>   </body>
>> </html>
>>
>
> Would you mind to send the $ONE_LOCATION/var/occi-server.log file and
> the output of the following command, `onevm show 129 -x`? What
> OpenNebula version are you using?
>
>>
>> On the other hand, if I try:
>>
>>
>> GET /compute/ HTTP/1.1
>>
>> HTTP/1.1 404 Not Found
>> X-Cascade: pass
>> Content-Type: text/html;charset=utf-8
>> Content-Length: 417
>> Connection: keep-alive
>> Server: thin 1.2.8 codename Black Keys
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>>   <style type="text/css">
>>   body { text-align:center;font-family:helvetica,arial;font-size:22px;
>>     color:#888;margin:20px}
>>   #c {margin:0 auto;width:500px;text-align:left}
>>   </style>
>> </head>
>> <body>
>>   <h2>Sinatra doesn't know this ditty.</h2>
>>   <img src='/__sinatra__/404.png'>
>>   <div id="c">
>>     Try this:
>>     <pre>get '/compute/' do
>>   "Hello World"
>> end</pre>
>>   </div>
>> </body>
>> </html>
>>
>>
>
> Try sending the following request "GET /compute" instead of "GET /compute/"?
>
>>
>> I am not fully aware how the interface works so I might be making a silly
>> mistake…any help?
>>
>>
>>
>> Thanks in advanced,
>>
>>
>>
>> João
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opennebula.org
>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>
>>
>
> Regards
>
> --
> Daniel Molina, Cloud Technology Engineer/Researcher
> Major Contributor
> OpenNebula - The Open Source Toolkit for Cloud Computing
> www.OpenNebula.org | dmolina at opennebula.org
>
>



-- 
Daniel Molina, Cloud Technology Engineer/Researcher
Major Contributor
OpenNebula - The Open Source Toolkit for Cloud Computing
www.OpenNebula.org | dmolina at opennebula.org



More information about the Users mailing list