Search in sources :

Example 1 with GetFenceAgentStatusParameters

use of org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters 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)

Aggregations

ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 FenceAgent (org.ovirt.engine.core.common.businessentities.pm.FenceAgent)1 FenceOperationResult (org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult)1 PowerStatus (org.ovirt.engine.core.common.businessentities.pm.PowerStatus)1 GetFenceAgentStatusParameters (org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 FenceProxySourceTypeHelper (org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper)1 Guid (org.ovirt.engine.core.compat.Guid)1 StringHelper (org.ovirt.engine.core.compat.StringHelper)1 Frontend (org.ovirt.engine.ui.frontend.Frontend)1 ICommandTarget (org.ovirt.engine.ui.uicommonweb.ICommandTarget)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)1