Thank you I am getting the following error when I used the updated example, while when I am using xmlrpc script its working .<br><br>king@king-desktop:~$ ruby opennebula_ruby_api.rb <br>opennebula_ruby_api.rb:22:in `<main>': unexpected return (LocalJumpError)<br>
<br>------------------------------------------------------------------------<br><br>xmlrpc using ruby:<br>---------------------------<br><br>#!/usr/bin/env ruby<br>require 'xmlrpc/client'<br>require 'pp'<br>
server_url="<a href="http://192.168.138.230:2633/RPC2">http://192.168.138.230:2633/RPC2</a>"<br>server=XMLRPC::Client.new2(server_url)<br>vmpool = server.call("<a href="http://one.vmpool.info">one.vmpool.info</a>","oneadmin:7bc8559a8fe509e680562b85c337f170956fcb06",-1)<br>
pp vmpool<br><br>OUTPUT:<br>----------------<br><br>king@king-desktop:~$ ruby opennebula.rb <br>[true,<br> "<VM_POOL><VM><ID>28</ID><UID>0</UID><USERNAME>oneadmin</USERNAME><NAME>test3</NAME><LAST_POLL>1291025778</LAST_POLL><STATE>3</STATE><LCM_STATE>3</LCM_STATE><STIME>1290752714</STIME><ETIME>0</ETIME><DEPLOY_ID>one-28</DEPLOY_ID><MEMORY>131072</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><DISK><CLONE><![CDATA[YES]]></CLONE><DISK_ID><![CDATA[0]]></DISK_ID><IMAGE><![CDATA[UbuntuApp]]></IMAGE><IMAGE_ID><![CDATA[1]]></IMAGE_ID><READONLY><![CDATA[NO]]></READONLY><SAVE><![CDATA[NO]]></SAVE><SOURCE><![CDATA[/var/lib/one//images/2a4e357eac97900cc1eedd570eaa87050e11aa98]]></SOURCE><TARGET><![CDATA[hda]]></TARGET><TYPE><![CDATA[DISK]]></TYPE></DISK><GRAPHICS><LISTEN><![CDATA[0.0.0.0]]></LISTEN><PORT><![CDATA[17]]></PORT><TYPE><![CDATA[vnc]]></TYPE></GRAPHICS><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[test3]]></NAME><NIC><BRIDGE><![CDATA[br0]]></BRIDGE><IP><![CDATA[192.168.138.1]]></IP><MAC><![CDATA[02:00:c0:a8:8a:01]]></MAC><NETWORK><![CDATA[RANGED]]></NETWORK><NETWORK_ID><![CDATA[2]]></NETWORK_ID></NIC><VMID><![CDATA[28]]></VMID></TEMPLATE><HISTORY><SEQ>0</SEQ><HOSTNAME>192.168.138.231</HOSTNAME><HID>0</HID><STIME>1290752718</STIME><ETIME>0</ETIME><PSTIME>1290752718</PSTIME><PETIME>1290752770</PETIME><RSTIME>1290752770</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>29</ID><UID>0</UID><USERNAME>oneadmin</USERNAME><NAME>test4</NAME><LAST_POLL>1291025838</LAST_POLL><STATE>3</STATE><LCM_STATE>3</LCM_STATE><STIME>1291008373</STIME><ETIME>0</ETIME><DEPLOY_ID>one-29</DEPLOY_ID><MEMORY>131072</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><DISK><CLONE><![CDATA[YES]]></CLONE><DISK_ID><![CDATA[0]]></DISK_ID><IMAGE><![CDATA[UbuntuApp]]></IMAGE><IMAGE_ID><![CDATA[1]]></IMAGE_ID><READONLY><![CDATA[NO]]></READONLY><SAVE><![CDATA[NO]]></SAVE><SOURCE><![CDATA[/var/lib/one//images/2a4e357eac97900cc1eedd570eaa87050e11aa98]]></SOURCE><TARGET><![CDATA[hda]]></TARGET><TYPE><![CDATA[DISK]]></TYPE></DISK><GRAPHICS><LISTEN><![CDATA[0.0.0.0]]></LISTEN><PORT><![CDATA[18]]></PORT><TYPE><![CDATA[vnc]]></TYPE></GRAPHICS><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[test4]]></NAME><NIC><BRIDGE><![CDATA[br0]]></BRIDGE><IP><![CDATA[192.168.138.2]]></IP><MAC><![CDATA[02:00:c0:a8:8a:02]]></MAC><NETWORK><![CDATA[RANGED]]></NETWORK><NETWORK_ID><![CDATA[2]]></NETWORK_ID></NIC><VMID><![CDATA[29]]></VMID></TEMPLATE><HISTORY><SEQ>0</SEQ><HOSTNAME>192.168.138.231</HOSTNAME><HID>0</HID><STIME>1291008378</STIME><ETIME>0</ETIME><PSTIME>1291008378</PSTIME><PETIME>1291008429</PETIME><RSTIME>1291008429</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>"]<br>
king@king-desktop:~$ <br>----------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br><br>I am just tying to understand API. I am new to ruby/opennebula/xml .... can you please give me the example for the same above script using ruby api ... that should help me.<br>
<br>Regards<br><br><br><div class="gmail_quote">On Mon, Nov 29, 2010 at 2:00 PM, Daniel Molina Aranda <span dir="ltr"><<a href="mailto:danmolin@fdi.ucm.es">danmolin@fdi.ucm.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<div><br></div><div>The problem is that the info method returns an OpenNebula error when it fails. You should change the return statement to:</div><div><br></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">--8<------</span></div>
<div>rc = <a href="http://vm_pool.info/" target="_blank">vm_pool.info</a>()</div><div><br></div><div>if OpenNebula.is_error?(rc)</div><div> return rc.message</div><div>else</div><div> return rc</div><div>end<br><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">------>8--</span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">I have updated the documentation script [1], if you want to check it.</span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">Hope this helps.</span></div>
<div><br></div><div>[1] <a href="http://www.opennebula.org/documentation:rel2.0:ruby" target="_blank">http://www.opennebula.org/documentation:rel2.0:ruby</a></div><div><br><div class="gmail_quote"><div><div></div><div class="h5">
On 29 November 2010 08:49, KING LABS <span dir="ltr"><<a href="http://kinglabs.in" target="_blank">kinglabs.in</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">I have installed ruby oca gem and tried using it with given example script at <a href="http://www.opennebula.org/documentation:rel2.0:ruby" target="_blank">http://www.opennebula.org/documentation:rel2.0:ruby</a> , script executes with out any results, it doesnt give me any error even when the user credentials given wrong.<br>
<br>also i tried with little modified script based on example script is as follows which is giving a error<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>#!/usr/bin/env ruby<br> <br>##############################################################################<br># Required libraries<br>##############################################################################<br>
require 'rubygems'<br>
require 'oca'<br> <br>include OpenNebula<br> <br># OpenNebula credentials<br><br>CREDENTIALS = "oneadmin:7bc8559a8fe509e680562b85c337f170956fcb06"<br><br># XML_RPC endpoint where OpenNebula is listening<br>
<br>ENDPOINT = "<a href="http://192.168.138.230:2633/RPC2" target="_blank">http://192.168.138.230:2633/RPC2</a>"<br> <br>client = Client.new(CREDENTIALS, ENDPOINT)<br> <br>vm_pool = VirtualMachinePool.new(client, -1)<br>
<br>
puts <a href="http://vm_pool.info" target="_blank">vm_pool.info</a>()<br><br>-------------------------------------------------------------------------------------------------------------------------<br><br>Output:<br><br>
king@king-desktop:~$ ruby opennebula_ruby_api.rb <br>
#<OpenNebula::Error:0x00000002050a80><br>king@king-desktop:~$ <br><br><br>Few working examples are welcomed.<br><br>Regards.<br>
<br></div></div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Daniel Molina, Cloud Technology Engineer/Researcher<br>DSA Research Group: web <a href="http://dsa-research.org" target="_blank">http://dsa-research.org</a> and blog <a href="http://blog.dsa-research.org" target="_blank">http://blog.dsa-research.org</a><br>
OpenNebula Open Source Toolkit for Cloud Computing: <a href="http://www.OpenNebula.org" target="_blank">http://www.OpenNebula.org</a><br>
</div>
</blockquote></div><br>