Search in sources :

Example 1 with HttpLocationInfo

use of org.ovirt.engine.core.common.businessentities.HttpLocationInfo 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 2 with HttpLocationInfo

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

the class ExportRepoImageCommand method executeCommand.

@Override
protected void executeCommand() {
    DiskImage diskImage = getDiskImage();
    OpenStackImageProviderProxy proxy = getProviderProxy();
    acquireImageDbLock();
    String newImageId = proxy.createImageFromDiskImage(diskImage);
    getParameters().setParentCommand(ActionType.ExportRepoImage);
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UploadImage, new UploadImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), getStorageDomain().getId(), diskImage.getId(), diskImage.getImageId(), new HttpLocationInfo(getProviderProxy().getImageUrl(newImageId), getProviderProxy().getUploadHeaders())));
    if (vdsReturnValue.getSucceeded()) {
        getReturnValue().getVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Disk, getParameters().getImageGroupID(), getParameters().getDestinationDomainId()));
    }
    getReturnValue().setActionReturnValue(newImageId);
    setSucceeded(true);
}
Also used : UploadImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) HttpLocationInfo(org.ovirt.engine.core.common.businessentities.HttpLocationInfo) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OpenStackImageProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

HttpLocationInfo (org.ovirt.engine.core.common.businessentities.HttpLocationInfo)2 HashMap (java.util.HashMap)1 OpenStackImageProviderProxy (org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy)1 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)1 ExternalLocationInfo (org.ovirt.engine.core.common.businessentities.ExternalLocationInfo)1 VdsmImageLocationInfo (org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 UploadImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 Guid (org.ovirt.engine.core.compat.Guid)1