Search in sources :

Example 11 with FenceAgent

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

Example 12 with FenceAgent

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);
    }));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) SetHaMaintenanceParameters(org.ovirt.engine.core.common.action.SetHaMaintenanceParameters) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VdsPowerDownParameters(org.ovirt.engine.core.common.action.VdsPowerDownParameters) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) StringHelper(org.ovirt.engine.core.compat.StringHelper) FrontendUrlUtils(org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) HostGeneralModel.createUpgradeModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostGeneralModel.createUpgradeModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HostErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.HostErrataCountModel) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Uri(org.ovirt.engine.ui.uicommonweb.Uri) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) QueryType(org.ovirt.engine.core.common.queries.QueryType) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HostGlusterSwiftListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) HostGlusterStorageDevicesListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterStorageDevicesListModel) HashSet(java.util.HashSet) FenceVdsManualyParameters(org.ovirt.engine.core.common.action.FenceVdsManualyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) NumaSupportModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.NumaSupportModel) Permission(org.ovirt.engine.core.common.businessentities.Permission) Window(com.google.gwt.user.client.Window) ForceSelectSPMParameters(org.ovirt.engine.core.common.action.ForceSelectSPMParameters) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ReversibleFlow(org.ovirt.engine.ui.uicompat.ReversibleFlow) RemoveVdsParameters(org.ovirt.engine.core.common.action.RemoveVdsParameters) ExternalComputeResource(org.ovirt.engine.core.common.businessentities.ExternalComputeResource) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) HaMaintenanceMode(org.ovirt.engine.core.common.businessentities.HaMaintenanceMode) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) TaskListModel(org.ovirt.engine.ui.uicommonweb.models.events.TaskListModel) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) HostAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.HostAffinityLabelListModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) HostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) Comparator(java.util.Comparator) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 13 with FenceAgent

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

Example 14 with FenceAgent

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

Example 15 with FenceAgent

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;
}
Also used : 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