Search in sources :

Example 1 with FenceAgent

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;
}
Also used : FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent)

Example 2 with FenceAgent

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;
}
Also used : ArrayList(java.util.ArrayList) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Pair(org.ovirt.engine.core.common.utils.Pair) HashSet(java.util.HashSet)

Example 3 with FenceAgent

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;
}
Also used : FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) LinkedList(java.util.LinkedList)

Example 4 with FenceAgent

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));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) QueryType(org.ovirt.engine.core.common.queries.QueryType) PowerStatus(org.ovirt.engine.core.common.businessentities.pm.PowerStatus) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) Comparator(java.util.Comparator) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters)

Example 5 with FenceAgent

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);
}
Also used : FenceVdsVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.FenceVdsVDSCommandParameters) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent)

Aggregations

FenceAgent (org.ovirt.engine.core.common.businessentities.pm.FenceAgent)27 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 Guid (org.ovirt.engine.core.compat.Guid)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 Window (com.google.gwt.user.client.Window)1 Inject (com.google.inject.Inject)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Before (org.junit.Before)1