Thanks Carlos!<br><br>I got it!<br><br>I attach two examples in python and perl:<br><br><b><a href="http://prueba-xml-rpc.pl">prueba-xml-rpc.pl</a></b><br><br>#!/usr/bin/perl<br><br>use warnings;<br>use strict;<br>use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);<br>
use Frontier::Client;<br><br># --------------------------------------------------------------------------------------#<br><br>my $server_url = "<a href="http://localhost:2633/RPC2">http://localhost:2633/RPC2</a>";<br>
my $user = "oneadmin";<br>my $password = "oneadmin";<br>my $server= Frontier::Client->new(url => $server_url);<br><br>$password = sha1_hex($password);<br><br>my $one_auth = "$user:$password";<br>
<br># ---------------------------------------------------------------------------------------#<br><br>&getVMInfo(37);<br><br># ---------------------------------------------------------------------------------------#<br>
<br>sub getVMInfo {<br> my $id;<br> ($id) = @_; <br><br> my @response = $server->call('<a href="http://one.vm.info">one.vm.info</a>', $one_auth, $id);<br> <br> foreach my $line (@response) {<br>
print $line->[1], "\n";<br> }<br><br>}<br><br><br><br><br><br><b>prueba-xml-rpc.py</b><br><br>#! /usr/bin/python<br>#<br># based on script of Chris Usher June 2009<br><br>import xmlrpclib<br>
import re<br>
import hashlib<br><br>server = '<a href="http://localhost:2633/RPC2">http://localhost:2633/RPC2</a>'<br>user = "oneadmin"<br>password = "oneadmin"<br>password = hashlib.sha1(password).hexdigest()<br>
one_auth = '{0}:{1}'.format(user, password)<br><br>def getProxy():<br> return xmlrpclib.ServerProxy(server)<br><br>def getVMInfo(id):<br> response = getProxy().<a href="http://one.vm.info">one.vm.info</a>(one_auth,id)<br>
if response[0]:<br> return response[1]<br> else:<br> raise Exception(response[1])<br><br>print getVMInfo(37)<br><br><br><br><br>Gracias<br>Miguel<br><br><br><br><br><div class="gmail_quote">El 8 de agosto de 2011 12:10, Carlos Martín Sánchez <span dir="ltr"><<a href="mailto:cmartin@opennebula.org">cmartin@opennebula.org</a>></span> escribió:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Miguel,<br>
<br>
I'm sure you can get an idea reading the python OCA bindings [1] code.<br>
<br>
Regards.<br>
<br>
[1] <a href="http://opennebula.org/software:ecosystem:python_bindings" target="_blank">http://opennebula.org/software:ecosystem:python_bindings</a><br>
<br>
--<br>
Carlos Martín, MSc<br>
Project Major Contributor<br>
OpenNebula - The Open Source Toolkit for Cloud Computing<br>
<a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org">cmartin@opennebula.org</a><br>
<div><div></div><div class="h5"><br>
<br>
<br>
On Sun, Aug 7, 2011 at 11:13 PM, Miguel Morillo Iruela<br>
<<a href="mailto:miguel.morillo@gmail.com">miguel.morillo@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I'm trying to deploy and get information of some VM deployed with ONE, I'd<br>
> like to obtain this information with the XML-RPC API, when I try to invoice<br>
> some commands I always get an authentication error:<br>
><br>
> The example script:<br>
><br>
> #!/usr/bin/python<br>
><br>
> import xmlrpclib<br>
> import os<br>
><br>
> #server=xmlrpclib.ServerProxy('<a href="http://localhost:2633/RPC2" target="_blank">http://localhost:2633/RPC2</a>')<br>
> server=xmlrpclib.ServerProxy('http://oneadmin:7bc8559a8fe509e680562b85c337f170956fcb06@localhost:2633/RPC2')<br>
><br>
> #-------Get Info about VM ----------<br>
> vm=37<br>
> vminfo=<a href="http://server.one.vm.info" target="_blank">server.one.vm.info</a>("",vm)<br>
> print vminfo[1]<br>
><br>
><br>
><br>
> oneadmin@opennebula:~$ ./test.py<br>
> [VirtualMachineInfo] User couldn't be authenticated, aborting call.<br>
><br>
><br>
> one_xmlrpc.log<br>
> .<br>
> .<br>
> .<br>
> <a href="http://127.0.0.1:18874" target="_blank">127.0.0.1:18874</a> - no_user - [07/Aug/2011:23:07:16 -0200] "POST" 200 2097<br>
> <a href="http://127.0.0.1:18874" target="_blank">127.0.0.1:18874</a> - no_user - [07/Aug/2011:23:07:16 -0200] "POST" 200 468<br>
> <a href="http://127.0.0.1:18874" target="_blank">127.0.0.1:18874</a> - no_user - [07/Aug/2011:23:07:46 -0200] "POST" 200 2097<br>
> <a href="http://127.0.0.1:18874" target="_blank">127.0.0.1:18874</a> - no_user - [07/Aug/2011:23:07:46 -0200] "POST" 200 468<br>
><br>
><br>
><br>
> If some body knows how to connect with python or perl and the correct way to<br>
> authenticate the connection. I have tested with username/password and<br>
> without.<br>
><br>
> Thanks<br>
> Miguel<br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opennebula.org">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>
><br>
</blockquote></div><br>