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 opened
    eam_work_folder
    \src\com\vmware\eam\sample\solution\AgentHandler.java
    in an editor.
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.
  1. Establish a connection to the ESX Agent Manager running in
    .
    The
    AgentHandler.java
    implements the
    EamConnection.java
    class 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(); [...] }
  2. Create an ESX agency by calling the
    EsxAgentManager.createAgency()
    method.
    The
    AgentHandler.java
    class checks whether any ESX agencies are already running, and if not calls the
    EsxAgentManager.createAgency()
    method.
    AgentHandler.java
    passes to the
    EsxAgentManager.createAgency()
    method the
    ManagedObjectReference
    object for the ESX Agent Manager instance running in
    ,
    eamRef
    .
    AgentHandler.java
    also passes to
    createAgency()
    the
    AgencyConfigInfo
    object that defines the configuration of the ESX agency.. The
    AgentHandler.java
    class sets the initial goal state of the ESX agency to
    ENABLED
    .
    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()); } [...] }
  3. Call the
    Agency.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); } }
  4. Call the
    Agency.agencyQueryRuntime()
    method to return the status of the ESX agency.
    The
    Agency.agencyQueryRuntime()
    method returns an
    EamObjectRuntimeInfo
    object 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.