[one-users] xmlrpc client

Ksenija Poljak ksenija.poljak at altus-it.hr
Fri Dec 9 04:36:06 PST 2011


I use the real password.

On Fri, Dec 9, 2011 at 1:32 PM, Prakhar Srivastava <prakhar.apj at gmail.com>wrote:

> You appear to use the hashed password and not the password itself. Use the
> real password to construct the session string.
>
>
> On Fri, Dec 9, 2011 at 5:38 PM, Ksenija Poljak <ksenija.poljak at altus-it.hr
> > wrote:
>
>> I do the same thing and is not working. This line alone does not cause
>> any problems. But when I try to use UserPool.info(client); or any other
>> method, returned error string is: HTTP server returned unexpected status:
>> Unauthorized.
>>
>> On Fri, Dec 9, 2011 at 12:52 PM, Prakhar Srivastava <
>> prakhar.apj at gmail.com> wrote:
>>
>>> Hi,
>>> This is how I create a connection to the server
>>> oneClient = new Client("oneadmin:onepass","http://192.168.1.5:2633/RPC2
>>> ");
>>>
>>> Check that you are using the
>>> import org.opennebula.client.Client;
>>>
>>> to make user that you are using the correct client. Also send the
>>> stacktrace if you are still facing problems.
>>>
>>> Prakhar
>>>
>>>
>>> On Fri, Dec 9, 2011 at 5:03 PM, Ksenija Poljak <
>>> ksenija.poljak at altus-it.hr> wrote:
>>>
>>>> Even when I use that API, I still get Unauthorized exception.
>>>> What is the proper way to form a session string that gets user (for
>>>> start oneadmin) authenticated and authorized in Java client so that I can
>>>> test other methods?
>>>> I use client function: Client client = new Client("session_string",
>>>> "server_url");
>>>>
>>>> public *Client*(java.lang.String secret,
>>>>               java.lang.String endpoint)
>>>>        throws ClientConfigurationException <http://opennebula.org/doc/3.0/oca/java/org/opennebula/client/ClientConfigurationException.html>
>>>>
>>>>
>>>>
>>>> On Thu, Dec 8, 2011 at 5:16 PM, Prakhar Srivastava <
>>>> prakhar.apj at gmail.com> wrote:
>>>>
>>>>> Hi Ksenija,
>>>>> Why don't you simply use the Java OpenNebula Cloud API<http://opennebula.org/documentation:rel3.0:java> that
>>>>> is packaged with opennebula. If there is no specific scenario, its best to
>>>>> use them.
>>>>>
>>>>> Prakhar
>>>>>
>>>>> On Thu, Dec 8, 2011 at 3:23 PM, Ksenija Poljak <
>>>>> ksenija.poljak at altus-it.hr> wrote:
>>>>>
>>>>>> Hi, I'm using opennebula 3 and I'm trying to write an xmlrpc Java
>>>>>> client.
>>>>>> I'm not able to connect my client to opennebula server.
>>>>>> I keep getting unauthorized exception:
>>>>>>
>>>>>> org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server
>>>>>> returned unexpected status: Unauthorized
>>>>>>
>>>>>> My testing program:
>>>>>>
>>>>>> package open.nebula.client;
>>>>>>
>>>>>>
>>>>>> import java.net.MalformedURLException;
>>>>>> import java.net.URL;
>>>>>>
>>>>>> import org.apache.xmlrpc.XmlRpcException;
>>>>>> import org.apache.xmlrpc.client.XmlRpcClient;
>>>>>> import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
>>>>>>
>>>>>> public class OpenNebulaClient{
>>>>>>  private XmlRpcClient client = new XmlRpcClient();;
>>>>>> private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
>>>>>>  private String session =
>>>>>> "oneadmin:ffd775fdb8e47ebf5b68513843f31742f74118e8";
>>>>>>  public OpenNebulaClient(String server_url)
>>>>>> {
>>>>>> try{
>>>>>>  this.config.setServerURL(new URL(server_url));
>>>>>> this.client.setConfig(this.config);
>>>>>>  }catch(MalformedURLException e){
>>>>>> System.err.println(e);
>>>>>> }
>>>>>>  }
>>>>>>  public void getUserInfo(int id) throws XmlRpcException
>>>>>>  {
>>>>>> Object[] params = {session,id};
>>>>>> try {
>>>>>>             Object[] result = (Object[])this.client.execute("
>>>>>> one.user.info",params);
>>>>>>             if(!result[0].equals(null)) {
>>>>>>             boolean success = (Boolean)result[0];
>>>>>>             String str_res = (String)result[1];
>>>>>>             System.out.println("success="+success);
>>>>>>             System.out.println("result="+str_res);
>>>>>>             }else{
>>>>>>             System.out.println("success=0");
>>>>>>             }
>>>>>> }catch (XmlRpcException e) {
>>>>>> System.err.println(e);
>>>>>>  //e.printStackTrace();
>>>>>>         }
>>>>>> }
>>>>>>  public static void main(String[] args)
>>>>>> {
>>>>>> OpenNebulaClient on_client = new
>>>>>>
>>>>>>  OpenNebulaClient("http://server_ip:port/RPC2");
>>>>>> try{
>>>>>> on_client.getUserInfo(0);
>>>>>>  }catch(XmlRpcException xmlrpce){
>>>>>> System.err.println(xmlrpce);
>>>>>> }
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I'm confused becose when I look at examples on the web, there are
>>>>>> methods used as one.userinfo, and on opennebula official site they are
>>>>>> listed in form: one.user.info.
>>>>>> Session string I used consists of username:password that I get listed
>>>>>> with command: 'oneuser show 0' on opennebula server.
>>>>>> Client and opennebula server are on different machines.
>>>>>> I'm not sure what I do wrong. Any suggestions would be more than
>>>>>> helpfull. Tnx in advance.
>>>>>>
>>>>>> the full stackTrace of error:
>>>>>>
>>>>>> org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server
>>>>>> returned unexpected status: Unauthorized
>>>>>> at
>>>>>> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
>>>>>>  at
>>>>>> org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
>>>>>> at
>>>>>> org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
>>>>>>  at
>>>>>> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
>>>>>> at
>>>>>> org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
>>>>>>  at
>>>>>> org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
>>>>>> at
>>>>>> org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
>>>>>>  at
>>>>>> org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
>>>>>> at
>>>>>> open.nebula.client.OpenNebulaClient.getUserInfo(OpenNebulaClient.java:30)
>>>>>>  at
>>>>>> open.nebula.client.OpenNebulaClient.main(OpenNebulaClient.java:49)
>>>>>>
>>>>>> _______________________________________________
>>>>>> Users mailing list
>>>>>> Users at lists.opennebula.org
>>>>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.opennebula.org
>>>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opennebula.org
>>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opennebula.org
>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>
>>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opennebula.org
>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20111209/dfa5de6c/attachment-0003.htm>


More information about the Users mailing list