Hi,

Maybe you can try the following code, it's a simple request to check if the
code can request the user's info, the equivalent of 'onevm show'.

What OpenNebula version are you using? Did you make sure you downloaded the
java bindings for the same version?


Regards


import org.opennebula.client.*;
import org.opennebula.client.user.*;

public class SessionInit {

    public static void main(String[] args)
    {
        try
        {
//            Client client = new Client();
//            Client client = new Client("oneadmin:onead", null);
            Client client = new Client("oneadmin:onead", "
http://localhost:2633/RPC2";);

            User user = new User(-1, client);
            OneResponse res = user.info();

            if( res.isError() )
            {
                System.out.println( res.getErrorMessage() );
            }
            else
            {
                System.out.println( "User name: " + user.getName() );
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}



--
Carlos Martín, MSc
Project Engineer
OpenNebula - The Open-source Solution for Data Center Virtualization
www.OpenNebula.org | [email protected] |
@OpenNebula<http://twitter.com/opennebula><[email protected]>



On Wed, Oct 31, 2012 at 1:00 PM, rajesh kannan <[email protected]>wrote:

> Really happy to see u reply sir ........thank u sir
>
> oneadmin@SONY-VAIO:~/lib/java$ oneuser show
> USER 0 INFORMATION
>
> ID             : 0
> NAME           : oneadmin
> GROUP          : oneadmin
> PASSWORD       : cb01da439fe2ec212349424491de000f26809212
> AUTH_DRIVER    : core
> ENABLED        : Yes
>
> USER TEMPLATE
>
>
>
> RESOURCE USAGE & QUOTAS
>
>
> oneadmin@SONY-VAIO:~/lib/java$ onevm list
>     ID USER     GROUP    NAME            STAT UCPU    UMEM HOST
>   TIME
>      0 oneadmin oneadmin ttylinux        fail    0      0K              0d
> 00h17
>      1 oneadmin oneadmin ttylinux        stop   99    512M              1d
> 19h24
> oneadmin@SONY-VAIO:~/lib/java$ onevm resubmit 1
> oneadmin@SONY-VAIO:~/lib/java$ onevm list
>     ID USER     GROUP    NAME            STAT UCPU    UMEM HOST
>   TIME
>      0 oneadmin oneadmin ttylinux        fail    0      0K              0d
> 00h17
>      1 oneadmin oneadmin ttylinux        pend   99    512M              1d
> 19h24
>
>
> Here CLI commands working but when am going to use Java program its not
> working
>
> i dont know what was problem
>
>
>
> On 31 October 2012 16:29, Carlos Martín Sánchez <[email protected]>wrote:
>
>> Hi,
>>
>> Can you execute CLI commands with those "oneadmin:onead" credentials? Try
>> any command, like 'oneuser show' or 'onevm list'
>> --
>> Carlos Martín, MSc
>> Project Engineer
>> OpenNebula - The Open-source Solution for Data Center Virtualization
>> www.OpenNebula.org | [email protected] | 
>> @OpenNebula<http://twitter.com/opennebula><[email protected]>
>>
>>
>>
>> On Wed, Oct 31, 2012 at 5:28 AM, rajesh kannan 
>> <[email protected]>wrote:
>>
>>> sorry for asking once again because i dont have choice to ask any one so
>>> pls help me ....i had this problem past one month.... i try out all
>>> possibility ....i refer all your passed question on [one_users] ...they are
>>> said about only ONE_AUTH file but am specified correctly .....
>>>
>>> i dont know what was the problem pls help..............
>>>
>>> //this java program given in opennebula websites
>>>
>>> // i made only changes on this only
>>>
>>> //passing the parameter username:password and XML-RPC
>>>
>>> //then change the vmTemplate Variable
>>>
>>>
>>> Client oneClient = new Client("oneadmin:onead","
>>> http://localhost:2633/RPC2";);
>>>
>>>     String vmTemplate =
>>>           "NAME     = vm_from_java    CPU = 0.1    MEMORY = 64\n"
>>>         + "DISK     = [\n"
>>>         + "\tsource   = \"/var/lib/images/ttylinux.img\",\n"
>>>         + "\ttarget   = \"hda\",\n"
>>>         +"\thostname    = \"$NAME\",\n"
>>>         +"\tip_public   = \"PUBLIC_IP\",\n"
>>>         +"\t root_pubkey = \"id_rsa\",\n"
>>>         +"\tfiles      = \"/var/lib/one/init.sh ~/.ssh/id_rsa\",\n"
>>>         +"\tusername    = \"opennebula\",\n"
>>>         +"\tuser_pubkey = \"id_rsa\",\n"
>>>         + "\treadonly = \"no\" ]\n"
>>>         + "FEATURES = [ acpi=\"no\" ]";
>>>
>>> oneadmin@SONY-VAIO:~/lib/java$ javac vmcre.java
>>>
>>> oneadmin@SONY-VAIO:~/lib/java$ java vmcre
>>>
>>> ERRR
>>> [VirtualMachineAllocate] User couldn't be authenticated, aborting call.
>>>
>>>
>>> when i try to install opennebula i did this kind of ssh operation
>>>
>>>
>>> su -l oneadmin
>>> ssh-keygen
>>> {Note - all defaults, and no passphrase.}
>>> cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
>>> nano ~/.ssh/config
>>> [add below two lines to SSH config file]
>>> Host *
>>> StrictHostKeyCheckingno
>>>
>>>
>>> Is there any problem on this????????
>>>
>>>
>>> Env  variable
>>>
>>> oneadmin@SONY-VAIO:~/lib/java$ cat ~/.bash_profile
>>>
>>>
>>> export ONE_LOCATION=/var/lib/one
>>> export ONE_AUTH=$ONE_LOCATION/.one/one_auth
>>> export ONE_XMLRPC=http://localhost:2633/RPC2
>>> export
>>> PATH=$ONE_LOCATION/bin:/usr/local/bin:/var/lib/gems/1.8/bin/:/var/lib/gems/1.8/:$PATH
>>>
>>>
>>> Username:password ONE_AUTH file
>>>
>>> oneadmin@SONY-VAIO:~/lib/java$ cat ~/.one/one_auth
>>>
>>> oneadmin:onead
>>>
>>> //(Username:password)
>>>
>>>
>>> oneadmin@SONY-VAIO:~/lib/java$ cat ~/etc/oned.conf
>>>
>>> AUTH_MAD = [
>>>     executable = "one_auth_mad",
>>> arguments  = "--authn ssh,x509,ldap,server_cipher,server_x509" ]
>>>
>>> uncomment this line also
>>>
>>>
>>>
>>> i dont know what else suppose to do to recover this problem
>>>
>>> sorry for distrub
>>>
>>> i need to finish the project on this month pls help me
>>>
>>> if u know something else do on this pls mail me
>>>
>>> ................if know please help...................
>>>
>>> _______________________________________________
>>> Users mailing list
>>> [email protected]
>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>
>>>
>>
>
_______________________________________________
Users mailing list
[email protected]
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org

Reply via email to