Archive

Posts Tagged ‘Jython’

Two More Jython Samples Managing VMware vSphere

May 18th, 2010 2 comments

Yesterday I posted an article introducing the virtual appliance Timo created last week. I am sure some of you have given it a try. I hope you liked it. If you haven’t done so, you can download it from Timo’s post.

The virtual appliance ships with only two samples. Definitely not enough. That is why the community needs to work together so that we can match the functionalities of vSphere PowerCLI.

The following are two samples by David Rousseau who is an independent consultant living in Paris. Thanks for his permission to publish his code here. He owns the copyright of the code. If you want to use it, you can contact him or leave a message in this post.

  1. jython_rest.py: This code shows how to use the tiny Client REST API I created. Check out this article for more details of the API itself.
  2. jython_test.py: list all the hosts, resource pools, virtual machines and vApps that are found at the server.

To help you understand the code, I added a little comment before each file.

Attention Administrators: vSphere Java API is for You too!

May 10th, 2010 No comments

Most people have the perception that vSphere Java API is for developers. It’s true but actually more than that. Administrators can take advantage of it as well.

Today, William Lam (@lamw) posted a Java version of his vdf tool which was originally written in Perl. For people don’t know William yet, he is a system administrator at Salesforce.com now and Yahoo before. He created and maintains the famous vGehtto script repository that almost every VI Perl developer knows about. William is also a vExpert and the No.1 contributor to the VMware developer community. Having not touched Java for 4+ years, William got his first HelloVM with VI Java API working in less than 5 minutes, and got the code converted in about one hour.

Categories: vSphere API Tags: , , ,

Using vSphere Java API in Jython and Other JVM languages

March 5th, 2010 2 comments

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.

Categories: vSphere API Tags: ,

4 Ways to WIN $2,500 Prize With vSphere Java API

February 4th, 2010 3 comments

You may have read blogs from my colleagues Mike DiPetrillo, Duncan Epping about the VMware Script-O-Mania contest. The prizes are $2,500 (1st), $1,000 (2nd), and $500(3rd) respectively. The contest ends in March 15, 2010. So act quickly!

“Wait, how can I WIN the prizes?”

Well, first of all, you want to read carefully the criteria. Note that your script is for System Administrators with ESXi. So it could be for initial server set up, health monitoring, trouble shooting, reporting auditing, or anything else that is cool and creative. I suggest you talk to system administrators what REAL PAINS they have, and how they would like to fix the problems.

When you are clear what problems to solve, then let’s move on.

If you are already familiar with PowerCLI and RCLI, you should probably stick with them. You can get helps from VMware Developer Community.

If not, open source VI Java API can help you!

Here are 4 ways the API can do for you to win the $2,500: