Connect the Extension
to
You must provide
information about the
instance to which you connect an extension. Set the details of the connection
to
in the client-side stub of the extension.
- Verify that you have set up and started the EAM Sample Solution in an application server.
- Openin an editor.eam_work_folder\src\com\vmware\eam\sample\solution\util\VimConnection.java
If you deploy your
extension using the Open Virtualization Format (OVF), you can integrate it with
the vCenter Extension vService. The vCenter Extension vService automates the
process of registering extension with
,
so you do not need to provide any connection parameters. See
Integrating an Extension with the vCenter Extension vService.
To connect an extension to
,
provide the following information to the client-side stub of the connection.
- A username and password for a administrator account, if you do not use the vCenter Extension vService
- The extension key for the extension
- A reference to theSessionManagerinstance in the
The EAM Sample Solution
defines the connection to
in the
VimConnection
class.
The
Manager
class performs
the following functions.
- Implements theVimConnectionclass to establish the connection to when the EAM Sample Solution starts.
- Uses the Spring framework to obtain the connection information from theeamri.propertiesfile that you configure when you set up the EAM Sample Solution.
- Passes the connection property values toVimConnection.
- Create an instance of theManagedObjectReferencedata object to define the connection to the extension.TheVimConnectionclass creates aManagedObjectReferenceobject of typeServiceInstance, named_siRef.public VimConnection(String host, int port) { [...] _siRef = new ManagedObjectReference(); _siRef.setType("ServiceInstance"); _siRef.setValue("ServiceInstance"); }
- Define methods to get and set the host, ports, username, password, connection timeout, and session cookie.TheVimConnectionconstructor defines methods to obtain the host, ports, username, password, connection timeout, and session cookie from the information that you set in theeamri.propertiesfile.
- Connect to by obtaining theSessionManagermanaged object for the .VimConnection.javadefines a method namedconnect(). Theconnect()method defines a standard connection to that uses WSDL. The following segment shows the calls to theSessionManager.login()andSessionManager.loginExtensionByCertificate()methods that establish the connection to . The_stubvariable is an instance ofVimPortType,_scis aServiceContentobject, and_siRefis theManagedObjectReferenceobject of typeServiceInstance.private synchronized void connect() { [...] try { [...] VimService locator = new VimService(wsdlURL, new QName("urn:vim25Service", "VimService")); _stub = locator.getVimPort(); [...] _sc = _stub.retrieveServiceContent(_siRef); ManagedObjectReference sessionManager = _sc.getSessionManager(); if (_extensionKey == null) { _stub.login(sessionManager, _username, _password, null); } else { _stub.loginExtensionByCertificate(sessionManager, _extensionKey, null); } [...] _connectionStatus = ConnectionStatus.Connected; } catch (Exception e) { _logger.error(e, e); } }
- Register the extension by calling theExtensionManager.registerExtension()method.VimConnectiondefines aregisterExtension()method that implementsExtensionManager.registerExtension().ManagercallsVimConnection.registerExtension()after it has set the properties for the extension.public void registerExtension(Extension ex) { try { Extension findExtension = _stub.findExtension(_sc.getExtensionManager(), ex.getKey()); if (findExtension == null) { _stub.registerExtension(_sc.getExtensionManager(), ex); } else { _stub.updateExtension(_sc.getExtensionManager(), ex); } _stub.setExtensionCertificate(_sc.getExtensionManager(), ex.getKey(), null); } catch (Exception e) { _logger.error(e, e); } }
You registered an extension
with
.
Provide an extension key with
which to register the extension with
.