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.

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: ,