Change the Goal State
of an Agency
A solution can
change the goal state of its ESX agencies while the solution is running. For
example, when a solution starts, the goal state of its ESX agencies can be
ENABLED
. If the solution includes a function to remove ESX
agencies, when this function runs, the goal state of the ESX agency changes to
UNDEPLOYED
.
- 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
You call the
Agency.enable()
,
Agency.disable()
, and
Agency.uninstall()
methods to change the goal state of an ESX agency. Calling these methods
changes the status of the ESX agency to yellow until the agency reaches the
desired state, in which case the status changes to green. If the ESX agency
cannot achieve the goal state, the status changes to red.
The EAM Sample Solution
defines a function to change the goal state of its ESX agencies in the
AgentHandler.java
class. The EAM Sample Solution changes the goal state of its ESX agency when
users select
hosts on
which to run the solution, and when they uninstall the solution.
- Get the current goal state of the ESX agency by calling theEamObjectRuntimeInfo.getGoalState()method.The EAM Sample Solution defines a function in theAgentHandler.javaclass to obtain the current goal state from the solution.public void updateGoalState(String params) throws RuntimeFaultFaultMsg, NotFoundFaultMsg { String[] kv = params.split("=", 2); assert kv[0].equals("goalState"); String goalState = kv[1]; String currentGoalState = getRuntime().getGoalState().toString();
- Call theAgency.enable(),Agency.disable(), andAgency.uninstall()methods to set the ESX agency in the new goal state.The EAM Sample Solution calls the appropriate methods to set the ESX agencies to the goal state. If the goal state isUNINSTALLED, the solution calls thecleanup()method thatManager.javadefines to remove the ESX agencies and uninstall the solution.if (goalState.equals(currentGoalState)) { return; } if (goalState.equals(EamObjectRuntimeInfoGoalState.ENABLED.toString() .toLowerCase())) { enable(); } else if (goalState.equals(EamObjectRuntimeInfoGoalState.DISABLED.toString() .toLowerCase())) { disable(); } else { assert goalState.equals(EamObjectRuntimeInfoGoalState.UNINSTALLED.toString() .toLowerCase()); _unregistered = true; Manager.getInstance().cleanup(); } }
You changed the goal state of
an ESX agency while the solution is running.