use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.
the class AbstractBackendStorageDomainDisksResource method add.
public Response add(Disk disk) {
// Unregistering a disk using this method was deprecated in version 4.2
// unregistered support for add disk has moved to BackendAttachedStorageDomainDiskResource..
boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED, true, false);
if (unregistered) {
// First we need to query the backend to fill in all the information about the disk from the VDSM.
// We don't just use the information from the Disk object because it's missing a few things like creation
// date and last modified date.
Guid dataCenterId = BackendDataCenterHelper.lookupByStorageDomainId(this, storageDomainId);
GetUnregisteredDiskQueryParameters getDiskParams = new GetUnregisteredDiskQueryParameters(asGuid(disk.getId()), storageDomainId, dataCenterId);
DiskImage unregisteredDisk = getEntity(DiskImage.class, QueryType.GetUnregisteredDisk, getDiskParams, disk.getId());
unregisteredDisk = (DiskImage) getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class).map(disk, unregisteredDisk);
RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(unregisteredDisk, storageDomainId);
return performCreate(ActionType.RegisterDisk, registerDiskParams, ID_RESOLVER);
} else {
validateDiskForCreation(disk);
AddDiskParameters params = new AddDiskParameters();
params.setDiskInfo(getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class).map(disk, null));
params.setStorageDomainId(this.storageDomainId);
return performCreate(ActionType.AddDisk, params, ID_RESOLVER);
}
}
use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.
the class BackendDiskAttachmentsResource method getAddParameters.
private ActionParametersBase getAddParameters(DiskAttachment attachment, org.ovirt.engine.core.common.businessentities.storage.Disk entity, Disk disk) {
DiskVmElement dve = map(attachment);
dve.getId().setVmId(vmId);
AddDiskParameters parameters = new AddDiskParameters(dve, entity);
Guid storageDomainId = getStorageDomainId(disk);
if (storageDomainId != null) {
parameters.setStorageDomainId(storageDomainId);
}
if (attachment.isSetActive()) {
parameters.setPlugDiskToVm(attachment.isActive());
}
if (disk.isSetLunStorage() && disk.getLunStorage().isSetHost()) {
parameters.setVdsId(getHostId(disk.getLunStorage().getHost()));
}
return parameters;
}
use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.
the class ImportRepoImageCommand method createAddDiskParameters.
protected AddDiskParameters createAddDiskParameters() {
DiskImage diskImage = getParameters().getDiskImage();
ArrayList<Guid> storageIds = new ArrayList<>();
storageIds.add(getParameters().getStorageDomainId());
diskImage.setDiskAlias(getParameters().getDiskAlias());
diskImage.setStorageIds(storageIds);
diskImage.setId(getParameters().getImageGroupID());
diskImage.setDiskProfileId(getParameters().getDiskProfileId());
diskImage.setImageId(getParameters().getDestinationImageId());
diskImage.setQuotaId(getParameters().getQuotaId());
AddDiskParameters parameters = new AddDiskParameters(diskImage);
parameters.setStorageDomainId(getParameters().getStorageDomainId());
parameters.setParentCommand(getActionType());
parameters.setParentParameters(getParameters());
parameters.setShouldRemainIllegalOnFailedExecution(true);
parameters.setShouldRemainLockedOnSuccesfulExecution(true);
parameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
parameters.setUsePassedDiskId(true);
parameters.setUsePassedImageId(true);
parameters.setVmSnapshotId(getParameters().getVmSnapshotId());
return parameters;
}
use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.
the class CreateOvfVolumeForStorageDomainCommand method executeCommand.
@Override
protected void executeCommand() {
AddDiskParameters diskParameters = new AddDiskParameters(createDisk(getStorageDomainId()));
diskParameters.setStorageDomainId(getStorageDomainId());
diskParameters.setParentCommand(getActionType());
diskParameters.setParentParameters(getParameters());
diskParameters.setShouldRemainIllegalOnFailedExecution(true);
diskParameters.setSkipDomainCheck(getParameters().isSkipDomainChecks());
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.AddDisk, diskParameters);
Guid createdId = actionReturnValue.getActionReturnValue();
if (createdId != null) {
setActionReturnValue(createdId);
addStorageDomainOvfInfoToDb(createdId);
}
setSucceeded(actionReturnValue.getSucceeded());
}
use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.
the class LiveSnapshotMemoryImageBuilder method buildAddDiskParameters.
private AddDiskParameters buildAddDiskParameters(DiskImage disk) {
AddDiskParameters parameters = new AddDiskParameters(disk);
parameters.setStorageDomainId(storageDomainId);
parameters.setParentCommand(enclosingCommand.getActionType());
parameters.setParentParameters(enclosingCommand.getParameters());
parameters.setShouldBeLogged(false);
return parameters;
}
Aggregations