Search in sources :

Example 1 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class GuideModel method checkVdsClusterChangeSucceeded.

protected void checkVdsClusterChangeSucceeded(final String searchStr, final List<ActionParametersBase> changeVdsParameterList, final List<ActionParametersBase> activateVdsParameterList) {
    final Map<Guid, Guid> hostClusterIdMap = new HashMap<>();
    for (ActionParametersBase param : changeVdsParameterList) {
        hostClusterIdMap.put(((ChangeVDSClusterParameters) param).getVdsId(), ((ChangeVDSClusterParameters) param).getClusterId());
    }
    Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<VDS> hosts = returnValue.getReturnValue();
        boolean succeeded = true;
        for (VDS host : hosts) {
            if (!host.getClusterId().equals(hostClusterIdMap.get(host.getId()))) {
                succeeded = false;
            }
        }
        if (!succeeded) {
            getWindow().stopProgress();
            cancel();
            errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostChangeClusterTimeOut());
        } else {
            activateHostsAfterClusterChange(searchStr, activateVdsParameterList);
        }
    }));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) Guid(org.ovirt.engine.core.compat.Guid) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) Map(java.util.Map) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VDS(org.ovirt.engine.core.common.businessentities.VDS) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) Timer(com.google.gwt.user.client.Timer) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class AddDataCenterRM method rollback3.

public void rollback3() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    VDS host = context.hostFoundById;
    boolean abort = false;
    if (model.getSelectedItem() != null) {
        // Perform rollback only when the host is in maintenance.
        if (host.getStatus() != VDSStatus.Maintenance) {
            abort = true;
        }
    } else {
        abort = true;
    }
    if (abort) {
        context.enlistment = null;
        enlistment.done();
        return;
    }
    StoragePool dataCenter = context.dataCenterFoundById;
    // Perform rollback only when the Data Center is un uninitialized.
    if (dataCenter.getStatus() != StoragePoolStatus.Uninitialized) {
        context.enlistment = null;
        enlistment.done();
        return;
    }
    if (enlistmentContext.getOldClusterId() != null) {
        // Switch host back to previous cluster.
        Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(enlistmentContext.getOldClusterId(), host.getId()), result -> {
            ActionReturnValue returnValue = result.getReturnValue();
            context.changeVDSClusterReturnValue = returnValue;
            rollback4();
        });
    } else {
        context.enlistment = null;
        enlistment.done();
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)

Example 3 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class ChangeHostClusterRM method prepare1.

public void prepare1() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    VDS host = model.getSelectedItem();
    if (!enlistmentContext.getClusterId().equals(host.getClusterId())) {
        enlistmentContext.setOldClusterId(host.getClusterId());
        ChangeVDSClusterParameters parameters = new ChangeVDSClusterParameters(enlistmentContext.getClusterId(), host.getId());
        parameters.setCorrelationId(getCorrelationId());
        Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, parameters, result -> {
            ActionReturnValue returnValue = result.getReturnValue();
            context.changeVDSClusterReturnValue = returnValue;
            prepare2();
        });
    } else {
        context.enlistment = null;
        enlistment.prepared();
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)

Example 4 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class DataCenterGuideModel method onSelectHost.

public void onSelectHost() {
    MoveHost model = (MoveHost) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.setSelectedHosts(new ArrayList<MoveHostData>());
    for (MoveHostData a : model.getItems()) {
        if (a.getIsSelected()) {
            model.getSelectedHosts().add(a);
        }
    }
    Cluster cluster = model.getCluster().getSelectedItem();
    final List<ActionParametersBase> parameterList = new ArrayList<>();
    for (MoveHostData hostData : model.getSelectedHosts()) {
        VDS host = hostData.getEntity();
        // Try to change host's cluster as neccessary.
        if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
            parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, new IFrontendMultipleActionAsyncCallback() {

        @Override
        public void executed(FrontendMultipleActionAsyncResult result) {
            final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
            List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.getWindow()).getSelectedHosts();
            List<ActionReturnValue> retVals = result.getReturnValue();
            final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
            if (retVals != null && hosts.size() == retVals.size()) {
                int i = 0;
                for (MoveHostData selectedHostData : hosts) {
                    VDS selectedHost = selectedHostData.getEntity();
                    if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
                        Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()), null, this);
                    } else if (selectedHostData.getActivateHost()) {
                        activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
                    }
                    i++;
                }
            }
            if (activateVdsParameterList.isEmpty()) {
                dataCenterGuideModel.getWindow().stopProgress();
                dataCenterGuideModel.cancel();
                dataCenterGuideModel.postAction();
            } else {
                final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
                Timer timer = new Timer() {

                    public void run() {
                        checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
                    }
                };
                timer.schedule(2000);
            }
        }
    }, this);
}
Also used : IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Timer(com.google.gwt.user.client.Timer) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class HostListModel method onSaveInternal.

public void onSaveInternal(boolean approveInitiated) {
    HostModel model = (HostModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    VDS host = model.getIsNew() ? new VDS() : (VDS) Cloner.clone(getSelectedItem());
    // Save changes.
    host.setVdsName(model.getName().getEntity());
    host.setComment(model.getComment().getEntity());
    host.setHostName(model.getHost().getEntity().trim());
    host.setPort(Integer.parseInt(model.getPort().getEntity().toString()));
    host.setSshPort(Integer.parseInt(model.getAuthSshPort().getEntity().toString()));
    boolean sshUsernameSet = model.getUserName().getEntity() != null;
    host.setSshUsername(sshUsernameSet ? model.getUserName().getEntity() : null);
    boolean sshFpSet = model.getFetchSshFingerprint().getEntity() != null;
    host.setSshKeyFingerprint(!sshFpSet ? null : model.getFetchSshFingerprint().getEntity());
    host.setVdsSpmPriority(model.getSpmPriorityValue());
    boolean consoleAddressSet = model.getConsoleAddressEnabled().getEntity();
    host.setConsoleAddress(!consoleAddressSet ? null : model.getConsoleAddress().getEntity());
    Guid oldClusterId = host.getClusterId();
    Guid newClusterId = model.getCluster().getSelectedItem().getId();
    host.setClusterId(newClusterId);
    host.setVdsSpmPriority(model.getSpmPriorityValue());
    host.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(model.getPmProxyPreferences()));
    // Save other PM parameters.
    host.setPmEnabled(model.getIsPm().getEntity());
    host.setDisablePowerManagementPolicy(model.getDisableAutomaticPowerManagement().getEntity());
    host.setPmKdumpDetection(model.getPmKdumpDetection().getEntity());
    host.setCurrentKernelCmdline(model.getKernelCmdline().getEntity());
    host.setKernelCmdlineBlacklistNouveau(model.getKernelCmdlineBlacklistNouveau().getEntity());
    host.setKernelCmdlineParsable(model.isKernelCmdlineParsable());
    host.setKernelCmdlineIommu(model.getKernelCmdlineIommu().getEntity());
    host.setKernelCmdlineKvmNested(model.getKernelCmdlineKvmNested().getEntity());
    host.setKernelCmdlineUnsafeInterrupts(model.getKernelCmdlineUnsafeInterrupts().getEntity());
    host.setKernelCmdlinePciRealloc(model.getKernelCmdlinePciRealloc().getEntity());
    cancelConfirm();
    model.startProgress();
    if (model.getIsNew()) {
        AddVdsActionParameters parameters = new AddVdsActionParameters();
        parameters.setVdsId(host.getId());
        parameters.setvds(host);
        parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
        if (model.getUserPassword().getEntity() != null) {
            parameters.setPassword(model.getUserPassword().getEntity());
        }
        parameters.setOverrideFirewall(model.getOverrideIpTables().getEntity());
        parameters.setAuthMethod(model.getAuthenticationMethod());
        Provider<?> networkProvider = model.getNetworkProviders().getSelectedItem();
        if (networkProvider != null) {
            parameters.getVdsStaticData().setOpenstackNetworkProviderId(networkProvider.getId());
            parameters.setNetworkMappings(model.getInterfaceMappings().getEntity());
        }
        if (model.getProviders().getSelectedItem() != null) {
            parameters.getVdsStaticData().setHostProviderId(model.getProviders().getSelectedItem().getId());
        }
        if (Boolean.TRUE.equals(model.getIsDiscoveredHosts().getEntity())) {
            Provider<?> provider = model.getProviders().getSelectedItem();
            ExternalHostGroup hostGroup = (ExternalHostGroup) model.getExternalHostGroups().getSelectedItem();
            ExternalComputeResource computeResource = (ExternalComputeResource) model.getExternalComputeResource().getSelectedItem();
            ExternalDiscoveredHost discoveredHost = (ExternalDiscoveredHost) model.getExternalDiscoveredHosts().getSelectedItem();
            parameters.initVdsActionParametersForProvision(provider.getId(), hostGroup, computeResource, discoveredHost.getMac(), discoveredHost.getName(), discoveredHost.getIp());
        }
        parameters.setHostedEngineDeployConfiguration(new HostedEngineDeployConfiguration(model.getHostedEngineHostModel().getSelectedItem()));
        parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
        Frontend.getInstance().runAction(ActionType.AddVds, parameters, result -> {
            Object[] array = (Object[]) result.getState();
            HostListModel<Void> localModel = (HostListModel<Void>) array[0];
            boolean localApproveInitiated = (Boolean) array[1];
            localModel.postOnSaveInternal(result.getReturnValue(), localApproveInitiated);
        }, new Object[] { this, approveInitiated });
    } else {
        // Update VDS -> consists of changing VDS cluster first and then updating rest of VDS properties:
        UpdateVdsActionParameters parameters = new UpdateVdsActionParameters();
        parameters.setvds(host);
        parameters.setVdsId(host.getId());
        // $NON-NLS-1$
        parameters.setPassword("");
        parameters.setInstallHost(false);
        parameters.setAuthMethod(model.getAuthenticationMethod());
        parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
        parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
        if (model.getExternalHostProviderEnabled().getEntity() && model.getProviders().getSelectedItem() != null) {
            host.setHostProviderId(model.getProviders().getSelectedItem().getId());
        }
        if (!oldClusterId.equals(newClusterId)) {
            Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(newClusterId, host.getId()), result -> {
                Object[] array = (Object[]) result.getState();
                HostListModel<Void> localModel = (HostListModel<Void>) array[0];
                UpdateVdsActionParameters localParameters = (UpdateVdsActionParameters) array[1];
                boolean localApproveInitiated = (Boolean) array[2];
                ActionReturnValue localReturnValue = result.getReturnValue();
                if (localReturnValue != null && localReturnValue.getSucceeded()) {
                    localModel.postOnSaveInternalChangeCluster(localParameters, localApproveInitiated);
                } else {
                    localModel.getWindow().stopProgress();
                }
            }, new Object[] { this, parameters, approveInitiated });
        } else {
            postOnSaveInternalChangeCluster(parameters, approveInitiated);
        }
    }
}
Also used : ExternalComputeResource(org.ovirt.engine.core.common.businessentities.ExternalComputeResource) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) Guid(org.ovirt.engine.core.compat.Guid) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration)

Aggregations

ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)7 VDS (org.ovirt.engine.core.common.businessentities.VDS)7 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 Timer (com.google.gwt.user.client.Timer)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)3 Guid (org.ovirt.engine.core.compat.Guid)3 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)3 MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)2 ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Host (org.ovirt.engine.api.model.Host)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)1