Sie sind auf Seite 1von 12

Technical Note

Customizing the vSphere Client


VMware vSphere Web Services SDK 4.0
TheExtensionManageristheserviceinterfacethatsupportscentralizedmanagementofplugins(sometimes calledextensions)forvCenterServersystems.Pluginshavebothserverandclientcomponents.Theserver componentaugments,enhances,orextendsvCenterServerfunctionalityinsomeway.Forexample,the experimentalStorageMonitoringServiceprovidedwithvCenterServer4.0leveragesinformationfromthe vCenterServerdatabasetoprovidereportinglevelservicesaboutstorage. Textandgraphicaluserinterface(UI)itemsextendthevSphereClienttosupportuserinteractionwiththe server.Forexample,reportsaboutstorageareavailableonastoragetabandseveralcontextmenusinthe vSphereClient.TheExtensionManagerhousestheinformationneededbybothserverandclienttosupport thefeaturesofanyspecificplugin. TheExtensionManagerenablesdevelopersofWebbasedapplicationsandscriptstocustomizethevSphere Clientwiththeirownproductspecificmenuselections,tabs,ortoolbar,andviewicons.Forexample,you mightaddacustombuttontothevSphereClientthatdirectsuserstoyourcompanyWebsite,invokesaJSP application,orexecutesascriptonthevCenterServer.Thepluginsyoucreatemustbedefinedina configurationfileandregisteredwiththeExtensionManagerasdescribedinthischapter. ThistypeofpluginissometimescalledascriptingpluginbecauseitsupportsrunningscriptsonthevCenter Server,fromavSphereClient.ScriptingpluginshaveanExtensionobjectthatspecifiesserverextensiontype ofcom.vmware.vim.viClientScripts.Scriptingpluginsrequirethatallcomponents,includingthe configurationfile,areavailableusingtheHTTP/HTTPSprotocol,withtheirlocationsspecifiedasURLs. ThistechnicalnotedoesnotincludeinformationaboutcustomizingtheUIbyusingC#orotherlibrariesthat makeupthevSphereClient.Thisdocumentincludesthefollowingtopics:

UnderstandingvSphereClientUIExtensionPointsonpage 3 CreatingtheConfigurationFileonpage 7 OverviewoftheExtensionManagerManagedObjectonpage 10 RegisteringtheExtensiononpage 10

Overview of vSphere Client Plug-Ins


YouextendthevSphereClientbyidentifyingtheWebserverbasedapplications,scripts,orothercomponents thatyouwanttomakeavailablethroughthevSphereClient.Youcreateaconfigurationfilethatdefineseach ofthecomponentsandidentifieswhereinthevSphereClienteachshoulddisplayatruntime.Inthe configurationfile,youdefineeachofthesecomponentsasanextensionelement.Usingtheattributesand otherelementsdefinedinCreatingtheConfigurationFileonpage 7,youconfigurethepropertiesofeach extensionelement,includingtheURLoftheWebserverwherethecomponentislocated.Forexample,fora scriptthatrunsonthevCenterServer,theextensionelementdefinedintheconfigurationfileincludestheURL ofthevCenterServerwiththeappropriatesyntaxforrunningthescript.Finally,youregisterinformation abouttheplugin,includingthelocationoftheconfigurationfile,withtheExtensionManageronthevCenter Server.YoucancreateaJavaorC#utilitytoregistertheplugin,orascript,oryoucanusetheMOB.

VMware, Inc.

Customizing the vSphere Client

Atruntime,thesecomponentsinteractovertheintranetinthefollowingsequence: 1 UsersconnecttothevCenterServerastheyalwaysdo,usingthevSphereClient.Whenusersauthenticate successfullytovCenterServer,theSessionManagersendsthevSphereClientausersession(sessionId) thatidentifiesthemtothesystem. ThevCenterServerlooksupthelistofpluginsregisteredwithExtensionManager,obtainsthelocation oftheconfigurationfile,redirectsthevSphereClienttothelocationspecified.Thesearetheplugins availabletousersbasedonthepermissionsassociatedwiththeiraccount. ThevSphereClientobtainstheconfigurationfilefromtheWebserver.ThevSphereClientparsesthe configurationfile,obtainingthevariouscomponentsdefinedinthefilefromthelocationsspecified,and populatingtheUIwiththesecomponents. Whenusersselectamenuitemorclickonabuttonforyourplugin,thevSphereClientconnectstothe Webserverspecifiedforthatextensionelementintheconfigurationfile,sendingcontextinformation, includingthesessionIdandotherdetailslistedinTable 1inthestringtotheWebserver.

TheentireprocessistransparenttovSphereClientendusers.However,endusersofyourplugincanenable ordisableitsfunctionalitybyusingtheManagePlugins...menuselectioninthevSphereClient.Forexample, theStorageViewstabdisplayswhentheStorageMonitoringServicepluginisenabled,butisremovedfrom theUIwhenusersdisabletheplugin.

Requirements
YoucanimplementtheWebserverfunctionalityusinganyofthefollowingprogramminglanguages:

JavaServletsorJavaServerPages(JSPs) MicrosoftActiveServerPages(ASP.NET) TraditionalCGIScripting StaticordynamicHTMLpages

YourpluginmayalsoinvokevCenterServerscriptsandscriptsonvirtualmachines.TheguestOSonthe virtualmachinemusthaveVMwareToolsinstalledtosupportscripting. IfyourpluginincludesascriptorWebapplication,thescriptorapplicationmustbeabletoparsethestring thatissenttoitbythevSphereClient.Forexample,ifthepluginexecutesascriptonthevCenterServerthat powercyclesvirtualmachines,theURLspecifiedfortheextensionelementintheconfigurationfilemightlook likethefollowingexample:


http://dev:8000/vmAction.cgi?cmd=powerOn

Table 1liststheotherparametersinthestring. Table 1. vSphere Client Session Context Parameters


Parameter sessionId Description StringvalueobtainedbythevSphereClientafterlogginginto vCenterServer.ThesessionIdassociatesaccesstotheplugin applicationwiththesameprivilegesthatwereappliedat initiallogon. Managedobjectreferenceoftheentityselectedintheclient. Thetypeofmanagedobjectreferenceanditsvalueare separatedbyacolon(:). ServernameandpathtotheWebservicesAPIhostedonthe vCenterServer. NameofthelocaleconfiguredforthevSphereClient.Usedfor localizingcontentfromtheWebserver. Example sessionId=9241E7B8A37B4264A8D1 945628F9E0D6

moref

moref=VirtualMachine:16

serviceUrl locale

serviceUrl=https://serverFQDN/sdk locale=en locale=ja locale=de

VMware, Inc.

Customizing the vSphere Client

YourapplicationorscriptmustbeabletoparseastringconsistingoftheparametersshowninTable 1.For example,iftheextensionrunsascriptonthevCenterServer,thefullstringmightlooklikethefollowing:


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 Points


ThevSphereClientistheprincipaluserinterfaceforadministeringvCenterServerandESX/ESXi.Pluginsare notsupportedonESX/ESXisystems.ThevSphereClientuserinterfaceconfigurationisdynamicinthatit variesdependingonthespecificsoftheservertowhichitisconnected.WhentheserverisavCenterServer system,thevSphereClientdisplaysalltheoptionsavailabletothevSphereenvironmentasdefinedinthe licensingconfigurationanduserpermissions,includingplugins. WhenusersfirstlogintoavCenterServersystemfromthevSphereClient,itdisplaysaHomepagewithicons foraccessingvariousvSphereClientfunctions.WhenuserslogoutofthevCenterServer,thevSphereClient retainstheclosingview.ThenexttimeuserslogintovCenterServer,theyarereturnedtothelastviewthat wasdisplayed. EachofthefollowingareasofthevSphereClienthasspecificplaces,calledextensionpoints,thatyoucan extendwiththespecificUIcomponentsforyourplugin:

Homeview Inventoryviews Mainmenus Inventorymenus Toolbars

ThevSphereClientuserinterfacechangesaccordingtowhichextensionpointsyouregister.Forexample,with inventoryviews,anewtabappears,whereaswithinventorymenus,anewmenuitemappears. ListsofextensionpointsavailableineachoftheseareasarecontainedinTable 2throughTable 6startingon page 4.TocustomizetheUIatoneoftheseextensionpoints,youaddanextensionelementtotheconfiguration fileandsetitsparentattributetotheappropriateextensionpoint.SeeCreatingtheConfigurationFileon page 7forcompleteinformation.

vSphere Client Home View


ThevSphereClienthomeviewdisplaysshortcutsforInventory,Administration,Management,and Applicationsfeatures.TheextensionpointsdefinedforthisviewincludetheHomeView.Inventory, HomeView.Admin,andHomeView.ManagementasshowninFigure 1,aswellasHomeView.Applications. Figure 1. vSphere Client Home View and Some Extension Points

VMware, Inc.

Customizing the vSphere Client

Toaddanicontooneoftheseareas,youdefineanextensionelementintheconfigurationfileandsetthe parentattributeoftheelementtotheappropriateextensionpoint.Otherdetailsabouthowtocreatethe configurationanddefinetheelementsneededareincludedinCreatingtheConfigurationFileonpage 7. Table 2liststheavailableviewareasanddefinedextensionpoints. Table 2. Home View Extension Points
Display area of home view Administration Applications Inventory Management Set parent attribute to extension point HomeView.Admin HomeView.Applications HomeView.Inventory HomeView.Management

vSphere Client Inventory View


ThevSphereClientinventoryviewdisplaysentitiesavailableintheinventoryinitsleftpaneandthe operationsavailableforselectedinventoryentitiesinitsrightpane.Youcanaddatabtothisviewby associatingitwithoneoftheinventoryobjectsintheleftpane. Figure 2. vSphere Client Inventory View

ToaddaTabthatdisplaysintherightpaneforaspecificinventoryobject,youmustaddanextensiontothe configurationfilethatdefinestheparentattributeastheappropriateextensionpointfromamongthe InventoryView.*extensionpointslistedinTable 3. Table 3. InventoryView Extension Points


Inventory object to associate with the Tab Cluster Datacenter DatacenterFolder Datastore DatastoreFolder DVS Host HostFolder Network NetworkFolder Set parent attribute to extension point InventoryView.Cluster InventoryView.Datacenter InventoryView.DatacenterFolder InventoryView.Datastore InventoryView.DatastoreFolder InventoryView.DistributedVirtualSwitch InventoryView.HostSystem InventoryView.ComputeResourceFolder InventoryView.Network InventoryView.NetworkFolder

VMware, Inc.

Customizing the vSphere Client

Table 3. InventoryView Extension Points (Continued)


Inventory object to associate with the Tab ResourcePool Template VirtualMachine VirtualMachineFolder VirtualService Set parent attribute to extension point InventoryView.ResourcePool InventoryView.Template InventoryView.VirtualMachine InventoryView.VirtualMachineFolder InventoryView.VirtualService

vSphere Client Context Menus


ThemenuoptionsandUIitemsavailableonthevSphereClientchangeasdifferentmanagedobjectsare selectedintheleftpaneoftheinterface,orasdifferentmenuchoicesaremadeinthemainmenu,atthetopof thedisplay.Forexample,Figure 3showsthedefaultcontextmenuavailableforvirtualmachinesfromthe InventorymenuofthevSphereClient. Figure 3. vSphere Client Inventory Context Menu

Youcanextendthemenusavailableatanymanagedobjectbyusingoneofthecontextualextensionpoints listedinthetables.AddoneextensionelementforeachtypeofcontextmenuyouwanttoaddtotheUI. ToaddcustomcontextmenustothetopmenuoftheUI,usetheextensionpointslistedinTable 4. Table 4. Main Menu Extension Points


Inventory object for the menu Administration Edit File File_Export File_New File_Report Help Inventory Plugins View View_Inventory Set parent attribute to extension point MainMenus.Administration MainMenus.Edit MainMenus.File MainMenus.File_Export MainMenus.File_New MainMenus.File_Report MainMenus.Help MainMenus.Inventory MainMenus.Plugins MainMenus.View MainMenus.View_Inventory

VMware, Inc.

Customizing the vSphere Client

ToaddcustomcontextmenustotheleftpaneoftheUI,usetheextensionpointslistedinTable 5. Table 5. Inventory Menu Extension Points


Inventory object for the menu Cluster Datacenter DatacenterFolder Datastore DatastoreFolder DVS Host HostFolder Network NetworkFolder ResourcePool Role ScheduledTasks Tasks Template VirtualMachine VirtualMachineFolder VirtualService Set parent attribute to extension point InventoryMenus.Cluster InventoryMenus.Datacenter InventoryMenus.DatacenterFolder InventoryMenus.Datastore InventoryMenus.DatastoreFolder InventoryMenus.DistributedVirtualSwitch InventoryMenus.HostSystem InventoryMenus.ComputeResourceFolder InventoryMenus.Network InventoryMenus.NetworkFolder InventoryMenus.ResourcePool InventoryMenus.Role InventoryMenus.ScheduledTasks InventoryMenus.Tasks InventoryMenus.Template InventoryMenus.VirtualMachine InventoryMenus.VirtualMachineFolder InventoryMenus.VirtualService

vSphere Client Inventory Toolbars


TheToolbarsthatdisplayintheUIarespecifictothemanagedobjectselectedinthelefthandpane.Toadd anicontotheToolbarassociatedwiththeappropriateinventoryobject,addanextensionelementtothe configurationfilethatdefinestheparentattributeusingtheappropriateextensionpointfromTable 6.Include aniconSmallerelementthatspecifiestheURLlocationoftheicon(theimagefile). Table 6. Toolbar Extension Points
Inventory object to associate with the Toolbar Cluster Datacenter DatacenterFolder Datastore DatastoreFolder DVS Host HostFolder Network NetworkFolder ResourcePool Template VirtualMachine Set parent attribute to extension point Toolbars.Cluster Toolbars.Datacenter Toolbars.DatacenterFolder Toolbars.Datastore Toolbars.DatastoreFolder Toolbars.DistributedVirtualSwitch Toolbars.HostSystem Toolbars.ComputeResourceFolder Toolbars.Network Toolbars.NetworkFolder Toolbars.ResourcePool Toolbars.Template Toolbars.VirtualMachine

VMware, Inc.

Customizing the vSphere Client

Table 6. Toolbar Extension Points (Continued)


Inventory object to associate with the Toolbar VirtualMachineFolder VirtualService Set parent attribute to extension point Toolbars.VirtualMachineFolder Toolbars.VirtualService

Creating the Configuration File


TheconfigurationfileisaplaintextfilecontainingtheseriesofXMLelementsandattributesthatspecifyyour customizations.ThefilemustcomplywithaformatspecifiedbyVMware.YoudonotneedtouseanXSD,but youmustfollowtherulesdefinedinthissection.Table 7listsvalidelementsintheorderinwhichtheyshould bedefinedinthefile,andExample 1showsacompleteexamplethatyoucanuseatemplate. ApluginconfigurationfilecancontainanextensionelementforeachUIitemrequiredtosupportuser interaction.However,whenaddingmenu,icon,andotherUIitemstothevSphereClient,followsomebasic guidelines.TakeintoaccountthelookandfeelofthevSphereClient.Usesimilarfonts,fontsizes,andcolor schemesforiconsandotherUIcomponents.DonotaddtoomanyiconstotheToolbar. Table 7. Configuration File Elements
Element scriptConfiguration Description Required.ContainingelementforvSphereClientUIextensionsthatsupportscripting plugins.The<scriptConfigurationversion=n.n>tagmustidentifythisasthefirstelement inthefile,withtheclosingtag(</scriptConfiguration>)lastinfile. Theversionattributeisrequired.ItidentifiestheversionoftheplugintovSphereClient fromamongpossiblymultipleversionsoftheplugin. key Required.Uniquestringthatidentifiestheplugin.Onlyonekeyelementperfileallowed. StringvalueforkeymustbeuniqueamongallextensionsonthevCenterServer.VMware recommendsusingJavapackagenamingconventionforthekeyvalue,suchas com.yourcompany.yourpluginname. Specifieswhethertodisplay(true)thevCenterServerselectorornot(false).Onlyone multiVCsupportedelementallowedperconfigurationfile. Optional.Descriptionofyourplugin.Onlyoneperfileallowed.Thisdescriptiondisplaysin thePluginManagerofthevSphereClient. Optional.NameofyourpluginthatdisplaysinthevSphereClientPluginsManager. Optional.Yourcompanyname. Filemustcontainatleastoneoftheseelementsdefiningtheextensionpointwithwhichto associatetheUIitem.Anextensionelementrequiresaparentattributesettotheappropriate extensionpoint.ValidextensionpointsarelistedinTable 2,Table 3,Table 4,Table 5, Table 6,andTable 7. Optionalattributesforextensionincludeprivilegeandtreestyle.Usetheprivilege attributetoassociateoneormoreprivilegerequirementswiththeextension.Forexample, <extensionparent=InventoryMenus.DVSprivilege=DVSwitch.Modify>. YoucanusethetreestyleattributewithMainView.*andInventoryView.*extensionpoints tolimitthepositioningoftheextensionelementtotheleftpaneundertheappropriate inventoryitem.Thetreestyleattributesupportsthefollowingoptions:

multiVCsupported description name vendor extension

Physical Virtual Datastores Network

Eachextensionelementmustbefollowedbyatitleelementandaurlelement. Eachextensionelementcanalsocontainicon,iconSmaller,andoneormore customAttributeelementsasappropriatefortheextensionpoint. Multipleextensionelementscanbenested,tocreatemultilevelcontextmenus.See Example 2,ComprehensiveConfigurationFileforPlugIn,onpage 9. title ThetitlethatdisplaysinthevSphereClientviewwindowwhentheextensionisactivated. Eachtitleelementhasalocaleattributethatmustbeset.Forexample,<titlelocale=en>, <titlelocale=ja>,or<titlelocale=de>.

VMware, Inc.

Customizing the vSphere Client

Table 7. Configuration File Elements (Continued)


Element url Description FullyqualifiedWebserverlocationofthescript,Webapplication,icon,button,orother componentfortheplugin.Requiredforeachextensionelementdefinedinthefile. Optionaldisplayattributefinetunestheactiontakenonthespecifiedpluginusingoneof thefollowingsettings:

Ifyoudonotspecifyadisplayattribute,thenthecomponentopensinaWebbrowser. windowOpenanonmodalwindowandlaunchtheURLwithinthat.Thisishowyou canopentheURLwithinvSphereClient. modalwindowSameasabove,exceptthatthewindowismodal.InC#,theusermust resolveinteractionwithamodalwindowbeforetheparentwindowactivitycancontinue. Thisishowyoucanimplementawizardordialog.Notsupportedforscriptingplugins. noneExecuteascriptlocatedattheURL.Whentheyclickthemenu,usersrunascript withoutlaunchinganyuserinterface(neitherWebpagenordialogwindow).

iconSmaller icon customAttribute

AURLcontaininga16x16pixelimage(.giffile)fordisplayataToolbar.*orInventoryView.* extensionpoint. AURLcontaininga32x32pixelimage(.giffile)fordisplayinaHomeView.*extensionpoint. Optional.Associatesamenuorviewwithacustomattributedefinedforthemanagedobject ontheserver.SetthenameattributeofacustomAttributetothenameofacustomattribute definedonthemanagedobject.

Forexample,toaddatabtothevSphereClientthatdisplaysintherightpanewhenusersselectavirtual machineintheleftpaneoftheUI,defineanextensionintheconfigurationfilethatusesthefollowingtemplate:
... <extension parent=InventoryView.VirtualMachine> <title locale=en>Tab Title Here</title> <url display=window>http://path/to/your/plugin/component/to/open/in/tab/pane</url> </extension> ...

Example 1showsaminimalconfigurationfilethataddsasmallicontodifferentlocationsonthevSphere ClientwithalinktotheVMwarevSphereAPIReferenceGuideontheVMwareWebsite.Example 3,Using thevSphereAPItoRegisteravSphereClientPlugin,onpage 11providestheJavaclientthatregistersthe URLforthelocationofthisfile. Example 1. Minimum Configuration File
<scriptConfiguration version="4.0> <key>com.vmware.pubs.sdkteam</key> <description>SDK Pubs Sample vSphere Client Plug-in</description> <name>vSphere API Reference Documentation Plug-in</name> <vendor>VMware, Inc.</vendor> <multiVCsupported>false</multiVCsupported> <extension parent="HomeView.Admin"> <title locale="en">vSphere Web Services SDK API ReferenceGuide</title> <url display="window">http://www.vmware.com/support/developer/vc-sdk/ visdk400pubs/ReferenceGuide/index.html</url> <icon>http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/docresources/page.gif</icon> </extension> <extension parent="Toolbars.Datacenter"> <title locale="en">vSphere Web Services SDK API ReferenceGuide</title> <url display="window">http://www.vmware.com/support/developer/vc-sdk/ visdk400pubs/ReferenceGuide/index.html</url> <iconSmaller>http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/docresources/page.gif </iconSmaller> </extension> </scriptConfiguration>

Tocreatetheconfigurationfile,youcanuseanytexteditor.VMwarerecommendsusinganXMLeditor,such asAltovaXMLSpy,tocreateawellformedXMLfile.IfXMLismalformed,thevSphereClientcannotloadit. (Seehttp://www.altova.comforinformationaboutXMLSpy.)ThePlugInManagerofthevSphereClient displayserrormessagesaboutaloadfailure,butdoesnotprovidedebugginginformation.


VMware, Inc. 8

Customizing the vSphere Client

Example 2isacompleteconfigurationfilethatdefinesseveraldifferentclientextensions,includingiconsand menus,fordemonstrationpurposes. Example 2. Comprehensive Configuration File for Plug-In


<?xml version="1.0" ?> <scriptConfiguration version="1.0"> <key>com.vmware.test</key> <description>Test script plug-in</description> <name>vSphere Client 4.0 Extension Points example</name> <vendor>VMware, Inc.</vendor> <multiVCsupported>false</multiVCsupported> <!-- Adds a shortcut to the home view --> <extension parent="Home.Inventory"> <title locale="en">VMware</title> <url display="window">http://vmware.com</url> <icon>http://fqdn/path/to/plugin/component/scsi.png</icon> <iconSmaller>http://fqdn/path/to/plugin/component/scsi_small.png</iconSmaller> </extension> <!-- Adds a tab to datacenter object --> <extension parent="InventoryView.Template"> <title locale="en">Custom Template</title> <url display="modalwindow">http://fqdn/path/to/plugin/component/a.html</url> </extension> <!-- Adds a menu to host system context menus.--> <extension parent="InventoryMenus.HostSystem"> <title locale="en">Custom</title> <url>http://fqdn/path/to/plugin/component/a.html</url> <!-- You can associate an extension with custom attributes defined on vCenter Server. --> <customAttribute name="A1">A1</customAttribute> <customAttribute name="A2">A2</customAttribute> </extension> <extension parent="InventoryMenus.HostSystem" privilege="Host.Config.Connection, Host.Config.Storage"> <title locale="en">Test</title> <url>http://fqdn/path/to/plugin/component/a.html</url> </extension> <extension parent="Toolbars.DatacenterFolder" treestyles="Physical, Virtual"> <title>Plugin button</title> <url display="window">http://fqdn/path/to/plugin/component/a.html</url> --> <iconSmaller>http://fqdn/path/to/plugin/component/scsi_small.png</iconSmaller> </extension> <!-- Adds a menu item to the DVS context menu. --> <extension parent="InventoryMenus.DistributedVirtualSwitch"> <title>Plug-in menu item</title> <url>http://www.google.com/search?q=Distributed%20Virtual%20Switch</url> </extension> <!-- nested menus --> <extension parent="InventoryMenus.Cluster"> <title>Nested menu-item</title> <!-- The first URL is ignored --> <url>http://www.google.com/</url> <!-- Level 1 nesting --> <extension> <title>Level 1 - a</title> <!-- Level 2 nesting --> <extension> <title>Level 2 - a</title> <url>http://www.google.com/</url> </extension> <extension> <title>Level 2 - b</title><url>http://www.google.com/</url> </extension> </extension> <!-- Level 1 nesting --> <extension> <title>Level 1 - b</title> <url>http://www.google.com/</url> </extension> <extension> <title>Level 1 - c</title> <url>http://www.google.com/</url> </extension> </extension> </scriptConfiguration>

VMware, Inc.

Customizing the vSphere Client

Overview of the ExtensionManager Managed Object


ExtensionManageristheserviceinterfaceforregisteringplugins.TheExtensionManagerhasasingle property,extensionList,thatisdefinedasanarrayofextensionsregisteredwiththevCenterServersystem. WhenyouregisteryourpluginwiththevCenterServer,itgetsaddedtothisarray.TheExtensiondataobject containsmetadataabouteachextension(plugin),includingitslocationandtype,andotherdetails. Figure 4. ExtensionManager and Extension Data Object

TheExtensionManagerwasintroducedwiththeVISDK2.5andincludesseveralnewpropertiesinvSphere API4.0.ManyExtensionpropertiesareoptional.Forexample,thesubjectNameisusedonlyifclient certificatesmustbehandledbytheplugin.SeetheVMwarevSphereAPIReferenceGuideforcomplete informationaboutExtensionManagerandExtension.ForinformationaboutthevSphereClientextensions supportedinVISDK2.5,gotohttp://www.vmware.com/support/developer/vcsdk/vcplugin/.

Registering the Extension


Yourpluginbecomesavailabletoendusersonlyaftertheconfigurationfileandallothercomponentshave beenlocatedontheWebservers,andanExtensiondataobjectisregisteredwithExtensionManager.The ExtensiondataobjectconsistsofmetadataaboutthepluginandtheURLofitsconfigurationfile.When endusersconnecttovCenterServerfromvSphereClient,theplugincomponentsaredispatchedtovSphere ClientasdescribedinOverviewofvSphereClientPlugInsonpage 1. ToregistertheextensionwithvCenterServer,youmustcreateaclientutilityapplicationorscriptthatcreates thenecessaryDescription,ExtensionServerInfo,andExtensionClientInfodataobjectsthatpopulate theExtensiondataobjectwithvaluesontheserver.Alternatively,youcanusetheMOBtosubmitthesame dataobjectsintheirXMLform.ForinformationaboutusingtheMOB,seetheVMwarevSphereWebServices SDK4.0ProgrammingGuide. Example 3,UsingthevSphereAPItoRegisteravSphereClientPlugin,onpage 11providesacompleteJava applicationthatregistersthesampleextensiondefinedinExample 1.Thesampleextensionconsistsofanicon forthevSphereAPIReferenceGuideandalinktoitslocationontheVMwareWebsite.ThisJavasampleis supportedonvCenterServer4.0only. Whetheryouuseascript,aclientapplication,ortheMOBtoregisteryourplugin,oneofthemostimportant detailsinExample 3thatisapplicabletoanyextensionsyoucreateisthatyoumustsetthetypepropertyof theExtensionServerInfotothefollowingspecificpackagename:
com.vmware.vim.viClientScripts

VMware, Inc.

10

Customizing the vSphere Client

Updating or Removing Plug-Ins


TheRegisterExtensionmethodtheExtensiondataobjectthatincludestheURLoftheWebsitecontaining theconfigurationfile.IfyoumovetheconfigurationfiletoanewlocationafterregisteringitsURL,youwill needtoupdatethelocationbyusingtheUpdateExtensionoperationwiththenewlocation.Toremovea vSphereClientPlugincompletely,usetheUnregisterExtensionoperation. Example 3providestheJavaclientthatregisterstheURLforthelocationofthisfile. Example 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 = "docfeedback@vmware.com"; private String versionStr = "4.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("vSphere Client Plug-in Sample"); 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); } }

VMware, Inc.

11

Customizing the vSphere Client

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

If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com VMware, Inc. 3401 Hillview Ave., Palo Alto, CA 94304 www.vmware.com Copyright 2009 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, the VMware boxes logo and design, Virtual SMP, and VMotion are registered trademarks or trademarks 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-01 Revised 2010-03-01

12

Das könnte Ihnen auch gefallen