Search in sources :

Example 1 with VdsActionParameters

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

the class HostListModel method onSshRestart.

public void onSshRestart() {
    ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
    if (model.getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VDS vds = (VDS) item;
        VdsActionParameters params = new VdsActionParameters(vds.getId());
        params.setPrevVdsStatus(vds.getStatus());
        list.add(params);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.SshHostReboot, list, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        cancelConfirm();
    }, model);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with VdsActionParameters

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

the class HostListModel method refreshCapabilities.

private void refreshCapabilities() {
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VDS vds = (VDS) item;
        list.add(new VdsActionParameters(vds.getId()));
    }
    Frontend.getInstance().runMultipleAction(ActionType.RefreshHost, list, result -> {
    }, null);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 3 with VdsActionParameters

use of org.ovirt.engine.core.common.action.VdsActionParameters 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 4 with VdsActionParameters

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

the class UpdateClusterCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid newMacPoolId = getNewMacPoolId();
    moveMacs.migrateMacsToAnotherMacPool(oldCluster, newMacPoolId, getContext());
    getCluster().setArchitecture(getArchitecture());
    setDefaultSwitchTypeIfNeeded();
    setDefaultFirewallTypeIfNeeded();
    // TODO: This code should be revisited and proper compensation logic should be introduced here
    checkMaxMemoryOverCommitValue();
    if (!Objects.equals(oldCluster.getCompatibilityVersion(), getParameters().getCluster().getCompatibilityVersion())) {
        String emulatedMachine = null;
        // pick an UP host randomly - all should have latest compat version already if we passed validate.
        for (VDS vds : allForCluster) {
            if (vds.getStatus() == VDSStatus.Up) {
                emulatedMachine = getEmulatedMachineOfHostInCluster(vds);
                break;
            }
        }
        if (emulatedMachine == null) {
            getParameters().getCluster().setDetectEmulatedMachine(true);
        } else {
            getParameters().getCluster().setEmulatedMachine(emulatedMachine);
        }
    } else if (oldCluster.getArchitecture() != getCluster().getArchitecture()) {
        // if architecture was changed, emulated machines must be updated when adding new host.
        // At this point the cluster is empty and have changed CPU name
        getParameters().getCluster().setDetectEmulatedMachine(true);
        getParameters().getCluster().setEmulatedMachine(null);
    }
    if (getParameters().isForceResetEmulatedMachine()) {
        getParameters().getCluster().setDetectEmulatedMachine(true);
    }
    boolean isKsmPolicyChanged = (getCluster().isKsmMergeAcrossNumaNodes() != getPrevCluster().isKsmMergeAcrossNumaNodes()) || (getCluster().isEnableKsm() != getPrevCluster().isEnableKsm());
    clusterDao.update(getParameters().getCluster());
    addOrUpdateAddtionalClusterFeatures();
    if (!oldCluster.supportsGlusterService() && getCluster().supportsGlusterService()) {
        // update gluster parameters on all hosts
        updateGlusterHosts();
    }
    if (isAddedToStoragePool) {
        for (VDS vds : allForCluster) {
            VdsActionParameters parameters = new VdsActionParameters();
            parameters.setVdsId(vds.getId());
            ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, parameters, cloneContextAndDetachFromParent());
            if (!addVdsSpmIdReturn.getSucceeded()) {
                setSucceeded(false);
                getReturnValue().setFault(addVdsSpmIdReturn.getFault());
                return;
            }
        }
        final NetworkCluster managementNetworkCluster = createManagementNetworkCluster();
        networkClusterDao.save(managementNetworkCluster);
    }
    alertIfFencingDisabled();
    if (isKsmPolicyChanged) {
        momPolicyUpdatedEvent.fire(getCluster());
    }
    updateDefaultNetworkProvider();
    // Call UpdateVmCommand on all VMs in the cluster to update defaults (i.e. DisplayType)
    updateVms();
    updateTemplates();
    if (getCluster().getFirewallType() != getPrevCluster().getFirewallType()) {
        markHostsForReinstall();
    }
    if (!failedUpgradeEntities.isEmpty()) {
        logFailedUpgrades();
        failValidation(Arrays.asList(EngineMessage.CLUSTER_CANNOT_UPDATE_CLUSTER_FAILED_TO_UPDATE_VMS), "$VmList " + StringUtils.join(failedUpgradeEntities.keySet(), ", "));
        getReturnValue().setValid(false);
        setSucceeded(false);
        return;
    }
    if (!Objects.equals(oldCluster.getCompatibilityVersion(), getCluster().getCompatibilityVersion())) {
        vmStaticDao.getAllByCluster(getCluster().getId()).forEach(this::updateClusterVersionInManager);
    }
    setSucceeded(true);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with VdsActionParameters

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

the class AutoRecoveryManager method recoverImpl.

public void recoverImpl() {
    check(vdsDao, ActionType.ActivateVds, arg -> {
        final VdsActionParameters params = new VdsActionParameters(arg.getId());
        params.setRunSilent(true);
        return params;
    }, list -> {
        List<VDS> filtered = new ArrayList<>(list.size());
        List<VdsNetworkInterface> nics;
        for (VDS vds : list) {
            if (vds.getNonOperationalReason() == NonOperationalReason.NETWORK_INTERFACE_IS_DOWN) {
                backend.getResourceManager().runVdsCommand(VDSCommandType.GetStats, new VdsIdAndVdsVDSCommandParametersBase(vds));
                nics = vds.getInterfaces();
            } else {
                nics = interfaceDao.getAllInterfacesForVds(vds.getId());
            }
            Map<String, Set<String>> problematicNics = NetworkMonitoringHelper.determineProblematicNics(nics, networkDao.getAllForCluster(vds.getClusterId()));
            if (problematicNics.isEmpty()) {
                filtered.add(vds);
            }
        }
        return filtered;
    }, "hosts");
    check(storageDomainDao, ActionType.ConnectDomainToStorage, arg -> {
        final StorageDomainPoolParametersBase params = new StorageDomainPoolParametersBase(arg.getId(), arg.getStoragePoolId());
        params.setRunSilent(true);
        return params;
    }, list -> list, "storage domains");
}
Also used : Set(java.util.Set) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsIdAndVdsVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdAndVdsVDSCommandParametersBase) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Aggregations

VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)22 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 ArrayList (java.util.ArrayList)7 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)7 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 FenceVdsActionParameters (org.ovirt.engine.core.common.action.FenceVdsActionParameters)5 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 Timer (com.google.gwt.user.client.Timer)2 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)2 ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)2 InstallVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 JsSingleValueStringObject (org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)2 MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)2 HashMap (java.util.HashMap)1