Announcing Guest Operating System Management API for vSphere

Having created a sample to run a program in guest operating system using GuestProgramManager, I started to write a similar one to show how to use the GuestFileManager. Compared with the GuestProgramManager, the GuestFileManager is much more complicated to use.

So I decided to take time to develop a high-level guest management API on top of the existing VI Java API. Besides the existing features offered by the vSphere API itself, I also added new features like uploading and downloading a whole directory (vSphere API itself only supports uploading and downloading a single file), uploading and downloading file to and from Java stream. The stream support is very important for an API, not much so for a command line tool.

The core of the guest opermanagement API for vSphere is two classes: GuestProgramDirector and GuestFileDirector, which corresponds to the GuestProgramManager and GuestFileManager. The names are consistent with the fact that a director is high level to a manager. :-)

The usage of the APIs is straight-forward. The methods, especially those in the GuestFileDirector, are pretty similar to what you do with conventional command lines. For example, the downloadFile method has the following signature. I think you can guess out how to use this method easily.

public void downloadFile(String filePathInGuest, String filePathLocal) throws IOException

I will explain more about each of the types with samples in future blogs. Here is the API for you to download.

Update: sample 1: run, kill, and list programs in guest operating system.

This entry was posted in Software Development, vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

10 Comments

  1. Santhosh
    Posted April 12, 2012 at 6:45 am | Permalink

    Hi,

    i have downloaded the API and copied your code to run, kill process.

    Its throwing a null pointer exception at line 30 of the GuestProcessDirector.java.

    What would be the error?

    I am new to Java. Please deal with this solution.

    GuestProcessDirector progDir = new GuestProcessDirector(vm, “Administrator”, “vijava”);

    The VM object , user name and password are valid here.

  2. Santhosh
    Posted April 13, 2012 at 4:52 am | Permalink

    My vmware tools version is 8.3.2, build 257589….Should i upgrade?

  3. Posted April 13, 2012 at 3:25 pm | Permalink

    It should be newer. In my case, the version is 8.6.0 build 425873.
    Steve

  4. Santhosh
    Posted April 17, 2012 at 2:52 am | Permalink

    Can you share your ESX details? Can you please specify the minimum requirements ?

  5. Santhosh
    Posted April 17, 2012 at 2:48 pm | Permalink

    my ESX is 4.0

  6. Tyron
    Posted October 17, 2012 at 10:23 am | Permalink

    Is there any particular reason why this API is not part of the VI Java API? Using the link provided here I am downloading five .class java files and was wondering whether there exists such files packaged in a jar. Thanks

  7. Posted October 24, 2012 at 5:56 pm | Permalink

    This is awesome. Can you put this in maven central?

  8. Mark Norman
    Posted August 22, 2013 at 9:36 am | Permalink

    can I get the source? I need to step through it to figure out a problem. thanks.

  9. ptpt52
    Posted April 23, 2014 at 9:11 pm | Permalink

    Hi, I was trying to download files from the guest using the vSphere API from vmware.com
    I try the sample code to run but failed
    the code is from VMware-vSphere-SDK-5.1.0-774886.zip
    where samples/com/vmware/guest/DownloadGuestFile.java

    my guest os has installed the vmware-tools, but I notice that the sample code run just hung at waitting for guest.guestOperationsReady to be true
    but it is not,
    why the guest.guestOperationsReady is false? how shuold I configure my vcenter?
    the EXSi server is version 4.1
    and the vcenter is 5.x

    any help?

  10. Posted April 23, 2014 at 10:55 pm | Permalink

    The guest operation from vSphere API was added in 5.0. If you are using ESXi 4.1, it’s not supported. Try it out with 5.x ESXi.

    Good luck!

    Steve

2 Trackbacks

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • NEED HELP?


    My consulting helps clients with virtualization and cloud computing, including VMware infrastructure automation and orchestration, vSphere management APIs, and deep product integration with hypervisors. Current training offerings include vSphere APIs training, vCenter Orchestrator training, and etc. Should you, or someone you know, need these consulting services or training, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.