use of org.ovirt.engine.core.common.action.ImagesContainterParametersBase in project ovirt-engine by oVirt.
the class AddVmCommand method addVmCinderDisks.
protected void addVmCinderDisks(Collection<DiskImage> templateDisks) {
List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(templateDisks);
if (cinderDisks.isEmpty()) {
return;
}
Map<Guid, Guid> diskImageMap = new HashMap<>();
for (CinderDisk cinderDisk : cinderDisks) {
ImagesContainterParametersBase params = buildCloneCinderDiskCommandParameters(cinderDisk);
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CloneSingleCinderDisk, params, cloneContext().withoutExecutionContext().withoutLock());
if (!actionReturnValue.getSucceeded()) {
log.error("Error cloning Cinder disk '{}': {}", cinderDisk.getDiskAlias());
getReturnValue().setFault(actionReturnValue.getFault());
return;
}
Guid imageId = actionReturnValue.getActionReturnValue();
diskImageMap.put(cinderDisk.getId(), imageId);
}
srcDiskIdToTargetDiskIdMapping.putAll(diskImageMap);
}
use of org.ovirt.engine.core.common.action.ImagesContainterParametersBase in project ovirt-engine by oVirt.
the class AddVmCommand method buildCloneCinderDiskCommandParameters.
private ImagesContainterParametersBase buildCloneCinderDiskCommandParameters(CinderDisk cinderDisk) {
ImagesContainterParametersBase createParams = new ImagesContainterParametersBase(cinderDisk.getImageId());
DiskImage templateDisk = diskInfoDestinationMap.get(cinderDisk.getId());
createParams.setDiskAlias(templateDisk.getDiskAlias());
createParams.setStorageDomainId(templateDisk.getStorageIds().get(0));
createParams.setEntityInfo(getParameters().getEntityInfo());
createParams.setParentCommand(getActionType());
createParams.setParentParameters(getParameters());
createParams.setVmSnapshotId(getVmSnapshotId());
return createParams;
}
use of org.ovirt.engine.core.common.action.ImagesContainterParametersBase in project ovirt-engine by oVirt.
the class RemoveAllVmTemplateImageTemplatesCommand method executeCommand.
@SuppressWarnings("unchecked")
@Override
protected void executeCommand() {
List<DiskImage> imageTemplates = DisksFilter.filterImageDisks(diskDao.getAllForVm(getVmTemplateId()), ONLY_ACTIVE);
for (DiskImage template : imageTemplates) {
// remove this disk in all domain that were sent
for (Guid domain : (Collection<Guid>) CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) {
ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(template.getImageId(), getVmTemplateId());
tempVar.setStorageDomainId(domain);
tempVar.setStoragePoolId(template.getStoragePoolId());
tempVar.setImageGroupID(template.getId());
tempVar.setEntityInfo(getParameters().getEntityInfo());
tempVar.setWipeAfterDelete(template.isWipeAfterDelete());
tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
tempVar.setParentCommand(getActionType());
tempVar.setParentParameters(getParameters());
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveTemplateSnapshot, tempVar);
if (actionReturnValue.getSucceeded()) {
getReturnValue().getInternalVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
} else {
log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, actionReturnValue.getFault().getMessage());
}
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(template.getImageId(), domain));
}
DiskImage diskImage = diskImageDao.get(template.getImageId());
if (diskImage != null) {
baseDiskDao.remove(template.getId());
vmDeviceDao.remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId()));
imageStorageDomainMapDao.remove(diskImage.getImageId());
imageDao.remove(template.getImageId());
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.action.ImagesContainterParametersBase in project ovirt-engine by oVirt.
the class RemoveDiskSnapshotsCommand method performNextOperationColdMerge.
private boolean performNextOperationColdMerge(int completedChildren) {
Guid nextImageId = getParameters().getImageIds().get(completedChildren);
log.info("Starting child command {} of {}, image '{}'", completedChildren + 1, getParameters().getImageIds().size(), nextImageId);
ImagesContainterParametersBase parameters = buildRemoveSnapshotSingleDiskParameters(nextImageId);
ActionType actionType = FeatureSupported.isQemuimgCommitSupported(getStoragePool().getCompatibilityVersion()) ? ActionType.ColdMergeSnapshotSingleDisk : ActionType.RemoveSnapshotSingleDisk;
commandCoordinatorUtil.executeAsyncCommand(actionType, parameters, cloneContextAndDetachFromParent());
return true;
}
use of org.ovirt.engine.core.common.action.ImagesContainterParametersBase in project ovirt-engine by oVirt.
the class RemoveDiskSnapshotsCommand method performNextOperationLiveMerge.
private boolean performNextOperationLiveMerge(int completedChildren) {
if (completedChildren != 0) {
checkImageIdConsistency(completedChildren - 1);
}
Guid nextImageId = getParameters().getImageIds().get(completedChildren);
log.info("Starting child command {} of {}, image '{}'", completedChildren + 1, getParameters().getImageIds().size(), nextImageId);
ImagesContainterParametersBase parameters = buildRemoveSnapshotSingleDiskLiveParameters(nextImageId, completedChildren);
updateParameters(completedChildren, parameters.getDestinationImageId());
persistCommandIfNeeded();
commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveSnapshotSingleDiskLive, parameters, cloneContextAndDetachFromParent());
return true;
}
Aggregations