use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddVmCommand method makeNewImage.
private DiskImage makeNewImage(Guid storageId, DiskImage image) {
DiskImage newImage = new DiskImage();
newImage.setImageId(image.getImageId());
newImage.setDiskAlias(image.getDiskAlias());
newImage.setVolumeFormat(image.getVolumeFormat());
newImage.setVolumeType(image.getVolumeType());
ArrayList<Guid> storageIds = new ArrayList<>();
storageIds.add(storageId);
newImage.setStorageIds(storageIds);
newImage.setQuotaId(image.getQuotaId());
// Find out the correct disk profile for storage domain
newImage.setDiskProfileId(diskProfileDao.getAllForStorageDomain(storageId).stream().filter(p -> image.getDiskProfileIds().contains(p.getId())).findFirst().map(p -> p.getId()).orElse(null));
return newImage;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddVmCommand method addVmImages.
protected boolean addVmImages() {
if (!vmDisksSource.getDiskTemplateMap().isEmpty()) {
if (getVm().getStatus() != VMStatus.Down) {
log.error("Cannot add images. VM is not Down");
throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
}
lockVM();
Collection<DiskImage> templateDisks = getImagesToCheckDestinationStorageDomains();
List<DiskImage> diskImages = DisksFilter.filterImageDisks(templateDisks, ONLY_NOT_SHAREABLE, ONLY_ACTIVE);
for (DiskImage image : diskImages) {
ActionReturnValue result = runInternalActionWithTasksContext(getDiskCreationCommandType(), buildDiskCreationParameters(image));
// if couldn't create snapshot then stop the transaction and the command
if (!result.getSucceeded()) {
throw new EngineException(result.getFault().getError());
} else {
getTaskIdList().addAll(result.getInternalVdsmTaskIdList());
DiskImage newImage = result.getActionReturnValue();
srcDiskIdToTargetDiskIdMapping.put(image.getId(), newImage.getId());
}
}
// Clone volumes for Cinder disk templates
addVmCinderDisks(templateDisks);
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddVmCommand method getSharedLocks.
@Override
protected Map<String, Pair<String, String>> getSharedLocks() {
Map<String, Pair<String, String>> locks = new HashMap<>();
locks.put(getVmTemplateId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, new LockMessage(EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_IS_USED_FOR_CREATE_VM).with("VmName", getVmName())));
for (DiskImage image : getImagesToCheckDestinationStorageDomains()) {
locks.put(image.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, getDiskSharedLockMessage()));
}
if (getParameters().getPoolId() != null) {
locks.put(getParameters().getPoolId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM_POOL, new LockMessage(EngineMessage.ACTION_TYPE_FAILED_VM_POOL_IS_USED_FOR_CREATE_VM).with("VmName", getVmName())));
}
return locks;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddVmTemplateCommand method createDiskDummiesForSpaceValidations.
/**
* Space Validations are done using data extracted from the disks. The disks in question in this command
* don't have all the needed data, and in order not to contaminate the command's data structures, an alter
* one is created specifically for this validation - hence dummy.
*/
private List<DiskImage> createDiskDummiesForSpaceValidations(Collection<DiskImage> disksList) {
List<DiskImage> dummies = new ArrayList<>(disksList.size());
for (DiskImage image : disksList) {
Guid targetSdId = diskInfoDestinationMap.get(image.getId()).getStorageIds().get(0);
DiskImage dummy = imagesHandler.createDiskImageWithExcessData(image, targetSdId);
dummies.add(dummy);
}
return dummies;
}
Aggregations