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.
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
ESXi hosts on
which to run the solution, and when they uninstall the solution.
Prerequisites
■
|
Download the vSphere ESX Agent Manager SDK.
|
■
|
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.
|
Procedure
1 | Get the current goal
state of the ESX agency by calling the
EamObjectRuntimeInfo.getGoalState()
method.
The EAM Sample
Solution defines a function in the
AgentHandler.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();
|
2 | Call the
Agency.enable(),
Agency.disable(), and
Agency.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 is
UNINSTALLED, the solution calls the
cleanup() method that
Manager.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;
Manager.getInstance().cleanup();
}
}
|
You changed the goal state of
an ESX agency while the solution is running.