use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class AddVmCommand method init.
@Override
protected void init() {
super.init();
T parameters = getParameters();
if (parameters.getVmStaticData() != null) {
Guid templateIdToUse = getParameters().getVmStaticData().getVmtGuid();
if (parameters.getVmStaticData().isUseLatestVersion()) {
VmTemplate latest = vmTemplateDao.getTemplateWithLatestVersionInChain(templateIdToUse);
if (latest != null) {
// as it may have different set of disks
if (!templateIdToUse.equals(latest.getId())) {
getParameters().setDiskInfoDestinationMap(new HashMap<>());
}
setVmTemplate(latest);
templateIdToUse = latest.getId();
getParameters().getVmStaticData().setVmtGuid(templateIdToUse);
}
}
setVmTemplateId(templateIdToUse);
// API backward compatibility
if (getVmDeviceUtils().shouldOverrideSoundDevice(getParameters().getVmStaticData(), getEffectiveCompatibilityVersion(), getParameters().isSoundDeviceEnabled())) {
parameters.setSoundDeviceEnabled(true);
}
if (parameters.isConsoleEnabled() == null) {
parameters.setConsoleEnabled(false);
}
vmDevicesSourceId = (getInstanceTypeId() != null) ? getInstanceTypeId() : parameters.getVmStaticData().getVmtGuid();
imageTypeId = parameters.getVmStaticData().getImageTypeId();
vmInterfacesSourceId = parameters.getVmStaticData().getVmtGuid();
vmDisksSource = getVmTemplate();
}
parameters.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
// override values here for validate to run with correct values, has to come before init-disks
if (isCompatibilityVersionSupportedByCluster(getEffectiveCompatibilityVersion())) {
updateVmObject();
}
if (getParameters().getVmStaticData().getDefaultDisplayType() == DisplayType.none && !parameters.isConsoleEnabled()) {
parameters.getVmStaticData().setUsbPolicy(UsbPolicy.DISABLED);
}
initTemplateDisks();
initStoragePoolId();
diskInfoDestinationMap = getParameters().getDiskInfoDestinationMap();
if (diskInfoDestinationMap == null) {
diskInfoDestinationMap = new HashMap<>();
}
vmHandler.updateDefaultTimeZone(parameters.getVmStaticData());
vmHandler.autoSelectResumeBehavior(getParameters().getVmStaticData(), getCluster());
// Fill the migration policy if it was omitted
if (getParameters().getVmStaticData() != null && getParameters().getVmStaticData().getMigrationSupport() == null) {
setDefaultMigrationPolicy();
}
if (vmDisksSource != null) {
parameters.setUseCinderCommandCallback(!vmDisksSource.getDiskTemplateMap().isEmpty());
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class ImportVmTemplateCommand method moveOrCopyAllImageGroups.
@Override
protected void moveOrCopyAllImageGroups(final Guid containerID, final Iterable<DiskImage> disks) {
TransactionSupport.executeInNewTransaction(() -> {
for (DiskImage disk : disks) {
Guid originalDiskId = newDiskIdForDisk.get(disk.getId()).getId();
Guid destinationDomain = imageToDestinationDomainMap.get(originalDiskId);
MoveOrCopyImageGroupParameters p = new MoveOrCopyImageGroupParameters(containerID, originalDiskId, newDiskIdForDisk.get(disk.getId()).getImageId(), disk.getId(), disk.getImageId(), destinationDomain, ImageOperation.Copy);
p.setParentCommand(getActionType());
p.setUseCopyCollapse(true);
p.setVolumeType(disk.getVolumeType());
p.setVolumeFormat(disk.getVolumeFormat());
p.setCopyVolumeType(CopyVolumeType.SharedVol);
p.setSourceDomainId(getParameters().getSourceDomainId());
p.setForceOverride(getParameters().getForceOverride());
p.setImportEntity(true);
p.setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, containerID));
p.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
for (DiskImage diskImage : getParameters().getVmTemplate().getDiskList()) {
if (originalDiskId.equals(diskImage.getId())) {
p.setQuotaId(diskImage.getQuotaId());
p.setDiskProfileId(diskImage.getDiskProfileId());
break;
}
}
p.setParentParameters(getParameters());
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, p);
if (!vdcRetValue.getSucceeded()) {
throw vdcRetValue.getFault() != null ? new EngineException(vdcRetValue.getFault().getError()) : new EngineException(EngineError.ENGINE);
}
getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList());
}
return null;
});
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForDisk.
private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForDisk(DiskImage disk, Guid containerID) {
Guid originalDiskId = newDiskIdForDisk.get(disk.getId()).getId();
Guid destinationDomain = imageToDestinationDomainMap.get(originalDiskId);
MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, originalDiskId, newDiskIdForDisk.get(disk.getId()).getImageId(), disk.getId(), disk.getImageId(), destinationDomain, ImageOperation.Copy);
params.setParentCommand(getActionType());
params.setUseCopyCollapse(isCopyCollapseOrNoSnapshots());
params.setCopyVolumeType(CopyVolumeType.LeafVol);
params.setForceOverride(getParameters().getForceOverride());
params.setSourceDomainId(getParameters().getSourceDomainId());
params.setStoragePoolId(getParameters().getStoragePoolId());
params.setImportEntity(true);
params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
params.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
params.setQuotaId(disk.getQuotaId() != null ? disk.getQuotaId() : getParameters().getQuotaId());
params.setDiskProfileId(disk.getDiskProfileId());
if (getParameters().getVm().getDiskMap() != null && getParameters().getVm().getDiskMap().containsKey(originalDiskId)) {
DiskImageBase diskImageBase = (DiskImageBase) getParameters().getVm().getDiskMap().get(originalDiskId);
params.setVolumeType(diskImageBase.getVolumeType());
params.setVolumeFormat(diskImageBase.getVolumeFormat());
}
params.setParentParameters(getParameters());
return params;
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForMemoryDumpImage.
private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForMemoryDumpImage(Guid containerID, Guid storageId, Guid imageId, Guid volumeId) {
MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, imageId, volumeId, imageId, volumeId, storageId, ImageOperation.Copy);
params.setParentCommand(getActionType());
params.setCopyVolumeType(CopyVolumeType.LeafVol);
params.setForceOverride(getParameters().getForceOverride());
params.setSourceDomainId(getParameters().getSourceDomainId());
params.setStoragePoolId(getParameters().getStoragePoolId());
params.setImportEntity(true);
params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
params.setParentParameters(getParameters());
StorageDomainStatic storageDomain = storageDomainStaticDao.get(storageId);
if (storageDomain.getStorageType().isBlockDomain()) {
params.setUseCopyCollapse(true);
params.setVolumeType(VolumeType.Preallocated);
params.setVolumeFormat(VolumeFormat.RAW);
}
return params;
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class MoveOrCopyTemplateCommand method init.
@Override
public void init() {
super.init();
setVmTemplateId(getParameters().getContainerId());
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, getVmTemplateId()));
imageToDestinationDomainMap = getParameters().getImageToDestinationDomainMap();
imageFromSourceDomainMap = new HashMap<>();
}
Aggregations