[one-users] Java example on opennebula

Carlos Martín Sánchez cmartin at opennebula.org
Wed Oct 17 08:59:05 PDT 2012


Please stop sending a daily mail with the same problem. It's annoying and
counter-productive.

You will get better help if you put some effort in your question. I really
like how this is explained in the Stack Overflow guide on how to ask [1].


Can you execute CLI commands with those "oneadmin:rajesh" credentials? Try
any command, like 'oneuser show' or 'onevm list'; and paste the output of:

$ cat ~/.one/one_auth


Good luck

[1] http://stackoverflow.com/questions/how-to-ask
--
Carlos Martín, MSc
Project Engineer
OpenNebula - The Open-source Solution for Data Center Virtualization
www.OpenNebula.org | cmartin at opennebula.org |
@OpenNebula<http://twitter.com/opennebula><cmartin at opennebula.org>



On Wed, Oct 17, 2012 at 6:04 AM, rajesh kannan <asrajeshkannan at gmail.com>wrote:

> Pls Help me
>
> Give me any changes on this program
>
> Still i Had problem
>
> Trying to allocate the virtual machine... failed!
> [VirtualMachineAllocate] User couldn't be authenticated, aborting call.
>
> import java.lang.*;
> import java.io.*;
> import org.opennebula.client.Client;
> import org.opennebula.client.vm.VirtualMachine;
> import org.opennebula.client.OneResponse;
> import org.apache.xmlrpc.XmlRpcException;
>
> public class vmcre
> {
> public static void main(String args[])
> {
> try
> {
>   Client oneClient = new Client("$ONE_AUTH","$ONE_XMLRPC");
>
> //or
>
> //Client oneClient = new Client("oneadmin:rajesh","$ONE_XMLRPC");
>
> //or
>
> //Client oneClient = new
> Client("/var/lib/one/.one/one_auth","http://localhost:2633/RPC2");
>
>
>
>     String vmTemplate =
>           "NAME     = vm_from_java    CPU = 0.1    MEMORY = 64\n"
>         + "DISK     = [\n"
>         + "\tsource   = \"/var/lib/one/ttylinux.img\",\n"
>         + "\ttarget   = \"hda\",\n"
>         + "\treadonly = \"no\" ]\n"
>         + "FEATURES = [ acpi=\"no\" ]";
>
>     System.out.print("Trying to allocate the virtual machine... ");
>     OneResponse rc = VirtualMachine.allocate(oneClient, vmTemplate);
>
>     if( rc.isError() )
>     {
>         System.out.println( "failed!");
>         throw new Exception( rc.getErrorMessage() );
>     }
>     int newVMID = Integer.parseInt(rc.getMessage());
>     System.out.println("ok, ID " + newVMID + ".");
>
>     VirtualMachine vm = new VirtualMachine(newVMID, oneClient);
>
>     System.out.print("Trying to hold the new VM... ");
>     rc = vm.hold();
>
>     if(rc.isError())
>     {
>         System.out.println("failed!");
>         throw new Exception( rc.getErrorMessage() );
>     }
>
>     rc = vm.info();
>
>     if(rc.isError())
>         throw new Exception( rc.getErrorMessage() );
>
>     System.out.println();
>     System.out.println(
>             "This is the information OpenNebula stores for the new VM:");
>     System.out.println(rc.getMessage() + "\n");
>
>     System.out.println("The new VM " +
>             vm.getName() + " has status: " + vm.status());
>
>     System.out.println("The path of the disk is");
>     System.out.println( "\t" + vm.xpath("template/disk/source") );
>
>     rc = vm.finalizeVM();
>     System.out.println("\nTrying to finalize (delete) the VM " +
>                         vm.getId() + "...");
>
> }
> catch (Exception e)
> {
>     System.out.println(e.getMessage());
> }
> }
> }
>
>
> Regards
>
> A S RAJESH KANNAN
> ANNA UNIVERSITY,CEG
> M.TECH(IT)
> _______________________________________________
> 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/20121017/492635f9/attachment-0002.htm>


More information about the Users mailing list