Home > vSphere API > Using vSphere Java API in Jython and Other JVM languages

Using vSphere Java API in Jython and Other JVM languages

As a by-product, the vSphere Java API makes Jython programming a lot easier. The following is a very simple sample written in Jython to print out the name of the first virtual machine in inventory.

    from java.net import *
    from com.vmware.vim25.mo import *

    si= ServiceInstance(URL(“https://sjin-dev1/sdk”),\
    “root”, “password”, True)
    rootFolder = si.getRootFolder()
    vms = InventoryNavigator(rootFolder) \
    .searchManagedEntities(“VirtualMachine”)
    print “Hello ” + vms[0].getName()
    si.getServerConnection().logout()

As you can see, it really brings in the benefit of VI Java API into Python community at almost no extra cost.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure

HTML5 App

Click here for the presentation for more details including setting up an IDE. For more about what JVM languages you can use with vSphere Java API, check out here.




Categories: vSphere API Tags: ,
  1. Reuben
    April 4th, 2014 at 04:54 | #1

    Hi Steve,

    I am writing an Affinity rule code in python to disable DRS for a particular VM. I am using pyVmomi API and am taking help from VI java sample DrsAff.java . I am not able to proceed further. Please share some ideas.

    Thanks,
    Reuben

  2. April 4th, 2014 at 15:13 | #2

    Hi Reuben, what is the issue blocking you?

    Steve

  1. August 30th, 2010 at 00:02 | #1