Search in sources :

Example 1 with VdsmImageLocationInfo

use of org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo in project ovirt-engine by oVirt.

the class CopyDataCommand method completeGenerationInfo.

private void completeGenerationInfo() {
    if (!isDstVdsmImage()) {
        return;
    }
    VdsmImageLocationInfo info = (VdsmImageLocationInfo) getParameters().getDstInfo();
    DiskImage image = imagesHandler.getVolumeInfoFromVdsm(getParameters().getStoragePoolId(), info.getStorageDomainId(), info.getImageGroupId(), info.getImageId());
    info.setGeneration(image.getImage().getGeneration());
    persistCommandIfNeeded();
}
Also used : VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with VdsmImageLocationInfo

use of org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo in project ovirt-engine by oVirt.

the class LocationInfoHelper method prepareLocationInfoForVdsCommand.

public static Map<String, Object> prepareLocationInfoForVdsCommand(LocationInfo locationInfo) {
    if (locationInfo instanceof ExternalLocationInfo) {
        ExternalLocationInfo info = (ExternalLocationInfo) locationInfo;
        if (ConnectionMethod.HTTP.equals(info.getConnectionMethod())) {
            HttpLocationInfo httpInfo = (HttpLocationInfo) info;
            Map<String, Object> infoMap = new HashMap<>();
            infoMap.put("method", "http");
            infoMap.put("url", httpInfo.getUrl());
            infoMap.put("headers", httpInfo.getHeaders());
            return infoMap;
        }
    }
    if (locationInfo instanceof VdsmImageLocationInfo) {
        VdsmImageLocationInfo info = (VdsmImageLocationInfo) locationInfo;
        Map<String, Object> infoMap = new HashMap<>();
        infoMap.put("endpoint_type", "div");
        infoMap.put("sd_id", info.getStorageDomainId().toString());
        infoMap.put("img_id", info.getImageGroupId().toString());
        infoMap.put("vol_id", info.getImageId().toString());
        if (info.getGeneration() != null) {
            infoMap.put("generation", info.getGeneration());
        }
        return infoMap;
    }
    throw new RuntimeException("Unsupported location info");
}
Also used : HashMap(java.util.HashMap) HttpLocationInfo(org.ovirt.engine.core.common.businessentities.HttpLocationInfo) ExternalLocationInfo(org.ovirt.engine.core.common.businessentities.ExternalLocationInfo) VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)

Example 3 with VdsmImageLocationInfo

use of org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo in project ovirt-engine by oVirt.

the class UpdateAllTemplateDisksCommand method buildUpdateVolumeCommandParameters.

private UpdateVolumeCommandParameters buildUpdateVolumeCommandParameters(DiskImage diskImage) {
    UpdateVolumeCommandParameters parameters = new UpdateVolumeCommandParameters(diskImage.getStoragePoolId(), new VdsmImageLocationInfo(diskImage), getParameters().getLegal(), null, null, getParameters().getShared());
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    parameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return parameters;
}
Also used : UpdateVolumeCommandParameters(org.ovirt.engine.core.common.action.UpdateVolumeCommandParameters) VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)

Example 4 with VdsmImageLocationInfo

use of org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo in project ovirt-engine by oVirt.

the class AmendVolumeCommand method getImage.

private Image getImage() {
    if (image == null) {
        VdsmImageLocationInfo info = (VdsmImageLocationInfo) getParameters().getVolInfo();
        image = imageDao.get(info.getImageId());
    }
    return image;
}
Also used : VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)

Example 5 with VdsmImageLocationInfo

use of org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo in project ovirt-engine by oVirt.

the class AmendVolumeCommand method executeCommand.

@Override
protected void executeCommand() {
    VdsmImageLocationInfo info = (VdsmImageLocationInfo) getParameters().getVolInfo();
    DiskImage image = imagesHandler.getVolumeInfoFromVdsm(getParameters().getStoragePoolId(), info.getStorageDomainId(), info.getImageGroupId(), info.getImageId());
    info.setGeneration(image.getImage().getGeneration());
    persistCommandIfNeeded();
    VDSReturnValue vdsReturnValue = vdsCommandsHelper.runVdsCommandWithFailover(VDSCommandType.AmendVolume, new AmendVolumeVDSCommandParameters(getParameters().getStorageJobId(), info.getStorageDomainId(), info.getImageGroupId(), info.getImageId(), info.getGeneration(), getParameters().getQcowCompat()), getParameters().getStoragePoolId(), this);
    if (!vdsReturnValue.getSucceeded()) {
        setCommandStatus(CommandStatus.FAILED);
    }
    setSucceeded(vdsReturnValue.getSucceeded());
}
Also used : VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) AmendVolumeVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.AmendVolumeVDSCommandParameters)

Aggregations

VdsmImageLocationInfo (org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)10 FenceVolumeJobCommandParameters (org.ovirt.engine.core.common.action.FenceVolumeJobCommandParameters)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 HashMap (java.util.HashMap)1 UpdateVolumeCommandParameters (org.ovirt.engine.core.common.action.UpdateVolumeCommandParameters)1 ExternalLocationInfo (org.ovirt.engine.core.common.businessentities.ExternalLocationInfo)1 HttpLocationInfo (org.ovirt.engine.core.common.businessentities.HttpLocationInfo)1 SubchainInfo (org.ovirt.engine.core.common.businessentities.SubchainInfo)1 AmendVolumeVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.AmendVolumeVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1