4 Rules for Converting Onyx Generated Code

VMware PM Carter Shanklin (@cshanklin) once gave a great presentation on how to use Onyx with Java development at PEX 2010. I covered it briefly in a previous blog, and left out the “4 rules” hoping Carter would help.

As many of you have already known, Carter moved on to SpringSource division as the PM for tc server. So he has been pretty busy with his transition. With his coverage on both administrator and developer oriented products, he is right on the wave of devops movement. Make sure you follow him at Twitter.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

Now let’s get back to his 4 rules of converting Onyx generated code to a language of your choice:

  1. Create objects when Onyx does, and use the same name.
  2. Assemble the overall object at the end.
  3. Bring your own code to looking up IDs.
  4. Replace Get-View with class methods or static look up code.

The first two rules are relatively easy to understand. Whatever data objects Onyx created, you need corresponding ones in your language say Java. Because data objects contain each other, all the contained data objects should be assembled into the top one.

The last two rules are not that straight forward due to the way Onyx works. At the very high level, Onyx records whatever you do in the vSphere Client as SOAP messages and converts the messages to PowerCLI code (could be other code in the future). The vSphere Client uses ManagedObjectReference objects as IDs whose values are very dynamic depending how you drive the vSphere Client. When you convert these IDs, you want to have your own way to get them. There are several ways to get the IDs in VI Java API. You can use either InventoryNavigator or SeachIndex to look up any managed entity you are interested, or navigate the inventory tree one by one.

The key value offered by Onyx for Java developers is on the data objects which may have hundreds of sub properties and therefore be confusing sometimes. When you have no idea on what values for your parameters, when you get any clueless InvalidRequest exception, it’s high time that you pick up Onyx.

For more of Carter’s presentation, check it out here.

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

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=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, 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.