Create an ESX
Agency
You create an ESX
agency by calling the
EsxAgentManager.createAgency()
method. You must specify ESX agent configurations for each version of ESX
Server on which you deploy ESX agents.
- Verify that you have set up and started the EAM Sample Solution in an application server.
- Verify that you have openedin an editor.eam_work_folder\src\com\vmware\eam\sample\solution\AgentHandler.java
When you call the
EsxAgentManager.createAgency()
method you must pass it an
AgencyConfigInfo
object
and a string to define the initial goal state of the ESX agents that the agency
deploys. The
initialGoalState
property informs ESX Agent Manager of the state in which to deploy ESX agent
virtual machines when the solution first runs.
The EAM Sample Solution
defines a function that creates an ESX agency in the
AgentHandler.java
class.
- Establish a connection to the ESX Agent Manager running in .TheAgentHandler.javaimplements theEamConnection.javaclass from the EAM Sample Solution to connect to and ESX Agent Manager.public void setup(EamConnection eamConnection) { assert eamConnection != null; _eamConnection = eamConnection; ManagedObjectReference eamRef = _eamConnection.getEsxAgentManager(); EamPortType stub = _eamConnection.getStub(); [...] }
- Create an ESX agency by calling theEsxAgentManager.createAgency()method.TheAgentHandler.javaclass checks whether any ESX agencies are already running, and if not calls theEsxAgentManager.createAgency()method.AgentHandler.javapasses to theEsxAgentManager.createAgency()method theManagedObjectReferenceobject for the ESX Agent Manager instance running in ,eamRef.AgentHandler.javaalso passes tocreateAgency()theAgencyConfigInfoobject that defines the configuration of the ESX agency.. TheAgentHandler.javaclass sets the initial goal state of the ESX agency toENABLED.public void setup(EamConnection eamConnection) { assert eamConnection != null; _eamConnection = eamConnection; ManagedObjectReference eamRef = _eamConnection.getEsxAgentManager(); EamPortType stub = _eamConnection.getStub(); try { List<ManagedObjectReference> agencyRefs = stub.queryAgency(eamRef); if (agencyRefs != null && agencyRefs.size() > 0) { _agency = agencyRefs.get(0); } else { _agency = stub.createAgency(eamRef, _agencyConfigInfo, EamObjectRuntimeInfoGoalState.ENABLED.toString() .toLowerCase()); } [...] }
- Call theAgency.queryConfig()method to verify the configuration of the ESX agency and report any issues with the configuration.public void setup(EamConnection eamConnection) { [...] _agencyConfigInfo = stub.queryConfig(_agency); _isSetup = true; } catch (RuntimeFaultFaultMsg e) { _log.error(e, e); } catch (InvalidAgencyScopeFaultMsg e) { _log.error(e, e); } catch (InvalidAgentConfigurationFaultMsg e) { _log.error(e, e); } catch (InvalidUrlFaultMsg e) { _log.error(e, e); } }
- Call theAgency.agencyQueryRuntime()method to return the status of the ESX agency.TheAgency.agencyQueryRuntime()method returns anEamObjectRuntimeInfoobject that contains the goal state of the agency, its current status, and a list of any problems that the agency has encountered.public EamObjectRuntimeInfo getRuntime() throws RuntimeFaultFaultMsg { waitForSetup(); return _eamConnection.getStub().agencyQueryRuntime(_agency); }
You created an ESX agency that
a solution can deploy on ESXi hosts.