Search in sources :

Example 11 with AddDiskParameters

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);
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters) RegisterDiskParameters(org.ovirt.engine.core.common.action.RegisterDiskParameters) GetUnregisteredDiskQueryParameters(org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.api.model.Disk)

Example 12 with AddDiskParameters

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;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 13 with AddDiskParameters

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;
}
Also used : ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 14 with AddDiskParameters

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());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 15 with AddDiskParameters

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;
}
Also used : AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Aggregations

AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)17 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 Guid (org.ovirt.engine.core.compat.Guid)6 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)3 ArrayList (java.util.ArrayList)2 Disk (org.ovirt.engine.api.model.Disk)1 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)1 QuotaStorageConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 RegisterDiskParameters (org.ovirt.engine.core.common.action.RegisterDiskParameters)1 TransferDiskImageParameters (org.ovirt.engine.core.common.action.TransferDiskImageParameters)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)1 GetUnregisteredDiskQueryParameters (org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)1