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
.
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.
Your solution can define a function to change the goal state of its ESX agencies in the MyAgentHandler.java class. Your solution can change the goal state of its ESX agency when users select ESXi hosts on which to run the solution, and when they uninstall the solution.
Procedure
- Get the current goal state of the ESX agency by calling the EamObjectRuntimeInfo.getGoalState() method.
Your solution can define a function in the
MyAgentHandler.java class 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 the Agency.enable(), Agency.disable(), and Agency.uninstall() methods to set the ESX agency in the new goal state.
Your solution can call the appropriate methods to set the ESX agencies to the goal state. If the goal state is
UNINSTALLED
, the solution calls the
cleanup()
method that
MyManager.java defines 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;
MyManager.getInstance().cleanup();
}
}
Results
You changed the goal state of an ESX agency while the solution is running.