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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations