use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method performStorageOperation.
private boolean performStorageOperation() {
Guid sourceDomainId = getParameters().getSourceDomainId() != null ? getParameters().getSourceDomainId() : getDiskImage().getStorageIds().get(0);
if (isUsingSPDMFlow()) {
CopyImageGroupWithDataCommandParameters p = new CopyImageGroupWithDataCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getStorageDomainId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getImageGroupID(), getParameters().getImageId(), getVolumeFormatForDomain(), getParameters().getUseCopyCollapse());
p.setParentParameters(getParameters());
p.setParentCommand(getActionType());
p.setEndProcedure(EndProcedure.COMMAND_MANAGED);
p.setJobWeight(getParameters().getJobWeight());
runInternalAction(ActionType.CopyImageGroupWithData, p);
return true;
} else {
VDSReturnValue vdsReturnValue;
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
if (getParameters().getUseCopyCollapse()) {
vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getContainerId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getDestImageGroupId(), getParameters().getDestinationImageId(), "", getParameters().getStorageDomainId(), getParameters().getCopyVolumeType(), getVolumeFormatForDomain(), getParameters().getVolumeType(), isWipeAfterDelete(), getStorageDomain().getDiscardAfterDelete(), getParameters().getForceOverride())));
} else {
vdsReturnValue = runVdsCommand(VDSCommandType.MoveImageGroup, postDeleteActionHandler.fixParameters(new MoveImageGroupVDSCommandParameters(getDiskImage() != null ? getDiskImage().getStoragePoolId() : getStorageDomain().getStoragePoolId(), sourceDomainId, getDiskImage() != null ? getDiskImage().getId() : getParameters().getImageGroupID(), getParameters().getStorageDomainId(), getParameters().getContainerId(), ImageOperation.Copy, isWipeAfterDelete(), storageDomainDao.get(sourceDomainId).getDiscardAfterDelete(), getParameters().getForceOverride())));
}
if (vdsReturnValue.getSucceeded()) {
AsyncTaskCreationInfo taskCreationInfo = vdsReturnValue.getCreationInfo();
getTaskIdList().add(createTask(taskId, taskCreationInfo, getParameters().getParentCommand(), VdcObjectType.Storage, sourceDomainId, getParameters().getStorageDomainId()));
}
return vdsReturnValue.getSucceeded();
}
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CreateImageTemplateCommand method executeCommand.
@Override
protected void executeCommand() {
Guid storagePoolId = getDiskImage().getStoragePoolId() != null ? getDiskImage().getStoragePoolId() : Guid.Empty;
Guid imageGroupId = getDiskImage().getId() != null ? getDiskImage().getId() : Guid.Empty;
Guid snapshotId = getDiskImage().getImageId();
// Create new image group id and image id:
Guid destinationImageGroupID = Guid.newGuid();
setDestinationImageId(Guid.newGuid());
DiskImage newImage = cloneDiskImage(getDestinationImageId());
if (getParameters().getVolumeFormat() == null || getParameters().getVolumeType() == null) {
// At least one of the volume arguments should be copied from the ancestral image.
fillVolumeInformation(newImage);
}
if (getParameters().getVolumeFormat() != null) {
newImage.setVolumeFormat(getParameters().getVolumeFormat());
}
if (getParameters().getVolumeType() != null) {
newImage.setVolumeType(getParameters().getVolumeType());
}
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
VolumeFormat targetFormat = getTargetVolumeFormat(newImage.getVolumeFormat(), newImage.getVolumeType(), getParameters().getDestinationStorageDomainId());
newImage.setDiskAlias(getParameters().getDiskAlias() != null ? getParameters().getDiskAlias() : getDiskImage().getDiskAlias());
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(storagePoolId, getParameters().getStorageDomainId(), getParameters().getVmId(), imageGroupId, snapshotId, destinationImageGroupID, getDestinationImageId(), getJsonDiskDescription(newImage), getParameters().getDestinationStorageDomainId(), getParameters().getCopyVolumeType(), targetFormat, newImage.getVolumeType(), getDiskImage().isWipeAfterDelete(), storageDomainDao.get(getParameters().getDestinationStorageDomainId()).getDiscardAfterDelete(), false)));
getReturnValue().getInternalVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId(), getParameters().getDestinationStorageDomainId()));
newImage.setId(destinationImageGroupID);
newImage.setDiskDescription(getParameters().getDescription() != null ? getParameters().getDescription() : getDiskImage().getDiskDescription());
newImage.setVmSnapshotId(getParameters().getVmSnapshotId());
newImage.setQuotaId(getParameters().getQuotaId());
newImage.setDiskProfileId(getParameters().getDiskProfileId());
newImage.setParentId(Guid.Empty);
newImage.setImageTemplateId(Guid.Empty);
newImage.setStorageIds(new ArrayList<>(Arrays.asList(getParameters().getDestinationStorageDomainId())));
newImage.setActive(true);
imagesHandler.saveImage(newImage);
baseDiskDao.save(newImage);
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(newImage.getImageId());
diskDynamic.setActualSize(getDiskImage().getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
setActionReturnValue(newImage);
// set source image as locked:
lockImage();
setSucceeded(true);
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CreateVolumeContainerCommand method executeCommand.
@Override
protected void executeCommand() {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CreateVolume, getCreateVDSCommandParameters());
if (vdsReturnValue.getSucceeded()) {
getParameters().setVdsmTaskIds(new ArrayList<>());
getParameters().getVdsmTaskIds().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
getTaskIdList().add(getParameters().getVdsmTaskIds().get(0));
setSucceeded(true);
}
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class GetUnregisteredDisksQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
StorageDomain storageDomain = storageDomainDao.get(getStorageDomainId());
if (storageDomain == null) {
getQueryReturnValue().setExceptionString(EngineMessage.STORAGE_DOMAIN_DOES_NOT_EXIST.toString());
getQueryReturnValue().setSucceeded(false);
return;
}
if (storageDomain.getStorageType().isCinderDomain()) {
QueryReturnValue returnValue = runInternalQuery(QueryType.GetUnregisteredCinderDisksByStorageDomainId, new IdQueryParameters(getStorageDomainId()));
setReturnValue(returnValue.getReturnValue());
return;
}
// first, run getImagesList query into vdsm to get all of the images on the storage domain - then store in
// imagesList
VDSReturnValue imagesListResult = runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(getStorageDomainId(), getStoragePoolId()));
@SuppressWarnings("unchecked") List<Guid> imagesList = (List<Guid>) imagesListResult.getReturnValue();
// fromDao is a list of all disk images on the domain from the Dao
List<DiskImage> fromDao = diskImageDao.getAllSnapshotsForStorageDomain(getStorageDomainId());
// if the ID in imagesList is recognized by oVirt, remove from list
for (DiskImage image : fromDao) {
imagesList.remove(image.getId());
}
List<Disk> unregisteredDisks = new ArrayList<>();
for (Guid unregisteredDiskId : imagesList) {
GetUnregisteredDiskQueryParameters unregQueryParams = new GetUnregisteredDiskQueryParameters(unregisteredDiskId, getStorageDomainId(), getStoragePoolId());
QueryReturnValue unregQueryReturn = runInternalQuery(QueryType.GetUnregisteredDisk, unregQueryParams);
if (unregQueryReturn.getSucceeded()) {
unregisteredDisks.add(unregQueryReturn.getReturnValue());
} else {
log.debug("Could not get populated disk: {}", unregQueryReturn.getExceptionString());
}
}
getQueryReturnValue().setReturnValue(unregisteredDisks);
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class ExtendImageSizeCommand method executeCommand.
@Override
protected void executeCommand() {
VDSReturnValue vdsReturnValue = extendUnderlyingVolumeSize(getImage());
setSucceeded(vdsReturnValue.getSucceeded());
if (vdsReturnValue.getSucceeded()) {
Guid taskId = createTask(getAsyncTaskId(), vdsReturnValue.getCreationInfo(), getParameters().getParentCommand());
getReturnValue().getInternalVdsmTaskIdList().add(taskId);
if (getParameters().getParentNotifiesCallback()) {
getParameters().setVdsmTaskIds(new ArrayList<>(Collections.singletonList(taskId)));
getReturnValue().getVdsmTaskIdList().add(taskId);
persistCommand(getParameters().getParentCommand(), true);
}
} else {
updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE, getParameters().getNewSizeInGB());
}
}
Aggregations