use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class Cloner method cloneAgent.
private static FenceAgent cloneAgent(FenceAgent agent) {
FenceAgent clonedAgent = new FenceAgent();
clonedAgent.setId(agent.getId());
clonedAgent.setHostId(agent.getHostId());
clonedAgent.setIp(agent.getIp());
clonedAgent.setOptions(agent.getOptions());
clonedAgent.setOptionsMap(agent.getOptionsMap());
clonedAgent.setOrder(agent.getOrder());
clonedAgent.setPassword(agent.getPassword());
clonedAgent.setPort(agent.getPort());
clonedAgent.setType(agent.getType());
clonedAgent.setUser(agent.getUser());
return clonedAgent;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class HostModel method getFenceAgentModelList.
public List<FenceAgentModel> getFenceAgentModelList(VDS vds) {
List<FenceAgentModel> agents = new ArrayList<>();
// Keep a list of examined agents to prevent duplicate management IPs from showing up in the UI.
Set<Pair<String, String>> examinedAgents = new HashSet<>();
for (FenceAgent agent : vds.getFenceAgents()) {
FenceAgentModel model = new FenceAgentModel();
model.setHost(this);
// Set primary PM parameters.
model.getManagementIp().setEntity(agent.getIp());
model.getPmUserName().setEntity(agent.getUser());
model.getPmPassword().setEntity(agent.getPassword());
model.getPmType().setSelectedItem(agent.getType());
if (agent.getPort() != null) {
model.getPmPort().setEntity(agent.getPort());
}
model.getPmEncryptOptions().setEntity(agent.getEncryptOptions());
model.setPmOptionsMap(PowerManagementUtils.pmOptionsStringToMap(agent.getOptions()));
model.setOrder(agent.getOrder());
if (!examinedAgents.contains(new Pair<>(model.getManagementIp().getEntity(), model.getPmType().getSelectedItem()))) {
boolean added = false;
for (FenceAgentModel concurrentModel : agents) {
if (model.getOrder().getEntity() != null && model.getOrder().getEntity().equals(concurrentModel.getOrder().getEntity())) {
concurrentModel.getConcurrentList().add(model);
added = true;
break;
}
}
if (!added) {
agents.add(model);
}
}
examinedAgents.add(new Pair<>(model.getManagementIp().getEntity(), model.getPmType().getSelectedItem()));
}
return agents;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceAgentListModel method getFenceAgents.
/**
* Return a list of {@code FenceAgent}s based on the list of {@code FenceAgentModel}s containing in this list model
* @return A list of {@code FenceAgent}s
*/
public List<FenceAgent> getFenceAgents() {
List<FenceAgent> agents = new LinkedList<>();
for (FenceAgentModel agentModel : getItems()) {
FenceAgent agent = createFenceAgentFromModel(agentModel);
if (!agentModel.getConcurrentList().isEmpty()) {
for (FenceAgentModel concurrentAgentModel : agentModel.getConcurrentList()) {
FenceAgent concurrentAgent = createFenceAgentFromModel(concurrentAgentModel);
agents.add(concurrentAgent);
}
}
agents.add(agent);
}
return agents;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceAgentModel method test.
/**
* Execute the fence agent test.
*/
public void test() {
validatePmModels();
if (!isValid()) {
return;
}
setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
getTestCommand().setIsExecutionAllowed(false);
Cluster cluster = getHost().getCluster().getSelectedItem();
GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
FenceAgent agent = new FenceAgent();
if (getHost().getHostId() != null) {
param.setVdsId(getHost().getHostId());
}
agent.setOrder(getOrder().getEntity());
agent.setIp(getManagementIp().getEntity());
agent.setType(getPmType().getSelectedItem());
agent.setUser(getPmUserName().getEntity());
agent.setPassword(getPmPassword().getEntity());
agent.setPort(getPmPort().getEntity());
agent.setOptionsMap(getPmOptionsMap());
param.setAgent(agent);
param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
param.setVdsName(getHost().getName().getEntity());
param.setHostName(getHost().getHost().getEntity());
param.setClusterId(cluster.getId());
Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
String msg;
if (returnValue == null) {
msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
} else {
FenceOperationResult result = returnValue.getReturnValue();
if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
} else {
msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
}
}
setMessage(msg);
getTestCommand().setIsExecutionAllowed(true);
}, true));
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceVdsVDSCommandTest method setupCommandParams.
private FenceVdsVDSCommandParameters setupCommandParams(FenceActionType fenceAction) {
FenceAgent agent = new FenceAgent();
agent.setIp("1.2.3.4");
agent.setPort(1234);
agent.setType("ipmilan");
agent.setUser("admin");
agent.setPassword("admin");
agent.setOptions("");
return new FenceVdsVDSCommandParameters(PROXY_HOST_ID, TARGET_HOST_ID, agent, fenceAction, null);
}
Aggregations