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 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.- Establish a connection to the ESX Agent Manager running invCenter Server.TheMyAgentHandler.javacan implement theMyEamConnection.javaclass to connect tovCenter Serverand ESX Agent Manager.public void setup(MyEamConnection myeamConnection) { assert myeamConnection != null; _myeamConnection = myeamConnection; ManagedObjectReference eamRef = _myeamConnection.getEsxAgentManager(); EamPortType stub = _myeamConnection.getStub(); [...] }
- Create an ESX agency by calling theEsxAgentManager.createAgency()method.TheMyAgentHandler.javaclass checks whether any ESX agencies are already running, and if not calls theEsxAgentManager.createAgency()method.MyAgentHandler.javapasses to theEsxAgentManager.createAgency()method theManagedObjectReferenceobject for the ESX Agent Manager instance running invCenter Server,eamRef.MyAgentHandler.javaalso passes tocreateAgency()theAgencyConfigInfoobject that defines the configuration of the ESX agency. TheMyAgentHandler.javaclass sets the initial goal state of the ESX agency toENABLED.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()); } [...] }
- Call theAgency.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); } }
- 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.