use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceValidatorTest method failWhenClusterVersionNotCompatible.
@Test
public void failWhenClusterVersionNotCompatible() {
VDS vds = new VDS();
vds.setPmEnabled(true);
Cluster cluster = new Cluster();
cluster.setCompatibilityVersion(Version.getLast());
FenceAgent agent = new FenceAgent();
agent.setType("Some_Type");
when(fenceAgentDao.getFenceAgentsForHost(vds.getId())).thenReturn(Collections.singletonList(agent));
List<String> messages = new LinkedList<>();
boolean result = validator.isPowerManagementEnabledAndLegal(vds, cluster, messages);
assertFalse(result);
assertEquals(2, messages.size());
assertTrue(messages.contains("ACTION_TYPE_FAILED_AGENT_NOT_SUPPORTED"));
assertTrue(messages.contains("VDS_FENCE_DISABLED"));
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class HostListModel method edit.
public void edit(final boolean isEditWithPMemphasis) {
if (getWindow() != null) {
return;
}
VDS host = getSelectedItem();
EditHostModel hostModel = new EditHostModel();
hostModel.setSelectedCluster(host);
AsyncDataProvider.getInstance().getAllFenceAgentsByHostId(new AsyncQuery<>(retValue -> {
ArrayList<FenceAgent> fenceAgents = new ArrayList<>();
for (FenceAgent fenceAgent : retValue) {
fenceAgents.add(fenceAgent);
}
host.setFenceAgents(fenceAgents);
hostModel.getFenceAgentListModel().setItems(hostModel.getFenceAgentModelList(host));
}), getSelectedItem().getId());
AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(dataCenters -> {
hostModel.updateModelFromVds(host, dataCenters, isEditWithPMemphasis);
hostModel.onDataInitialized();
hostModel.setTitle(ConstantsManager.getInstance().getConstants().editHostTitle());
hostModel.setHelpTag(HelpTag.edit_host);
// $NON-NLS-1$
hostModel.setHashName("edit_host");
hostModel.setIsHeSystem(isHeSystem());
hostModel.setHostsWithHeDeployed(getHostsWithHeDeployed());
hostModel.setHostedEngineHostModel(new HostedEngineHostModel());
setWindow(hostModel);
if (host.getFenceProxySources() != null && !host.getFenceProxySources().isEmpty()) {
hostModel.setPmProxyPreferences(FenceProxySourceTypeHelper.saveAsString(host.getFenceProxySources()));
} else {
AsyncDataProvider.getInstance().getDefaultPmProxyPreferences(new AsyncQuery<>(returnValue -> hostModel.setPmProxyPreferences(returnValue)));
}
// $NON-NLS-1$
UICommand onSaveFalseCommand = UICommand.createDefaultOkUiCommand("OnSaveFalse", HostListModel.this);
hostModel.getCommands().add(onSaveFalseCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("Cancel", HostListModel.this);
hostModel.getCommands().add(cancelCommand);
}));
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceAgentListModel method createFenceAgentFromModel.
/**
* Create a {@code FenceAgent} from the passed in {@code FenceAgentModel}
* @param agentModel The model to create the {@code FenceAgent} out of.
* @return A {@code FenceAgent} based on the passed in model.
*/
private FenceAgent createFenceAgentFromModel(FenceAgentModel agentModel) {
FenceAgent agent = new FenceAgent();
agent.setIp(agentModel.getManagementIp().getEntity());
agent.setUser(agentModel.getPmUserName().getEntity());
agent.setPassword(agentModel.getPmPassword().getEntity());
agent.setType(agentModel.getPmType().getSelectedItem());
agent.setOptionsMap(agentModel.getPmOptionsMap());
if (agentModel.getPmEncryptOptions().getEntity() != null) {
agent.setEncryptOptions(agentModel.getPmEncryptOptions().getEntity());
} else {
agent.setEncryptOptions(false);
}
if (agentModel.getPmPort() != null && agentModel.getPmPort().getEntity() != null) {
agent.setPort(agentModel.getPmPort().getEntity());
}
agent.setOrder(agentModel.getOrder().getEntity());
return agent;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceAgentExecutor method executeFenceAction.
protected FenceOperationResult executeFenceAction(FenceActionType action, FenceAgent agent, VDS proxyHost) {
FenceAgent realAgent = createRealAgent(agent, proxyHost);
auditFenceActionExecution(action, realAgent, proxyHost);
VDSReturnValue retVal = resourceManager.runVdsCommand(VDSCommandType.FenceVds, new FenceVdsVDSCommandParameters(proxyHost.getId(), fencedHost.getId(), realAgent, action, convertFencingPolicy(proxyHost)));
FenceOperationResult result = (FenceOperationResult) retVal.getReturnValue();
log.debug("Result of '{}' fence action: {}", result);
if (result == null) {
log.error("FenceVdsVDSCommand finished with null return value: succeeded={}, exceptionString='{}'", retVal.getSucceeded(), retVal.getExceptionString());
log.debug("Exception", retVal.getExceptionObject());
result = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, retVal.getExceptionString());
}
if (result.getStatus() == Status.ERROR) {
auditFenceActionFailure(action, realAgent, proxyHost);
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceAgent in project ovirt-engine by oVirt.
the class FenceAgentExecutor method createRealAgent.
/**
* Creates instance of agent with values passed to real agent
*/
protected FenceAgent createRealAgent(FenceAgent agent, VDS proxyHost) {
FenceAgent realAgent = new FenceAgent(agent);
realAgent.setOptions(getRealAgentOptions(agent, proxyHost));
realAgent.setType(VdsFenceOptions.getRealAgent(agent.getType()));
return realAgent;
}
Aggregations