Search in sources :

Example 26 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageProvider method mergeSourceImageAndCustomImageProperties.

public StatedImage mergeSourceImageAndCustomImageProperties(StatedImage statedImage, CustomImage customImage, String imageCatalogUrl, String catalogName) {
    Image image = statedImage.getImage();
    Image result = new Image(image.getDate(), customImage.getCreated(), customImage.getCreated(), customImage.getDescription(), image.getOs(), customImage.getName(), image.getVersion(), getRepoWithCustomBaseUrl(image.getRepo(), customImage.getBaseParcelUrl()), getImageSetsByProvider(image.getImageSetsByProvider(), customImage.getVmImage()), getStackDetailsWithCustomBaseUrl(image.getStackDetails(), customImage.getBaseParcelUrl()), image.getOsType(), image.getPackageVersions(), getPreWarmParcelsWithCustomBaseUrl(image.getPreWarmParcels(), customImage.getBaseParcelUrl()), getPreWarmCsdWithCustomBaseUrl(image.getPreWarmCsd(), customImage.getBaseParcelUrl()), image.getCmBuildNumber(), image.isAdvertised(), customImage.getBaseParcelUrl(), customImage.getCustomizedImageId());
    return StatedImage.statedImage(result, imageCatalogUrl, catalogName);
}
Also used : VmImage(com.sequenceiq.cloudbreak.domain.VmImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage)

Example 27 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class ImageCatalogToCustomImageCatalogV4GetResponseConverter method getImage.

private CustomImageCatalogV4ImageListItemResponse getImage(CustomImage source) {
    CustomImageCatalogV4ImageListItemResponse result = new CustomImageCatalogV4ImageListItemResponse();
    result.setImageId(source.getName());
    result.setImageType(source.getImageType() != null ? source.getImageType().name() : null);
    result.setSourceImageId(source.getCustomizedImageId());
    result.setImageDate(source.getCreated());
    try {
        Image image = imageCatalogService.getSourceImageByImageType(source).getImage();
        result.setSourceImageDate(image.getCreated());
        result.setVersions(imageVersionsConverter.convert(image));
        result.setCloudProvider(image.getImageSetsByProvider().keySet().stream().findFirst().orElse(null));
    } catch (Exception ex) {
        throw new ConversionException(ex.getMessage());
    }
    return result;
}
Also used : ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException) CustomImageCatalogV4ImageListItemResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException)

Example 28 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageCatalogV4Controller method createCustomImage.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.EDIT_IMAGE_CATALOG)
public CustomImageCatalogV4CreateImageResponse createCustomImage(@ResourceName String name, @Valid CustomImageCatalogV4CreateImageRequest request, @AccountId String accountId) {
    String creator = ThreadBasedUserCrnProvider.getUserCrn();
    CustomImage customImage = customImageCatalogV4CreateImageRequestToCustomImageConverter.convert(request);
    CustomImage savedCustomImage = customImageCatalogService.createCustomImage(restRequestThreadLocalService.getRequestedWorkspaceId(), accountId, creator, name, customImage);
    return customImageToCustomImageCatalogV4CreateImageResponseConverter.convert(savedCustomImage);
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 29 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageToCustomImageCatalogV4CreateImageResponseConverterTest method shouldConvert.

@Test
public void shouldConvert() {
    CustomImage customImage = new CustomImage();
    customImage.setName(IMAGE_ID);
    customImage.setImageType(ImageType.RUNTIME);
    customImage.setBaseParcelUrl(BASE_PARCEL_URL);
    customImage.setCustomizedImageId(SOURCE_IMAGE_ID);
    customImage.setVmImage(Collections.singleton(getVmImage(REGION, IMAGE_REFERENCE)));
    CustomImageCatalogV4CreateImageResponse result = victim.convert(customImage);
    assertEquals(IMAGE_ID, result.getImageId());
    assertEquals(SOURCE_IMAGE_ID, result.getSourceImageId());
    assertEquals(BASE_PARCEL_URL, result.getBaseParcelUrl());
    assertEquals(ImageType.RUNTIME.name(), result.getImageType());
    assertEquals(1, result.getVmImages().size());
    CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().stream().findFirst().get();
    assertEquals(REGION, vmImage.getRegion());
    assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
Also used : CustomImageCatalogV4CreateImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse) CustomImageCatalogV4VmImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Test(org.junit.jupiter.api.Test)

Example 30 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageToCustomImageCatalogV4DeleteImageResponseConverterTest method shouldConvert.

@Test
public void shouldConvert() {
    CustomImage customImage = new CustomImage();
    customImage.setName(IMAGE_ID);
    CustomImageCatalogV4DeleteImageResponse result = victim.convert(customImage);
    assertEquals(IMAGE_ID, result.getImageId());
}
Also used : CustomImageCatalogV4DeleteImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4DeleteImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Test(org.junit.jupiter.api.Test)

Aggregations

CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)47 Test (org.junit.jupiter.api.Test)26 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)18 VmImage (com.sequenceiq.cloudbreak.domain.VmImage)13 Supplier (java.util.function.Supplier)11 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 CustomImageCatalogV4GetImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse)4 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)3 CustomImageCatalogV4UpdateImageRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4UpdateImageRequest)3 CustomImageCatalogV4VmImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse)3 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)3 Test (org.junit.Test)3 CustomImageCatalogV4CreateImageRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest)2 CustomImageCatalogV4CreateImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse)2 CustomImageCatalogV4DeleteImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4DeleteImageResponse)2 CustomImageCatalogV4ImageListItemResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse)2 CustomImageCatalogV4UpdateImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4UpdateImageResponse)2 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)2 ConversionException (com.sequenceiq.cloudbreak.converter.ConversionException)2 StatedImage.statedImage (com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage)2