Archive

Posts Tagged ‘vSphere API’

How to Notify All the Active vSphere Users?

June 16th, 2010 No comments

As system administrators, you may have used the feature that sends a message to all users. It’s very helpful when you want to change something that might affect others, or ask for particular attention from new users who log in later.

It’s simply 3 steps as described vSphere Client Help:

  1. From the Home page of the vSphere Client, click Sessions.
  2. Type the message in the Message of the day box.
  3. Click Change.

The message is sent to all the currently login users, and until the message is changed, any new users see the message upon logining to the vCenter.

Now, how to do with the API?

Categories: vSphere API Tags: ,

Really Easy Way to Find out What’s New in vSphere API

June 1st, 2010 1 comment

I am probably one of a few persons who read the VMware vSphere API reference extensively because of my book. When I read it, I normally quickly click the Managed Object Types link in navigation pane on the left side, and then choose one type for the details on the right side.

Categories: vSphere API Tags:

VMware SDK Support Program: It’s Available to Everyone

May 25th, 2010 2 comments

Many people know VMware offers support on products, but not many know VMware actually started to support SDKs. I occasionally got questions on the SDK support. So I think a blog should help here.

A little history first. VMware used to provide support to partners who are part of Technical Alliance Program (TAP), but not to others including customer. VMware partners can also propose integration projects which may get people like me to provide architectual guidance. After SpringSource coming on board, Marty Messer took over the support program and expanded it to everyone as a paid service recently.

What You Can Buy?

The paid support is available in two levels:

Categories: vSphere API Tags: ,

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.

How to Fix Task Timeout in vSphere?

May 11th, 2010 No comments

Task management is an important part of vSphere API. It enables asynchronous calls by returning a Task back before the work is actually done at the server side. If a task takes too long (for example, more than 15 minutes to create a virtualmachine snapshot from VirtualCenter), however, it can time out before it finishes. It means you lose tracking of the task.

You can easily fix this issue by changing the configurations. On the ESX server, add the following to the /etc/opt/vmware/vpxa/vpxa.cfg file:

<task>
<timeout>7200</timeout>
</task>

and

<vmomi>
<soapStubAdapter>
<blockingTimeoutSeconds>7200</blockingTimeoutSeconds>
</soapStubAdapter>
</vmomi>

Remember to restart the service:

Categories: vSphere API Tags: , ,

Really Easy Way to Clone a Session: Yet Another Contribution from NetApp

April 26th, 2010 1 comment

Recently there were questions in the vSphere Java API forum on how to clone a new session from an existing one. Although vSphere Java API wraps around the basic Web Services API cloneSession() method, simply calling the method doesn’t get what you want.

Why? The signature of cloneSession() is as follows. It returns UserSession, which is embedded inside ServiceInstance managed object in vSphere Java API. While using the API, you always starts from the ServiceInstance.

public UserSession cloneSession(String cloneTicket) throws InvalidLogin, RuntimeFault, RemoteException;

In vSphere Java API, the ServiceInstance and UserSession have one to one mapping. Without a new ServiceInstance around the new UserSession, the UserSession is not much helpful.

Luckily, we got yet another contribution from Eric Forgette who works at NetApp. The contributed code includes a new overloaded method cloneSession() method to return a ServiceInstance object.

As I described before, we’ve been trying very hard to keep the vSphere Java API as close to the basic Web Services as possible. In this case, we decided to break the rule a little bit for good reasons, mainly for usability.

Categories: vSphere API Tags: ,

Synchronous versus Asynchronous Calls in vSphere API

April 22nd, 2010 No comments

In a previous article Top 10 Best Practices Using VMware VI and vSphere SDK, I mentioned synchronous versus asynchronous calls in the second best practice “Choose Right APIs.” But no detail was provided there. In this article, which is based on my book VMware VI and vSphere SDK , I discuss all the details.

Some methods defined on managed objects in vSphere API are asynchronous, meaning they return right away whether the operations are done successfully or not. That makes sense for long-running operations; you don’t want to block your current thread by waiting for the return of the call, and you might want to cancel it before it’s done.

For these asynchronous methods, the VI SDK provides a way to track the progress and results after the invocation is returned. As a naming convention, a long-running asynchronous method has _Task as a suffix in the method name, and it returns MOR to a Task. With MOR pointing to the Task object, you can track the progress and even get the result of the operation. For example, the cloneVM_Task() method defined in VirtualMachine is a long-running method that returns MOR pointing to a Task managed object.

Categories: vSphere API Tags: ,

Invalid property? A Trick With vSphere PropertyCollector

April 14th, 2010 9 comments

As I discussed extensively in my book, the PropertyCollector is very powerful yet not easy to use. There was a question posted at vSphere Java API forum related to the property collector which I think worths sharing here. Although it’s found using vSphere Java API, but it really goes beyond the API to the vSphere API itself.

Virtual Machine, IP Address, and MAC Address: Frequently Confused Concepts

April 13th, 2010 22 comments

Having answered many questions about IP addresses of virtual machines at different occasions, I still see more are coming. I think it’s time to write a blog about it. Hopefully people would search the Internet before raising the question.

First of all, there is a big confusion on the relationship of IP addresses and virtual machines. Many people tend to associate IP addresses with virtual machines, and want to retrieve/change the IP address of a virtual machine.

In fact, a virtual machine is very much like its physical counterpart. It does not have an IP address by itself. In other words, an IP address is NOT an intrinsic attribute of a machine, either virtual or physical. It might have one or more only after an OS is installed. In most cases, it does have one or more IP addresses, which gives the impression that every machine has an IP address.

A virtual machine does have intrinsic attributes such as MAC addresses if NIC cards are configured. Unlike its physical counterpart, a virtual machine’s MAC address can be re-configured. Some software vendors rely on MAC addresses to lock down their licensed software on particular machines. This mechanism can be, therefore, compromised in virtual environments.

Video on vSphere Java API Released at InfoQ

April 9th, 2010 2 comments

While searching Twitter on “vSphere Java”, I found my presentation available today online at InfoQ (many thanks to @arm1433 and @toya256ForRSS). It has both video and slides for more than one hour. The voice was not quite clear in the first one or two minutes. After that it’s pretty good.

This presenation is a complete overview of the open source vSphere Java API. Because the audience then was new to virtualization, the first several minutes covered a little virtualization basics. You can scroll over if you know virtualization already.

Categories: vSphere API Tags: ,

I18N vs. vSphere

April 8th, 2010 No comments

With today’s global market, a software vendor has to consider the internationalization (I18N) issue to better serve users in different areas and maximize the return on the product investment. This article introduces the I18N basics of vSphere. Much of the content is based on my book VMware VI and vSphere SDK by Prentice Hall.

There are two basic meanings. First, you have to design your software so that it is localizable. In other words, you have to use the right APIs that can handle double byte characters. Sometimes people call this globalization (G11N).

Second, you should provide localized versions of your software so that users can read and use their native languages. Sometimes people call this localization.

In most cases, you externalize all the text strings that are visible to end users from the code to the resource files and translate them into different languages. Then localizing the software is as easy as combining the code and localized resource files. This is the way VirtualCenter server is localized. Depending on the programming language and platform, the resource files can be organized differently and might have another format. For example, Java uses properties files, yet C++ on Windows uses resource dlls.

That said, I18N is a broad topic that does much more than what is briefly covered here. Further discussion is beyond the scope of this book, but you can find more detailed information online.

As discussed, the VI SDK is essentially a set of Web Services interfaces. The WS-I18N summarizes four internationalization patterns that can be applied with Web Services when deployed.

Categories: vSphere API Tags: , ,

Winners of the VMware Script-O-Mania Contest: Who, What, How and Why?

April 1st, 2010 No comments

The winners of the VMware Script-O-Mania contest was announced today by Pablo Roesch at VMware Developer Blog. Congratulations to Alan, William and Arnim who won the first three awards!

I just took some time to read these scripts even though PowerShell and Perl are not for me. Here I give you a brief introduction of the scripts, what vSphere APIs they used directly or indirectly, and why they topped the contest. Because vSphere API is based on Web Services, you can port the scripts to other languages like Java, .Net, whatever you feel comfortable with. If you want to port any of them using vSphere Java API, I am more than happy to include your contribution.

Note that the following comments are strictly my own opinions.

1. Who Created that VM ? – by Alan Renouf using PowerCLI

A script to add information back into the vSphere client, this script which is designed to run once a day (or more) as a scheduled task, will add a custom attribute to each VM with the creator and date created of that VM. A script to add information back into the vSphere client, this script which is designed to run once a day (or more) as a scheduled task, will add a custom attribute to each VM with the creator and date created of that VM.

Steve’s Comments:

Nice integration with the vSphere Client, making you almost doubt why it wasn’t there in the first place. Additional one liner scripts provide nice answers to the questions like who created the most VMs, how many VMs were created each month.

Introducing Security Model of VMware vSphere

April 1st, 2010 2 comments

This article introduces you the basic model and terminologies in vSphere security management, for example, privileges, permissions, roles, and how they are related to each other to secure vSphere. It helps you to better manage the vSphere and program the vSphere API. Much of the content is based on my book VMware VI and vSphere SDK by Prentice Hall.

In vSphere, the security model consists of three types of components: privileges, roles, and permissions.

Privileges

A privilege is the basic individual right required to perform an operation. It is statically defined and never changes in a single version of a product. Given the many operations in VI, there are many privileges (for example, the privilege to “power on a virtual machine”). These privileges are represented as strings separated by dots, such as VirtualMachine.Interact.PowerOn.

The operations and privileges are not one-to-one mapping. Many operations do share common privileges like System.View. Therefore, there are many fewer privileges defined than methods. In some exceptional cases, a method requires different privileges depending on the target it operates on and the nature of the operation. The CloneVM_Task() method, for example, requires VirtualMachine.Provisioning.Clone for cloning from one virtual machine to another, VirtualMachine.Provisioning.DeployTemplate for cloning from a template to a virtual machine, and so on.

Roles

The role groups privileges from a user’s perspective. A role is normally named and defined for a group of people who have common responsibilities in the system (for example, administrators). Each role can include zero to multiple privileges. The extreme cases are the predefined “Admin” roles, which by default, includes all the privileges and the NoAccess role, which includes no privileges.

Categories: vSphere API Tags: ,

3 Ways to Get Hold of Managed Objects in vSphere

March 30th, 2010 No comments

If you have ever used vSphere Web Service API, you must have known that there is no managed object but ManagedObjectReference object. Understanding it helps deepen your understanding of the vSphere API.

Honestly, the ManagedObjectReference is a little confusing by itself. It is in fact a data object but represents a managed object. You can think of a MOR as a pointer in some sense because it’s used to uniquely identify a managed object. Even better, you can think of the “type” and “value” defined in the MOR in the SQL way. The type is like a table name, and the value like the primary key which can uniquely identify a managed object in its type.

MOR is really intended to be used by program and should be carefully limited to the scope of where it comes from. That is why it’s hidden from application developers in vSphere Java API.

Anyway, let’s see how to get hold of MOR objects:

Categories: vSphere API Tags: ,

vSphere Inventory Structure Deep Dive

March 29th, 2010 4 comments

This blog digs into the vSphere inventory structure, and changes in vSphere 4 from VI. It explains the difference between ESX and vCenter inventory tree, why the inventory path you see from vSphere Client doesn’t work with API. Much of the content is adapted from my book VMware VI and vSphere SDK by Prentice Hall.

Inventory vs. Inheritance hierarchy

My previous blog introduced the object model of the vSphere API. The UML diagram there shows how different managed object types are structured in the inheritance hierarchy.

The inventory hierarchy is quite different. It shows how different managed object instances are associated. With this understood, you can easily navigate among different managed objects in inventory tree of both ESX and vCenter. It’s critical for programming vSphere API because navigating the inventory is the primary way to get hold of managed objects.

Categories: vSphere API Tags: ,

Demystifying 3 “View”s from VMware

March 23rd, 2010 6 comments

After I blogged the top 5 myths of vSphere API, William Lam suggested me to write a bit more on the views in his comments. If you haven’t followed him (@lamw) at Twitter yet, you may want to. His vGhetto Perl repository is one of the best resources for people who use VI Perl.

For sure, VMware loves the term “view”. As far as I know, there are 3 different ”views.” Two of them are for APIs; the last one is for the desktop product family. We are not going to talk about the product View in this blog. You can find more information at VMware web site.

Let’s instead focus on the two “Views” for developers: one is in VI Perl and .NET/PowerCLI; the other is part of the core vSphere API.

Categories: vSphere API Tags: , , , ,

Top 5 Myths about VMware vSphere API

February 28th, 2010 10 comments

If you have trouble to understand vSphere API when you first use it, you are definitely not alone. I had the same trouble when I first used it a while back.

Some of the troubles come from the disconnect between conventional programming model and that of vSphere API. In this blog, I summarize the top 5 myths about vSphere API based on my experience and the questions I see in the VMware community forum and vSphere Java API forum:

  1. Non-existing Managed Objects
  2. Pervasive PropertyCollector
  3. Short-Lived Task Object
  4. “Weak” HostSystem
  5. “Un-documented” View

Let’s examine each of them one by one.

What Makes A Platform Stick?

February 23rd, 2010 No comments

Inspired by the book Made to Stick – Why do some ideas thrive while others die? by Heath brothers, I would like to give it a try on software platforms rather than the ideas covered in the book. Although the computer industry is still relatively young compared with other industries, it’s quite dynamic and we’ve seen some platforms came and died while others came and thrive. So, what are the general characteristics for such sticky platforms?

The authors of the book summarized the 6 principals to make ideas stick, meaning the ideas change either the thoughts or/and behaviors of the receivers. These principals are Simplicity, Unexpectedness, Credibility, Concreteness, Emotions, and Stories. They are shortened to SUCCESs for easy memory.

Most of these principals don’t apply on software platforms. Unexpectedness, for example, may be the last thing you would like to see of a software platform. For software platform, we definitely need predictability, among other qualities.

After thinking the problem over, I summarized 4 basic principles for a software platform to stick: Simplicity, Extensibility, Ecosystem, and Developers, in short SEED.

More Thoughts On Rich Internet Applications And Applications In General

February 21st, 2010 No comments

Compared with advances in other application development, the rich Web application development using Java is not quite there yet. Instead of simplifying JavaScript, AJAX, and JSF, we need a new head start. Don’t get me wrong, some of them are still needed and continue to work well for plain Web applications.

“Develop Once, Run Everywhere”

Adobe Flex has done a fairly good job for Web. Even better the same code can be easily tweaked to run as a standalone application with Adobe AIR. This was once an expectation for Java when it first came out to run as an Applet. Somehow it didn’t succeed in its birth place, but gained its ground at the server side instead.

JavaFX from Sun is a nice try but too late in the game. More importantly, Sun is not a client software company like Microsoft who was also late with SliverLight but has client side expertise and managed to compete. I don’t think Sun will reclaim its already lost client market at all, and therefore JavaFX is likely a candidate to be axed after Oracle’s acquisition. The investment on JavaFX should have gone to Java Swing, which is a lackluster compared with IBM SWT.

Introducing A Tiny Yet Powerful API to Manage and Automate vSphere

February 3rd, 2010 8 comments

In yesterday’s blog, I talked about a little known secret of vSphere MOB – the invisible embedded XML in the HTML pages. To take advantage of the secret, I created a client side REST API which was shipped in VI Java API 2.0.