[one-users] opennebula
Carlos Martín Sánchez
cmartin at opennebula.org
Thu Oct 11 06:53:14 PDT 2012
Hi,
You may find these links useful:
http://opennebula.org/documentation:rel3.6:manage_users#users
http://opennebula.org/doc/3.6/oca/java/
http://opennebula.org/doc/3.6/oca/java/org/opennebula/client/Client.html
http://opennebula.org/documentation:rel3.6:api
https://github.com/OpenNebula/one/blob/master/src/oca/java/src/org/opennebula/client/Client.java
Regards
--
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 Thu, Oct 11, 2012 at 9:25 AM, Bhupendra Kumar Teli <
bhupendra.bkt11 at gmail.com> wrote:
> package javaapplication1;
>
>
>
> /**
> *
> * @author ubuntu
> */
>
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import org.opennebula.client.*;
> import org.opennebula.client.vm.*;
>
>
> public class JavaApplication1 {
>
> // First of all, a Client object has to be created.
> // Here the client will try to connect to OpenNebula using the default
> // options: the auth. file will be assumed to be at $ONE_AUTH, and the
> // endpoint will be set to the environment variable $ONE_XMLRPC.
> static Client oneClient;
>
> public static void main(String args[])
> {
> try
> {
> oneClient = new Client();
>
> // This VM template is a valid one, but it will probably fail to run
> // if we try to deploy it; the path for the image is unlikely to
> // exist.
> String vmTemplate =
> "NAME = vm_from_java CPU = 0.1 MEMORY = 64\n"
> + "DISK = [\n"
> + "\tsource =
> \"/home/ubuntu/ubuntu-10.04.4-desktop-i386.iso\",\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() );
> }
>
> // The response message is the new VM's ID
> int newVMID = Integer.parseInt(rc.getMessage());
> System.out.println("ok, ID " + newVMID + ".");
>
> // We can create a representation for the new VM, using the returned
> // VM-ID
> VirtualMachine vm = new VirtualMachine(newVMID, oneClient);
>
> // Let's hold the VM, so the scheduler won't try to deploy it
> System.out.print("Trying to hold the new VM... ");
> rc = vm.hold();
>
> if(rc.isError())
> {
> System.out.println("failed!");
> throw new Exception( rc.getErrorMessage() );
> }
>
> // And now we can request its information.
> 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");
>
> // This VirtualMachine object has some helpers, so we can access its
> // attributes easily (remember to load the data first using the info
> // method).
> System.out.println("The new VM " +
> vm.getName() + " has status: " + vm.status());
>
> // And we can also use xpath expressions
> System.out.println("The path of the disk is");
> System.out.println( "\t" + vm.xpath("template/disk/source") );
>
> // We have also some useful helpers for the actions you can perform
> // on a virtual machine, like cancel or finalize:
>
> rc = vm.finalizeVM();
> System.out.println("\nTrying to finalize (delete) the VM " +
> vm.getId() + "...");
>
> }
> catch (Exception e)
> {
> System.out.println(e.getMessage());
> }
> }
> }
>
> after executing this in root but it is giving an error that "ONE_AUTH file
> not present..
> plz tell me I am doing right or wrong because I just installed netbeans on
> that system and added org.opennebula.client.jar and running above apps.
> how it will interact with opennebula???
> --
> ----------------------------
> Regards,
> Bhupendra Kumar Teli
> M. Tech(IT)
> 11536007
> IIT Roorkee
> +91-8439869004
>
> _______________________________________________
> 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/20121011/ebd6ee46/attachment-0002.htm>
More information about the Users
mailing list