[one-users] Using Ruby API with OCA gem

Daniel Molina Aranda danmolin at fdi.ucm.es
Mon Nov 29 00:30:56 PST 2010


Hi,

The problem is that the info method returns an OpenNebula error when it
fails. You should change the return statement to:

--8<------
rc = vm_pool.info()

if OpenNebula.is_error?(rc)
     return rc.message
else
     return rc
end
------>8--

I have updated the documentation script [1], if you want to check it.

Hope this helps.

[1] http://www.opennebula.org/documentation:rel2.0:ruby

On 29 November 2010 08:49, KING LABS <kinglabs.in at gmail.com> wrote:

> I have installed ruby oca gem and tried using it with given example script
> at http://www.opennebula.org/documentation:rel2.0:ruby , script executes
> with out any results, it doesnt give me any error even when the user
> credentials given wrong.
>
> also i tried with little modified script based on example script is as
> follows which is giving a error
>
>
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
> #!/usr/bin/env ruby
>
>
> ##############################################################################
> # Required libraries
>
> ##############################################################################
> require 'rubygems'
> require 'oca'
>
> include OpenNebula
>
> # OpenNebula credentials
>
> CREDENTIALS = "oneadmin:7bc8559a8fe509e680562b85c337f170956fcb06"
>
> # XML_RPC endpoint where OpenNebula is listening
>
> ENDPOINT    = "http://192.168.138.230:2633/RPC2"
>
> client = Client.new(CREDENTIALS, ENDPOINT)
>
> vm_pool = VirtualMachinePool.new(client, -1)
>
> puts vm_pool.info()
>
>
> -------------------------------------------------------------------------------------------------------------------------
>
> Output:
>
> king at king-desktop:~$ ruby opennebula_ruby_api.rb
> #<OpenNebula::Error:0x00000002050a80>
> king at king-desktop:~$
>
>
> Few working examples are welcomed.
>
> Regards.
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>


-- 
Daniel Molina, Cloud Technology Engineer/Researcher
DSA Research Group: web http://dsa-research.org and blog
http://blog.dsa-research.org
OpenNebula Open Source Toolkit for Cloud Computing:
http://www.OpenNebula.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20101129/0147eeaa/attachment-0002.htm>


More information about the Users mailing list