Search in sources :

Example 1 with MigrateVmToServerParameters

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

the class VmListModel method onMigrate.

private void onMigrate() {
    MigrateModel model = (MigrateModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress();
    if (model.getIsAutoSelect()) {
        ArrayList<ActionParametersBase> list = new ArrayList<>();
        for (Object item : getSelectedItems()) {
            VM vm = (VM) item;
            list.add(new MigrateVmParameters(true, vm.getId(), vm.getClusterId()));
        }
        Frontend.getInstance().runMultipleAction(ActionType.MigrateVm, list, result -> {
            MigrateModel localModel = (MigrateModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    } else {
        ArrayList<ActionParametersBase> list = new ArrayList<>();
        for (Object item : getSelectedItems()) {
            VM vm = (VM) item;
            if (vm.getRunOnVds().equals(model.getHosts().getSelectedItem().getId())) {
                continue;
            }
            list.add(new MigrateVmToServerParameters(true, vm.getId(), model.getHosts().getSelectedItem().getId(), vm.getClusterId()));
        }
        Frontend.getInstance().runMultipleAction(ActionType.MigrateVmToServer, list, result -> {
            MigrateModel localModel = (MigrateModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    }
}
Also used : MigrateVmParameters(org.ovirt.engine.core.common.action.MigrateVmParameters) VM(org.ovirt.engine.core.common.businessentities.VM) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ArrayList (java.util.ArrayList)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 MigrateVmParameters (org.ovirt.engine.core.common.action.MigrateVmParameters)1 MigrateVmToServerParameters (org.ovirt.engine.core.common.action.MigrateVmToServerParameters)1 VM (org.ovirt.engine.core.common.businessentities.VM)1