Technical Note
VMware, Inc. 1
Customizing the vSphere ClientVMware vSphere Web Services SDK 4.1
TheExtensionManagerserviceinterfacesupportscentralizedmanagementofplugins(sometimescalledextensions)forvCenterServersystems.Pluginshavebothserverandclientcomponents.AserverplugincomponentextendsvCenterServercapabilityinsomeway.Forexample,theexperimentalStorageMonitoringService(SMS)providedwithvCenterServer4.1hasaserverplugincomponentthatusesinformationfromthevCenterServerdatabasetoprovideinformationaboutstorage.SMShasaclientcomponentthatextendsthevSphereClientwithtextandgraphicaluserinterface(GUI)itemsthatsupportuserinteractionwiththeserver.SMSreportsaboutstorageareavailableonastoragetabandinseveralcontextmenusinthevSphereClient.BoththeTheExtensionManagercontainstheinformationneededbybothserverandclienttosupportthefeaturesofanyspecificplugin.YoucanusetheExtensionManagerinanapplicationtoaddyourownproductspecificmenuselections,tabs,toolbar,andviewiconstothevSphereClient.Forexample,youmightaddacustombuttonthatdirectsuserstoyourcompanyWebsite,invokesaJSPapplication,orexecutesascriptonthevCenterServer.ThepluginsyoucreatemustbedefinedinaconfigurationfileandregisteredwiththeExtensionManagerasdescribedinthisdocument.ThistypeofpluginissometimescalledascriptingpluginbecauseitsupportsrunningscriptsonthevCenterServer,fromavSphereClient.ScriptingpluginshaveanExtensionobjectthatspecifiesserverextensiontypeofcom.vmware.vim.viClientScripts.Scriptingpluginsrequirethatallcomponents,includingtheconfigurationfile,areavailableusingtheHTTP/HTTPSprotocol,withtheirlocationsspecifiedasURLs.ThistechnicalnotedoesnotincludeinformationaboutcustomizingtheUIbyusingC#orotherlibrariesthatmakeupthevSphereClient.Thisdocumentincludesthefollowingtopics: OverviewofvSphereClientPlugInsonpage 1 UnderstandingvSphereClientUIExtensionPointsonpage 3 CreatingtheConfigurationFileonpage 7 OverviewoftheExtensionManagerManagedObjectonpage 11 RegisteringtheExtensiononpage 11
Overview of vSphere Client Plug-InsYouextendthevSphereClientbyidentifyingtheWebserverbasedapplications,scripts,orothercomponentsthatyouwanttomakeavailablethroughthevSphereClient.YoucreateaconfigurationfilethatreferenceseachofthecomponentsandidentifieswhereinthevSphereClienteachshoulddisplayatruntime.Intheconfigurationfile,youdefineeachofthesecomponentsasanextensionelement.UsingtheattributesandotherelementsdefinedinCreatingtheConfigurationFileonpage 7,youconfigurethepropertiesofeachextensionelement,includingtheURLoftheWebserverwherethecomponentislocated.Forexample,forascriptthatrunsonthevCenterServer,theextensionelementdefinedintheconfigurationfileincludestheURLofthevCenterServerwiththeappropriatesyntaxforrunningthescript.
VMware, Inc. 2
Customizing the vSphere Client
Finally,youregisterinformationabouttheplugin,includingthelocationoftheconfigurationfile,withtheExtensionManageronthevCenterServer.YoucancreateaJavaorC#utilitytoregistertheplugin,orascript,oryoucanusetheMOB(ManagedObjectBrowser).ForinformationaboutusingtheMOB,seethevSphereWebServicesSDKProgrammingGuide.Atruntime,thesecomponentsinteractovertheintranetinthefollowingsequence:1 UsersconnecttothevCenterServerastheyalwaysdo,usingthevSphereClient.Whenusersauthenticate
successfullytovCenterServer,theSessionManagersendsthevSphereClientausersession(sessionId)thatidentifiesthemtothesystem.
2 ThevCenterServerlooksupthelistofpluginsregisteredwithExtensionManager,obtainsthelocationoftheconfigurationfile,redirectsthevSphereClienttothelocationspecified.Thesearethepluginsavailabletousersbasedonthepermissionsassociatedwiththeiraccount.
3 ThevSphereClientobtainstheconfigurationfilefromtheWebserver.ThevSphereClientparsestheconfigurationfile,obtainingthevariouscomponentsdefinedinthefilefromthelocationsspecified,andpopulatingtheUIwiththesecomponents.
4 Whenusersselectamenuitemorclickonabuttonforyourplugin,thevSphereClientconnectstotheWebserverspecifiedforthatextensionelementintheconfigurationfile,sendingcontextinformation,includingthesessionIdandotherdetailslistedinTable 1inthestringtotheWebserver.
TheentireprocessistransparenttovSphereClientendusers.However,endusersofyourplugincanenableordisableitsfunctionalitybyusingtheManagePlugins...menuselectioninthevSphereClient.Forexample,theStorageViewstabdisplayswhentheStorageMonitoringServicepluginisenabled,butisremovedfromtheUIwhenusersdisabletheplugin.
Requirements YoucanimplementtheWebserverfunctionalityusinganyofthefollowingprogramminglanguages: JavaServletsorJavaServerPages(JSPs) MicrosoftActiveServerPages(ASP.NET) TraditionalCGIScripting StaticordynamicHTMLpagesYourpluginmayalsoinvokevCenterServerscriptsandscriptsonvirtualmachines.TheguestOSonthevirtualmachinemusthaveVMwareToolsinstalledtosupportscripting.IfyourpluginincludesascriptorWebapplication,thescriptorapplicationmustbeabletoparsethestringthatissenttoitbythevSphereClient.Forexample,ifthepluginexecutesascriptonthevCenterServerthatpowercyclesvirtualmachines,theURLspecifiedfortheextensionelementintheconfigurationfilemightlooklikethefollowingexample:http://dev:8000/vmAction.cgi?cmd=powerOn
Table 1liststheotherparametersinthestring.Table 1. vSphere Client Session Context Parameters
Parameter Description Example
sessionId StringvalueobtainedbyvSphereClientafterloggingintovCenterServer.Thesessionidassociatesaccesstothepluginapplicationwiththesameprivilegesaswereappliedatinitiallogon.
sessionId=9241E7B8A37B4264A8D1945628F9E0D6
moref Managedobjectreferenceoftheentityselectedintheclient.Thetypeofmanagedobjectreferenceanditsvalueareseparatedbyacolon(:).
moref=VirtualMachine:16
VMware, Inc. 3
Customizing the vSphere Client
YourapplicationorscriptmustbeabletoparseastringconsistingoftheparametersshowninTable 1.Forexample,iftheextensionrunsascriptonthevCenterServer,thefullstringmightlooklikethefollowingstring:http://dev:8000/vmAction.cgi?cmd=powerOn&moref=VirtualMachine:16&sessionId=9241E7B8-A37B-4264-A8D
1-945628F9E0D6&locale=en&serviceUrl=https://localhost/sdk
Understanding vSphere Client UI Extension PointsThevSphereClientistheprincipaluserinterfaceforadministeringvCenterServerandESX/ESXi.PluginsarenotsupportedonESX/ESXisystems.ThevSphereClientuserinterfaceconfigurationisdynamicinthatitvariesdependingonthespecificsoftheservertowhichitisconnected.WhentheserverisavCenterServersystem,thevSphereClientdisplaysalltheoptionsavailabletothevSphereenvironmentasdefinedinthelicensingconfigurationanduserpermissions,includingplugins.WhenusersfirstlogintoavCenterServersystemfromthevSphereClient,itdisplaysaHomepagewithiconsforaccessingvariousvSphereClientfunctions.WhenuserslogoutofthevCenterServer,thevSphereClientretainstheclosingview.ThenexttimeuserslogintovCenterServer,theyarereturnedtothelastviewthatwasdisplayed.EachofthefollowingareasofthevSphereClienthasspecificplaces,calledextensionpoints,thatyoucanextendwiththespecificUIcomponentsforyourplugin: Homeview Inventoryviews Mainmenus Inventorymenus Toolbars
ListsofextensionpointsavailableineachoftheseareasarecontainedinTable 2throughTable 6startingonpage 4.TocustomizetheUIatoneoftheseextensionpoints,youaddanextensionelementtotheconfigurationfileandsetitsparentattributetotheappropriateextensionpoint.SeeCreatingtheConfigurationFileonpage 7forcompleteinformation.
vSphere Client Home View
ThevSphereClienthomeviewdisplaysshortcutsforInventory,Administration,Management,andApplicationsfeatures.TheextensionpointsdefinedforthisviewincludetheHomeView.Inventory,HomeView.Admin,andHomeView.ManagementasshowninFigure 1,aswellasHomeView.Applications.Toaddanicontooneoftheseareas,youdefineanextensionelementintheconfigurationfileandsettheparentattributeoftheelementtotheappropriateextensionpoint.OtherdetailsabouthowtocreatetheconfigurationanddefinetheelementsneededareincludedinCreatingtheConfigurationFileonpage 7.
serviceUrl ServernameandpathtotheWebservicesAPIhostedonvCenterServer.
serviceUrl=https://serverFQDN/sdk
locale NameofthelocaleconfiguredforthevSphereClient.UsedforlocalizingcontentfromtheWebserver.
locale=enlocale=jalocale=de
Table 1. vSphere Client Session Context Parameters
Parameter Description Example
VMware, Inc. 4
Customizing the vSphere Client
Figure 1. vSphere Client Home View and Some Extension Points
Table 2liststheavailableviewareasanddefinedextensionpoints.
vSphere Client Inventory View
ThevSphereClientinventoryviewdisplaysentitiesavailableintheinventoryinitsleftpaneandtheoperationsavailableforselectedinventoryentitiesinitsrightpane.Youcanaddatabtothisviewbyassociatingitwithoneoftheinventoryobjectsintheleftpane.Figure 2. vSphere Client Inventory View
ToaddaTabthatdisplaysintherightpaneforaspecificinventoryobject,youmustaddanextensiontotheconfigurationfilethatdefinestheparentattributeastheappropriateextensionpointfromamongtheInventoryView.*extensionpointslistedinTable 3.
Table 2. Home View Extension Points
Display area of home view Set parent attribute to extension point
Administration HomeView.AdminApplications HomeView.ApplicationsInventory HomeView.InventoryManagement HomeView.Management
VMware, Inc. 5
Customizing the vSphere Client
vSphere Client Context Menus
ThemenuoptionsandUIitemsavailableonthevSphereClientchangeasdifferentmanagedobjectsareselectedintheleftpaneoftheinterface,orasdifferentmenuchoicesaremadeinthemainmenu,atthetopofthedisplay.Forexample,Figure 3showsthedefaultcontextmenuavailableforvirtualmachinesfromtheInventorymenuofthevSphereClient.Figure 3. vSphere Client Inventory Context Menu
Youcanextendthemenusavailableatanymanagedobjectbyusingoneofthecontextualextensionpointslistedinthetables.AddoneextensionelementforeachtypeofcontextmenuyouwanttoaddtotheUI.ToaddcustomcontextmenustothetopmenuoftheUI,usetheextensionpointslistedinTable 4.
Table 3. InventoryView Extension Points
Inventory object to associate with the Tab Set parent attribute to extension point
Cluster InventoryView.ClusterDatacenter InventoryView.DatacenterDatacenterFolder InventoryView.DatacenterFolderDatastore InventoryView.DatastoreDatastoreFolder InventoryView.DatastoreFolderDVS InventoryView.DistributedVirtualSwitchHost InventoryView.HostSystemHostFolder InventoryView.ComputeResourceFolderNetwork InventoryView.NetworkNetworkFolder InventoryView.NetworkFolderResourcePool InventoryView.ResourcePoolTemplate InventoryView.TemplateVirtualMachine InventoryView.VirtualMachineVirtualMachineFolder InventoryView.VirtualMachineFolderVirtualApp InventoryView.VirtualApp
VMware, Inc. 6
Customizing the vSphere Client
ToaddcustomcontextmenustotheleftpaneoftheUI,usetheextensionpointslistedinTable 5.
vSphere Client Inventory Toolbars
TheToolbarsthatdisplayintheUIarespecifictothemanagedobjectselectedinthelefthandpane.ToaddanicontotheToolbarassociatedwiththeappropriateinventoryobject,addanextensionelementtotheconfigurationfilethatdefinestheparentattributeusingtheappropriateextensionpointfromTable 6.IncludeaniconSmallerelementthatspecifiestheURLlocationoftheicon(theimagefile).
Table 4. Main Menu Extension Points
Inventory object for the menu Set parent attribute to extension point
Administration MainMenus.AdministrationEdit MainMenus.EditFile MainMenus.FileFile_Export MainMenus.File_ExportFile_New MainMenus.File_NewFile_Report MainMenus.File_ReportHelp MainMenus.HelpInventory MainMenus.InventoryPlugins MainMenus.PluginsView MainMenus.ViewView_Inventory MainMenus.View_Inventory
Table 5. Inventory Menu Extension Points
Inventory object for the menu Set parent attribute to extension point
Cluster InventoryMenus.ClusterDatacenter InventoryMenus.DatacenterDatacenterFolder InventoryMenus.DatacenterFolderDatastore InventoryMenus.DatastoreDatastoreFolder InventoryMenus.DatastoreFolderDVS InventoryMenus.DistributedVirtualSwitchHost InventoryMenus.HostSystemHostFolder InventoryMenus.ComputeResourceFolderNetwork InventoryMenus.NetworkNetworkFolder InventoryMenus.NetworkFolderResourcePool InventoryMenus.ResourcePoolRole InventoryMenus.RoleScheduledTasks InventoryMenus.ScheduledTasksTasks InventoryMenus.TasksTemplate InventoryMenus.TemplateVirtualMachine InventoryMenus.VirtualMachineVirtualMachineFolder InventoryMenus.VirtualMachineFolderVirtualApp InventoryMenus.VirtualApp
VMware, Inc. 7
Customizing the vSphere Client
Creating the Configuration FileTheconfigurationfileisaplaintextfilecontainingtheseriesofXMLelementsandattributesthatspecifyyourcustomizations.ThefilemustcomplywithaformatspecifiedbyVMware.YoudonotneedtouseanXSD,butyoumustfollowtherulesdefinedinthissection.Table 7listsvalidelementsintheorderinwhichtheyshouldbedefinedinthefile,andExample 1showsacompleteexamplethatyoucanuseatemplate.ApluginconfigurationfilemaycontainanextensionelementforeachUIitemrequiredtosupportuserinteraction.However,whenaddingmenu,icon,andotherUIitemstothevSphereClient,followsomebasicguidelines.TakeintoaccountthelookandfeelofthevSphereClient.Usesimilarfonts,fontsizes,andcolorschemesforiconsandothergraphicaluserinterface(GUI)components.DonotaddtoomanyiconstotheToolbar.
Table 6. Toolbar Extension Points
Inventory object to associate with the Toolbar Set parent attribute to extension point
Cluster Toolbars.ClusterDatacenter Toolbars.DatacenterDatacenterFolder Toolbars.DatacenterFolderDatastore Toolbars.DatastoreDatastoreFolder Toolbars.DatastoreFolderDVS Toolbars.DistributedVirtualSwitchHost Toolbars.HostSystemHostFolder Toolbars.ComputeResourceFolderNetwork Toolbars.NetworkNetworkFolder Toolbars.NetworkFolderResourcePool Toolbars.ResourcePoolTemplate Toolbars.TemplateVirtualMachine Toolbars.VirtualMachineVirtualMachineFolder Toolbars.VirtualMachineFolderVirtualApp Toolbars.VirtualApp
Table 7. Configuration File Elements
Element Description
scriptConfiguration Required.ContainingelementforvSphereClientUIextensionsthatsupportscriptingplugins.Thetagmustidentifythisasthefirstelementinthefile,withtheclosingtag()lastinfile.Theversionattributeisrequired.ItidentifiestheversionoftheplugintovSphereClientfromamongpossiblymultipleversionsoftheplugin.
supportNonSecureCommunication Optional.FornonsecureHTTPconnectionsbetweenthevSphereClientandandthepluginWebserverthatisidentifiedbytheurlelementofanextensionelement.Seethedescriptionoftheurlelementbelow.WhenthevSphereClientestablishesasecureconnectiontoapluginWebserver,theClientwillpasssessionIdandwebServicesSessionIdvaluesintheHTTPSrequest.IftheextensionelementspecifiesastandardHTTPconnection,bydefaultthevSphereClientdoesnotpassthesessionidentifierstothepluginserver.ToincludesessionidentifiersinastandardHTTPrequest,usethefollowingstatementinyourconfigurationfile.true
key Required.Uniquestringthatidentifiestheplugin.Onlyonekeyelementperfileallowed.StringvalueforkeymustbeuniqueamongallextensionsonthevCenterServer.VMwarerecommendsusingJavapackagenamingconventionforthekeyvalue,suchascom.yourcompany.yourpluginname.
VMware, Inc. 8
Customizing the vSphere Client
multiVCsupported Specifieswhethertodisplay(true)thevCenterServerselectorornot(false).OnlyonemultiVCsupportedelementallowedperconfigurationfile.
description Optional.Descriptionofyourplugin.Onlyoneperfileallowed.ThisdescriptiondisplaysinthePluginManagerofthevSphereClient.
name Optional.NameofyourpluginthatdisplaysinthevSphereClientPluginsManager.
vendor Optional.Yourcompanyname.extension Filemustcontainatleastoneoftheseelementsdefiningtheextensionpointwith
whichtoassociatetheUIitem.Anextensionelementrequiresaparentattributesettotheappropriateextensionpoint.ValidextensionpointsarelistedinTable 2,Table 3,Table 4,Table 5,Table 6,andTable 7.Optionalattributesforextensionincludeprivilegeandtreestyle.Usetheprivilegeattributetoassociateoneormoreprivilegerequirementswiththeextension.Forexample,.YoucanusethetreestyleattributewithMainView.*andInventoryView.*extensionpointstolimitthepositioningoftheextensionelementtotheleftpaneundertheappropriateinventoryitem.Thetreestyleattributesupportsthefollowingoptions: Physical Virtual Datastores NetworkEachextensionelementmustbefollowedbyatitleelementandaurlelement.Eachextensionelementmayalsocontainicon,iconSmaller,andoneormorecustomAttributeelementsasappropriatefortheextensionpoint.Multipleextensionelementscanbenested,tocreatemultilevelcontextmenus.SeeExample 2,ComprehensiveConfigurationFileforPlugIn,onpage 10.
title ThetitlethatdisplaysinthevSphereClientviewwindowwhentheextensionisactivated.Eachtitleelementhasalocaleattributethatmustbeset.Forexample,,,or.
url FullyqualifiedWebserverlocationofthescript,Webapplication,icon,button,orothercomponentfortheplugin.Requiredforeachextensionelementdefinedinthefile.Optionaldisplayattributefinetunestheactiontakenonthespecifiedpluginusingoneofthefollowingsettings: windowOpentheURLinanewwindowinsidethevSphereClient. modalwindowNotsupportedforscriptingplugins.Opensnewwindow
thatsupportsawizard. noneExecutethescriptlocatedattheURL.
iconSmaller AURLcontaininga16x16pixelimage(.giffile)fordisplayataToolbar.*orInventoryView.*extensionpoint.
icon AURLcontaininga32x32pixelimage(.giffile)fordisplayinaHomeView.*extensionpoint.
customAttribute Optional.Associatesamenuorviewwithacustomattributedefinedforthemanagedobjectontheserver.SetthenameattributeofacustomAttributetothenameofacustomattributedefinedonthemanagedobject.
Table 7. Configuration File Elements (Continued)
Element Description
VMware, Inc. 9
Customizing the vSphere Client
Forexample,toaddatabtothevSphereClientthatdisplaysintherightpanewhenusersselectavirtualmachineintheleftpaneoftheUI,defineanextensionintheconfigurationfilethatusesthefollowingtemplate:...
Tab Title Herehttp://path/to/your/plugin/component/to/open/in/tab/pane
...
Example 1showsaminimalconfigurationfilethataddsasmallicontodifferentlocationsonthevSphereClientwithalinktotheVMwarevSphereAPIReferenceGuideontheVMwareWebsite.Example 3,UsingthevSphereAPItoRegisteravSphereClientPlugin,onpage 12providestheJavaclientthatregisterstheURLforthelocationofthisfile.
Tocreatetheconfigurationfile,youcanuseanytexteditor.However,VMwarerecommendsusingaXMLeditor,suchasAltovaXMLSpy,toensureyoucreateawellformedXMLfile.IftheXMLfileisnotformedcorrectly,thevSphereClientcannotloadit.ThePlugInManagerofthevSphereClientdisplayserrormessagesaboutthefailure,butdoesnotprovidedebugginginformation.Seehttp://www.altova.comforinformationaboutXMLSpy.Example 2isacompleteconfigurationfilethatdefinesseveraldifferentextensions,includingiconsandmenus,fordemonstrationpurposes.
Example 1. Minimum Configuration File
VMware, Inc. 10
Customizing the vSphere Client
Example 2. Comprehensive Configuration File for Plug-In
-
com.vmware.test Test script plug-in vSphere Client 4.1 Extension Points example VMware, Inc. false - -
VMware http://vmware.com http://fqdn/path/to/plugin/component/scsi.png http://fqdn/path/to/plugin/component/scsi_small.png
- -
Custom Template http://fqdn/path/to/plugin/component/a.html
- -
Custom http://fqdn/path/to/plugin/component/a.html
- A1 A2
-- Test http://fqdn/path/to/plugin/component/a.html - Plugin button http://fqdn/path/to/plugin/component/a.html --> http://fqdn/path/to/plugin/component/scsi_small.png - - Plug-in menu item http://www.google.com/search?q=Distributed%20Virtual%20Switch - - Nested menu-item - http://www.google.com/ - - Level 1 - a - - Level 2 - a http://www.google.com/ - - Level 2 - bhttp://www.google.com/ - - Level 1 - b http://www.google.com/ - - Level 1 - c http://www.google.com/
VMware, Inc. 11
Customizing the vSphere Client
Overview of the ExtensionManager Managed ObjectExtensionManageristheserviceinterfaceforregisteringplugins.TheExtensionManagerhasasingleproperty,extensionList,thatisdefinedasanarrayofextensionsregisteredwiththevCenterServer.WhenyouregisteryourpluginwiththevCenterServer,itgetsaddedtothisarray.TheExtensiondataobjectcontainsmetadataabouteachextension(plugin),includingitslocationandtype,andotherdetails.Figure 4. ExtensionManager and Extension Data Object
ManyExtensionpropertiesareoptional.Forexample,thesubjectNameisusedonlyifclientcertificatesmustbehandledbytheplugin.SeetheVMwarevSphereAPIReferenceGuideforcompleteinformationaboutExtensionManagerandExtension.ForinformationaboutthevSphereClientextensionssupportedinVISDK2.5,gotohttp://www.vmware.com/support/developer/vcsdk/vcpluginexp/index.html.
Registering the ExtensionYourpluginbecomesavailabletoendusersonlyaftertheconfigurationfileandallothercomponentshavebeenlocatedontheWebservers,andanExtensiondataobjectisregisteredwithExtensionManager.TheExtensiondataobjectconsistsofmetadataaboutthepluginandtheURLofitsconfigurationfile.WhenendusersconnecttovCenterServerfromvSphereClient,theplugincomponentsaredispatchedtovSphereClientasdescribedinOverviewofvSphereClientPlugInsonpage 1.ToregistertheextensionwithvCenterServer,youcreateaclientutilityapplicationorscriptthatcreatesthenecessaryDescription,ExtensionServerInfo,andExtensionClientInfodataobjectsthatpopulatetheExtensiondataobjectwithvaluesontheserver.Asanalternative,youcanusetheMOBtosubmitthesamedataobjectsintheirXMLform.Example 3providesacompleteJavaapplicationthatregistersthesampleextensiondefinedinExample 1.ThesampleextensionconsistsofaniconforthevSphereAPIReferenceGuideandalinktoitslocationontheVMwareWebsite.ThissampleissupportedonvCenterServer4.0andlater.Whetheryouuseascript,aclientapplication,ortheMOBtoregisteryourplugin,oneofthemostimportantdetailsinExample 3thatisapplicabletoanyextensionsyoucreateisthatyoumustsetthetypepropertyoftheExtensionServerInfotothefollowingspecificpackagename:com.vmware.vim.viClientScripts
VMware, Inc. 12
Customizing the vSphere Client
Updating or Removing Plug-InsTheRegisterExtensionmethodtakesanExtensiondataobjectthatincludestheURLoftheWebsitecontainingtheconfigurationfile.IfyoumovetheconfigurationfiletoanewlocationafterregisteringitsURL,youwillneedtoupdatethelocationbyusingtheUpdateExtensionoperationwiththenewlocation.ToremoveavSphereClientPlugincompletely,usetheUnregisterExtensionoperation.Example 3showsaJavaclientthatregisterstheURLforthelocationoftheconfigurationfileExample 3. Using the vSphere API to Register a vSphere Client Plug-in
import com.vmware.vim25.*;import java.net.URL;import java.util.*;public class PubsRegisterPlugin {
private ManagedObjectReference _svcRef;private VimServiceLocator _locator;private VimPortType _service;private ServiceContent _sic;private String companyStr = "VMware, Inc.";private String descStr = "SDK Pubs documentation page";private String keyStr = "com.vmware.vSphereWebServicesSDK.API ReferenceGuide";private String ext_url = "http://www.vmware.com/support/developer/vc-sdk/pubsplugin.xml";private String adminEmail = "[email protected]";private String versionStr = "1.0";private void createServiceRef() throws Exception {
_svcRef = new ManagedObjectReference();_svcRef.setType("ServiceInstance");_svcRef.set_value("ServiceInstance"); }
private void connectLoginRegister(String hostName, String userName, String password) throws Exception {
System.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");String url = "https://"+hostName+"/sdk/vim";Description description = new Description();
description.setLabel("vSphere Web Services SDK Main Documentation Page");description.setSummary(descStr);
ExtensionServerInfo esi = new ExtensionServerInfo();esi.setUrl(ext_url);esi.setDescription(description);esi.setCompany(companyStr);esi.setType("com.vmware.vim.viClientScripts");esi.setAdminEmail(new String[] {adminEmail});
ExtensionClientInfo eci = new ExtensionClientInfo();eci.setVersion(versionStr);eci.setDescription(description);eci.setCompany(companyStr);eci.setType("com.vmware.vim.viClientScripts");eci.setUrl(ext_url);
Extension ext= new Extension();ext.setDescription(description);ext.setKey(keyStr);ext.setVersion(versionStr);ext.setSubjectName("blank");ext.setServer(new ExtensionServerInfo[] {esi});ext.setClient(new ExtensionClientInfo[] {eci});ext.setLastHeartbeatTime(Calendar.getInstance());
createServiceRef();_locator = new VimServiceLocator();_locator.setMaintainSession(true);_service = _locator.getVimPort(new URL(url));_sic = _service.retrieveServiceContent(_svcRef);if (_sic.getSessionManager() != null) {
_service.login(_sic.getSessionManager(), userName, password, null);ManagedObjectReference extMgrMof = _sic.getExtensionManager();_service.registerExtension(extMgrMof, ext);}
}
13
Customizing the vSphere Client
If you have comments about this documentation, submit your feedback to: [email protected]
VMware, Inc. 3401 Hillview Ave., Palo Alto, CA 94304 www.vmware.comCopyright 2009, 2010 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
Item: EN-000218-00
public static void main(String [] args) throws Exception {PubsRegisterPlugin obj = new PubsRegisterPlugin();String serverName = args[0];String userName = args[1];String password = args[2];obj.connectLoginRegister(serverName, userName, password);
}} //PubsRegisterPlugin class
Overview of vSphere Client Plug-InsRequirements
Understanding vSphere Client UI Extension PointsvSphere Client Home ViewvSphere Client Inventory ViewvSphere Client Context MenusvSphere Client Inventory Toolbars
Creating the Configuration FileOverview of the ExtensionManager Managed ObjectRegistering the ExtensionUpdating or Removing Plug-Ins