Create and manage vCenter Server plug-ins

Easily add your own Web extension to the vSphere Client

Plug-ins let third parties, or partners, customize the vCenter Server with their own Web product-specific menu selections, tabs, or toolbars. With plug-ins you have a wide range of integration and extension scenarios, such as navigating the vSphere Client to the HostSystem's power management Web page. In this article, learn about vCenter Server plug-in architecture and how to add your own Web extensions to the vSphere Client. Walk through the setup and configuration, and explore the workflow at run time. Learn to enable or disable a specific plug-in using the Manager Plug-ins menu in vSphere Client.

Yun Guo Lian (yunguol@cn.ibm.com), Software Engineer, IBM

Photo of Yun Guo LianYun Guo Lian is a software engineer for IBM China. She currently works on Active Energy Management plug-in development.



Ma Zhuo (mazhuo@cn.ibm.com), Software Engineer, IBM

Photo of Ma ZhuoMa Zhuo has worked on IBM Director, virtualization, and Web development projects. He has a passion for software development. Ma enjoys writing about software development and mentoring other developers.



11 May 2010

Also available in Japanese

Introduction

With VMware's vCenter Server, third-party developers and partners can extend the VMware Infrastructure Client (VI Client) with their own product-specific menu selections, views, tabs, and toolbar icons to gain access to external, Web-based functions. The vCenter Server extensions, or plug-ins, provide: a configuration file; URLs; icons; Web server-hosted resources that work together to display extended menu items, icons, and other UI items in the VI Client; and access to the external functions.

vCenter Server plug-ins enable a wide range of integration and extension scenarios. For example, with vCenter Server plug-ins you can:

  • Display a static Web page.

    For example, make the VI Client navigate to the HostSystem's power management Web page with a customer button added to the VI Client toolbar.

  • Display a dynamic Web page that refreshes data with each access.
  • Obtain listings of managed ESX Server host systems.
  • Obtain information about the inventory—host systems, virtual machines, compute resources, and so on.
  • Retrieve performance statistics and information about events.
  • Manage the entire inventory.

    For example, add a new host to the inventory, power-on virtual machines, power-off virtual machines, and so on.

  • Act on information retrieved from the vCenter Server.

    For example, obtain the DNS name of a selected host and formulate a URL pointing to your own management system on that host.

In this article, get an overview of the vCenter Server plug-in architecture. An example will help get you started to add your own Web extensions to the vSphere Client. The extensions will be available to users who connect to the vCenter Server in the vSphere Client. The invocation workflow is also provided.


Setting up the environment

For plug-in development, you need a system setup that includes the following:

  • VMware ESX/ESXi
  • vCenter Server
  • vSphere Client
  • vSphere SDK
VMware ESX/ESXi
Provides a virtualization layer that abstracts the processor, memory, storage, and networking resources of the physical host into multiple virtual machines.
vCenter Server
A service that acts as a central administration for ESX/ESXi hosts connected on a network. This service directs actions on the virtual machines and the hosts. The vCenter Server is the working core of VirtualCenter.

You can have multiple vCenter Server systems joined to a Linked Mode group. This allows you to log in to any single instance of the vCenter Server and view and manage the inventories of all the vCenter Server systems in the group.

vSphere Client
Installs on a Windows® machine and is the primary method of interaction with VMware vSphere. The vSphere Client acts as a console to operate virtual machines and as an administration interface into the vCenter Server systems and ESX/ESXi hosts.

ESX/ESXi and vCenter Server licenses

Licensing is applicable to ESX/ESXi hosts and the vCenter Server. Each host requires a license, and each vCenter Server instance requires a license. You cannot assign multiple license keys to a host or to a vCenter Server system. You can:

  • License multiple hosts with one license key if the key has enough capacity for more than one host.
  • License multiple vCenter Server instances with one license key if the key has a capacity greater than one.
  • License multiple solutions with one license key if the key has a capacity greater than one.

License keys have a certain amount of capacity. For hosts, capacity is based on the number of processors in the host. For the vCenter Server, capacity is based on the number of instances of vCenter Server. For most vSphere products, when you purchase vSphere licenses you must consider the total number of processors, not hosts, that will run the products.

You can assign and reassign the processor capacity to any combination of hosts. If you purchase a license for a product, each instance requires a single unit of license key capacity, regardless of the number of processors in the machine. The vCenter Server is an example of a product that requires this type of license. If you purchase a vCenter Server license key with a capacity greater than one, you assign one unit of the capacity to each instance of vCenter Server.

vSphere SDK

VMware offers the VI Perl Toolkit and vSphere Web Service SDK. The vSphere SDK for Perl provides an easy-to-use Perl scripting interface to the vSphere API. Administrators and developers can work with vSphere API objects using vSphere SDK for Perl subroutines. Administrators can use the utility application included with vSphere SDK for Perl. The vSphere SDK for Perl includes the Web services management component for writing scripts that retrieve CIM data from the ESX/ESXi host using CIMOM, a service that provides standard CIM management functions. The vSphere SDK for Perl also includes subroutines for managing the VMware Credential Store and an example application that illustrates credential store use. ESX/ESXi 4.0 and vCenter Server 4.0 systems also provide a Web service that you can access using the vSphere API.

The vSphere Web Service SDK facilitates developing client applications that target the vSphere API. With the vSphere Web Service SDK you can create client applications to manage, monitor, and maintain VMware vSphere components deployed on ESX/ESXi and Virtual Servers systems. Developing a Java™ Web services client application using the VMware vSphere Web Services SDK requires the Java SDK and a Java Web services development toolset (Apache Axis 1.4).


Developing a vCenter Server plug-in

Developing and deploying vCenter Server plug-ins requires Web server-based components. The application must run on a Web server and must be implemented using CGI scripting, Java servlets, SAP.NET, or other standard Web development approaches. The URL to the application is used at run time to populate the VI Client with menus, toolbar icons and such, which ultimately provide access to your extended functions.

The Web-based approach to vCenter Server plug-ins (extensions) offers several advantages. Existing Web-based applications, or any Web site, can be quickly and easily integrated with VI Client. The integration with VI Client is loosely coupled; the application can be invoked from within VI Client, but it can also run as a standard Web application inside any Web browser.

Developing a plug-in includes Web application development, configuration file creation, and extension registrations. Figure 1 shows a sample system setup.

Figure 1. System setup
Diagram of the system setup. The Web server and Configuration file are pointing to the vSphere client. The vSphere client is pointing to the vCenter Server 4.0, ESX/ES Xi, and Register.

Deploy the Web application

To extend the VI Client, the only requirement is that the functions be available on a Web server. The functions can be as sophisticated as a comprehensive administration application, or as simple as static delivery of any page. Tomcat is one of the most popular Java servlet containers (plus a Web server). You can download it from Apache (see Resources). The default Tomcat configuration file can be found at:

C:\Program Files\ VMware\Infrastructure\VirtualCenterServer\tomcat\conf\server.xml

Create the configuration file

After planning where and how to extend the UI, the next step is to create the configuration file for your plug-in. You can use any text editor to create the configuration file.

To create a configuration file:

  1. Start the configuration file with the scriptConfiguration opening tags.
     <scriptConfiguration version=”1.0”>
  2. Create a key tag that will be used by ExtensionManager to uniquely identify your extension among possibly dozens of other vCenter Server plug-ins offered by both VMware and third-party developers. The key tag accepts a string.
    <key>com.ibm.sample</key>
  3. Add a description tag (optional).
  4. Add view tags and menu tags to define how users will access application features from within the VI Client.
  5. End the configuration file with the scriptConfiguration closing tags.

The VI Client can be extended in several distinct ways.

  • Icon buttons can be added to the toolbar.
  • Context-dependent menu items can be added to the VI Client under the inventory tree. There are several behavior display modes for context menu extensions:
    • Display attribute is not specified. If nothing is mentioned as <url>http://www.vmware.com</url> in the XML, then it opens the Web page in a new browser.
    • Window. A non-modal window (c# form) is opened and the URL is launched within the client.
    • Modalwindow. Same as above, except the dialog is modal.
    • None. Upon click of the menu the user wants to run a script without launching any UI. There will be neither a dialog nor the URL opening in a browser.
  • Tabs can be associated with specific inventory objects.

Listing 1 below shows a sample configuration file. The part highlighted in bold defines extension points on HostSystem. A new tab will show up on the right side, along with other tabs, whenever a HostSystem is selected in the inventory tree on the left side.

Listing 1. Extension is identified as a tab
   <scriptConfiguration version="1.0.0"> 
     <key>com.sample.demo1</key> 
     <description>Tab Demo</description> 
     <view parent="Inventory.HostSystem"> 
       <title locale="en">VI Plugin Demo1</title> 
       <url>http://www.vmware.com</url> 
     </view> 
    </scriptConfiguration>

The extension can also be defined as a right-click menu option. When a user right-clicks a HostSystem and selects the "Menu Demo" option, the VMware page will be displayed. Listing 2 shows an example.

Listing 2. Application is identified as a right-click menu option
<scriptConfiguration version="1.0.0"> 
  <key>com.sampel.demo2</key> 
  <description>Menu Demo</description> 
  <view parent="InventoryMenus.HostSystem"> 
    <title locale="en">VI Plugin Demo2</title> 
    <url>http://www.vmware.com</url> 
  </view> 
</scriptConfiguration>

To register the configuration file later, you should put the configuration file into the Web server directory. For example, the example file is at:

C:\ProgramFiles\Vmware\Infrastructure\tomcat\webapps\ROOT\sample.xml

Register the extension with vCenter Server

To register the plug-in with the VI API, use the RegisterExtension operations available through the ExtensionManager managed object. The plug-in becomes available to end users only after the configuration file and all other components are located on the Web servers, and after an Extension data object is registered with ExtensionManager. The Extension data object consists of metadata about the plug-in and the URL of its configuration file.

To register the extension with vCenter Server, you must create a client utility application or script that creates the necessary Description, ExtensionServerInfo, and ExtensionClientInfo data objects that populate the Extension data object with values on the server.

As mentioned, VMware offers the VI Perl Toolkit and VI Java API. Listing 3 shows the Perl sample code of plug-in registrations in Perl.

Listing 3. Plug-in registrations in Perl
 sub installPlugin {
 my ($description, $key, $pluginversion, $pluginurl, $company, $adminMail) = @_;
my ($desc, $serverInfo, $clientInfo, $extension);

	$desc = Description->new(
		label   => $description,
		summary => $description,
	);

	$serverInfo = ExtensionServerInfo->new(
		adminEmail  => [ $adminMail ],
		company     => $company,
		description => $desc,
		type        => "com.vmware.vim.viClientScripts",
		url         => $pluginurl,
	);

	$clientInfo = ExtensionClientInfo->new(
		version       => $pluginversion,
		company       => $company,
		description   => $desc,
		type          => "com.vmware.vim.viClientScripts",
		url           => "",
	);

	$extension = Extension->new(
		client      => [ $clientInfo ],
		server      => [ $serverInfo ],
		key         => $key,
		version     => $pluginversion,
		description => $desc,
		subjectName => $description,
		lastHeartbeatTime => "2012-12-23T00:00:00Z",
	);

	my $extensionManager = getExtensionManager();
	$extensionManager->RegisterExtension(extension => $extension);
	print "Plugin registered. Please restart VI Client before continuing.\n";
	return 0;
}

Listing 4 shows how to register the sample application plug-in in Java code.

Listing 4. Registering a plug-in with Java code
	public static Extension createExtensionObject(Properties props)
	{
		String companyStr = props.getProperty("companyStr");
		String descStr = props.getProperty("descStr"); 
		String keyStr = props.getProperty("keyStr");
		String extUrl = props.getProperty("extUrl");
		String adminEmail = props.getProperty("adminEmail");
		String version = props.getProperty("version");
		
		Description description = new Description(
				"", new DynamicProperty[] {}, 
				keyStr, descStr );

		ExtensionServerInfo esi = new ExtensionServerInfo(
				"", new DynamicProperty[]{},
				extUrl, description,	companyStr, 
				"com.vmware.vim.viClientScripts",
				new String[] { adminEmail } );

		// create Extension objects
		ExtensionClientInfo eci = new ExtensionClientInfo(
				"", new DynamicProperty[] {},
				version, description,
				companyStr, "com.vmware.vim.viClientScripts",
				"");
		
		Extension ext = new Extension(
				"", new DynamicProperty[] {},
				description, keyStr,
				version, "VC Extensibility",
				new ExtensionServerInfo[]{esi},
				new ExtensionClientInfo[] {eci},
				new ExtensionTaskTypeInfo[] {},
				new ExtensionEventTypeInfo[] {},
				new ExtensionFaultTypeInfo[] {},
				new ExtensionPrivilegeInfo[] {},
				new ExtensionResourceInfo[] {},
				Calendar.getInstance());
		return ext;
	}
…….
	public void registerExtension(Extension extension) throws RemoteException
	{
		if (extension == null) {
		    throw new NullPointerException();
		}
		vimService.registerExtension(getMOR(), extension);
	}
…….

After the plug-in has been registered with the vCenter Server ExtensionManager, the extended functions will be available to users who connect to the vCenter Server. The RegisterExtension method provides the Extension data object that includes the URL of the Web site containing the configuration file. If you move the configuration file to a new location after registering its URL, you will need to update the location by using the UpdateExtension operations with the new location. To remove a vSphere Client plug-in completely, use the UnregisterExtension operation.


Plug-in workflow at run time

Figure 2 shows an overview of the plug-in components and interactions at run time. The components interact over the Intranet in the following sequence.

  1. Users connect to the vCenter Server, as usual, using the vSphere Client.

    When users authenticate successfully to the vCenter Server, the SessionManager sends the vSphere Client a user session (sessionId) that identifies them to the system.

  2. The vCenter Server looks up the list of plug-ins registered with ExtensionManager, obtains the location of the configuration file, and redirects the vSphere Client to the location specified.

    These are the plug-ins available to users based on the permissions associated with their account.

  3. The vSphere Client gets the configuration file from the Web server. The vSphere Client parses the configuration file, obtaining the various components defined in the file from the location specified, and populates the UI with these components.
  4. When users select a menu item or click on a button for the plug-in, the vSphere Client connects to the Web server specified for the extension element in the configuration file. This sends context information in the URL, including the sessionId, moref, and other details in the string to the Web server.
    sessionId
    String value obtained by vSphere Client after logging into vCenter Server. The sessionId associates access to the plug-in application with the same privileges that were applied at initial login.
    moref
    Managed object reference of the entity selected in the vSphere client. The type of managed object reference and its values are separated by a colon (:).
    serviceUrl
    Server name and path to the Web server's API hosted on vCenter Server.
    Locale
    Name of the locale configured for the vSphere Client. Used for localizing content from the Web server.
Figure 2. Workflow at run time
A diagram showing the run time workflow. First, the Virtual Center points to the Configuration file and Web server A; Second, the Configuration file and Web server A point to the VI client; Third, Web server n points to the VI client. The Internet, intranet is represented by a cloud in the middle of the diagram.

For example, the HostSystem's power management plug-in invocation workflow is as follows.

  1. A user clicks on a physical host system in vSphere Client, the power management tab is displayed, and the URL string with current context information is passed (lines artificially broken to preserve format):
    http://dev:8000/powerManage.cgi?cmd=powerOn&moref=HostSystem:host-449&locale=zh_CN
    &serviceUrl=https://9.123.25.63:443/sdk
    &webServiceSessionId=073C0AB5F3FB11D97C51E438E416AA1
  2. Parse the sessionId and moref in the URL string and create a connection to the Web service. The sessionId associates access to the plug-in application to the same user as the vSphere Client's login user. The sessionId is returned to the client from the Web service and is then used transparently in the messages sent between client and server.

    After obtaining the Web server session token, parse it as follows and log in to the server by passing it a valid user account and password.

    vimService = serviceLocator.getVimPort(url);
    String cookieString = "vmware_soap_session=\"" + sessionId
       + "\"";
       org.apache.axis.client.Stub stub = (org.apache.axis.client.Stub) vimService;
    	stub._setProperty(
    org.apache.axis.transport.http.HTTPConstants.HEADER_COOKIE,
           cookieString);
    serviceContent = createServiceContent();
  3. Log in to the server using appropriate credentials.

    The VMware vSphere object model is a comprehensive set of robust server-side composite objects that provides complete management capabilities. The object model includes service interfaces for managing, monitoring, configuring, obtaining information, and controlling life-cycle operations associated with virtual infrastructures and object types. The PropertyCollector can be used to obtain reference to managed objects and values of the properties from managed objects.

    The moref refers to a managed object that has been selected in the URL string. The listing below shows a sample of parsing HostSystem's type and value from HostSystem's moref string.

    PropertyCollectorHelper pCollector = new PropertyCollectorHelper(
    	new URL(url), sessionId);
    ManagedObjectReference hostMor = new ManagedObjectReference();
    String hostMorType = hostMorStr.substring(0, hostMorStr
    	.indexOf(":"));
    String hostMorValue = hostMorStr
    	.substring(hostMorStr.indexOf(":") + 1);
    hostMor.setType(hostMorType);
    hostMor.set_value(hostMorValue);
  4. Process the objects, which will display the Power Management Web page for the selected HostSystem.
  5. Close the connection.

Resources

Learn

Get products and technologies

Discuss

  • My developerWorks: Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Web development on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Web development
ArticleID=488128
ArticleTitle=Create and manage vCenter Server plug-ins
publish-date=05112010