Search in sources :

Example 91 with ActionParametersBase

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

the class ImportVmFromExportDomainModel method buildImportVmParameters.

private List<ActionParametersBase> buildImportVmParameters() {
    List<ActionParametersBase> prms = new ArrayList<>();
    for (Object item : getItems()) {
        VM vm = ((ImportVmData) item).getVm();
        ImportVmParameters prm = new ImportVmParameters(vm, (Guid) getEntity(), Guid.Empty, getStoragePool().getId(), getCluster().getSelectedItem().getId());
        if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
            prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
        }
        CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
        if (cpuProfile != null) {
            prm.setCpuProfileId(cpuProfile.getId());
        }
        prm.setForceOverride(true);
        prm.setCopyCollapse(((ImportVmData) item).getCollapseSnapshots().getEntity());
        Map<Guid, Guid> map = new HashMap<>();
        for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
            DiskImage disk = (DiskImage) entry.getValue();
            map.put(disk.getId(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getId());
            disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(getDiskImportData(disk.getId()).getSelectedVolumeType(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getStorageType()));
            disk.setVolumeType(getDiskImportData(disk.getId()).getSelectedVolumeType());
            if (getDiskImportData(disk.getId()).getSelectedQuota() != null) {
                disk.setQuotaId(getDiskImportData(disk.getId()).getSelectedQuota().getId());
            }
        }
        prm.setImageToDestinationDomainMap(map);
        if (((ImportVmData) item).isExistsInSystem() || ((ImportVmData) item).getClone().getEntity()) {
            prm.setImportAsNewEntity(true);
            prm.setCopyCollapse(true);
        }
        prms.add(prm);
    }
    return prms;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) VM(org.ovirt.engine.core.common.businessentities.VM) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters) HashMap(java.util.HashMap) Map(java.util.Map) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 92 with ActionParametersBase

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

the class ImportVmFromExternalSourceModel method buildImportVmFromExternalProviderParameters.

private List<ActionParametersBase> buildImportVmFromExternalProviderParameters() {
    List<ActionParametersBase> prms = new ArrayList<>();
    for (Object item : getItems()) {
        ImportVmData importVmData = (ImportVmData) item;
        VM vm = importVmData.getVm();
        ImportVmFromExternalProviderParameters prm = new ImportVmFromExternalProviderParameters(vm, getStorage().getSelectedItem().getId(), getStoragePool().getId(), getCluster().getSelectedItem().getId());
        prm.setUrl(url);
        prm.setUsername(username);
        prm.setPassword(password);
        prm.setProxyHostId(proxyHostId);
        prm.setVirtioIsoName(getIso().getIsChangable() && getIso().getSelectedItem() != null ? getIso().getSelectedItem().getRepoImageId() : null);
        prm.setExternalName(importVmData.getName());
        if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
            prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
        }
        CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
        if (cpuProfile != null) {
            prm.setCpuProfileId(cpuProfile.getId());
        }
        prm.setForceOverride(true);
        prm.setCopyCollapse(importVmData.getCollapseSnapshots().getEntity());
        for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
            DiskImage disk = (DiskImage) entry.getValue();
            ImportDiskData importDiskData = getDiskImportData(disk.getDiskAlias());
            disk.setVolumeType(getAllocation().getSelectedItem());
            // virt-v2v which converts the image format as well
            if (vm.getOrigin() != OriginType.KVM) {
                disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(disk.getVolumeType(), getStorage().getSelectedItem().getStorageType()));
            }
            if (getDiskImportData(disk.getDiskAlias()).getSelectedQuota() != null) {
                disk.setQuotaId(importDiskData.getSelectedQuota().getId());
            }
        }
        updateNetworkInterfacesForVm(vm);
        if (importVmData.isExistsInSystem() || importVmData.getClone().getEntity()) {
            prm.setImportAsNewEntity(true);
            prm.setCopyCollapse(true);
        }
        prms.add(prm);
    }
    return prms;
}
Also used : ArrayList(java.util.ArrayList) ImportVmFromExternalProviderParameters(org.ovirt.engine.core.common.action.ImportVmFromExternalProviderParameters) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) VM(org.ovirt.engine.core.common.businessentities.VM) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Map(java.util.Map) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 93 with ActionParametersBase

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

the class RemoveVnicProfileModel method onRemove.

private void onRemove() {
    if (getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (VnicProfileView profile : getProfiles()) {
        ActionParametersBase parameters = getRemoveVnicProfileParams(profile);
        list.add(parameters);
    }
    startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveVnicProfile, list, result -> {
        stopProgress();
        cancel();
    }, null);
}
Also used : ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 94 with ActionParametersBase

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

the class SparsifyDiskModel method onSparsify.

public void onSparsify(final ICommandTarget target) {
    List<ActionParametersBase> parameterList = new ArrayList<>();
    for (Disk disk : disksToSparsify) {
        ActionParametersBase parameters = new StorageJobCommandParameters(((DiskImage) disk).getImageId());
        parameterList.add(parameters);
    }
    startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.SparsifyImage, parameterList, result -> {
        stopProgress();
        target.executeCommand(cancelCommand);
    }, this);
}
Also used : StorageJobCommandParameters(org.ovirt.engine.core.common.action.StorageJobCommandParameters) ArrayList(java.util.ArrayList) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 95 with ActionParametersBase

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

the class Backend method evaluateCorrelationId.

protected ActionReturnValue evaluateCorrelationId(CommandBase<?> commandBase) {
    ActionParametersBase cmdParams = commandBase.getParameters();
    if (cmdParams.getCorrelationId() == null && cmdParams.getParentParameters() != null) {
        cmdParams.setCorrelationId(cmdParams.getParentParameters().getCorrelationId());
    }
    // Evaluate and set the correlationId on the parameters, fails on invalid correlation id
    ActionReturnValue returnValue = ExecutionHandler.evaluateCorrelationId(cmdParams);
    if (returnValue != null) {
        log.warn("Validation of action '{}' failed. Reasons: {}", commandBase.getActionType(), StringUtils.join(returnValue.getValidationMessages(), ','));
    }
    // Set the correlation-id on the command
    commandBase.setCorrelationId(cmdParams.getCorrelationId());
    return returnValue;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)204 ArrayList (java.util.ArrayList)149 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)53 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)52 ActionType (org.ovirt.engine.core.common.action.ActionType)45 Test (org.junit.Test)44 Guid (org.ovirt.engine.core.compat.Guid)35 VDS (org.ovirt.engine.core.common.businessentities.VDS)26 List (java.util.List)23 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)23 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryType (org.ovirt.engine.core.common.queries.QueryType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)18 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)18 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)16 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)16 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)16 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15