You create an ESX agency by calling the EsxAgentManager.createAgency() method. You must specify ESX agent configurations for each version of ESXi on which you deploy ESX agents.

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.

You can define a function that creates an ESX agency in a MyAgentHandler.java class.

Prerequisites

Download the vSphere ESX Agent Manager SDK.

Procedure

  1. Establish a connection to the ESX Agent Manager running in vCenter Server.
    The MyAgentHandler.java can implement the MyEamConnection.java class to connect to vCenter Server and ESX Agent Manager.
    public void setup(MyEamConnection myeamConnection) {
     assert myeamConnection != null;
     _myeamConnection = myeamConnection;
    
      ManagedObjectReference eamRef = _myeamConnection.getEsxAgentManager();
      EamPortType stub = _myeamConnection.getStub();
    
      [...]
    }
  2. Create an ESX agency by calling the EsxAgentManager.createAgency() method.
    The MyAgentHandler.java class checks whether any ESX agencies are already running, and if not calls the EsxAgentManager.createAgency() method. MyAgentHandler.java passes to the EsxAgentManager.createAgency() method the ManagedObjectReference object for the ESX Agent Manager instance running in vCenter Server, eamRef. MyAgentHandler.java also passes to createAgency() the AgencyConfigInfo object that defines the configuration of the ESX agency. The MyAgentHandler.java class sets the initial goal state of the ESX agency to ENABLED.
    public void setup(MyEamConnection myeamConnection) {
     assert myeamConnection != null;
     _myeamConnection = myeamConnection;
    
      ManagedObjectReference eamRef = _myeamConnection.getEsxAgentManager();
      EamPortType stub = _myeamConnection.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(MyEamConnection myeamConnection) {
        [...]  
        _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);
    }

Results

You created an ESX agency that a solution can deploy on ESXi hosts.