Search in sources :

Example 6 with ImagesV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.

the class ImagesToImagesV4ResponseConverterTest method testConvert.

@Test
public void testConvert() {
    setupStackEntries();
    ImagesV4Response result = underTest.convert(createSource());
    assertEquals(1, result.getCdhImages().size());
}
Also used : ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) Test(org.junit.Test) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)

Example 7 with ImagesV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.

the class CoreImageProviderTest method testGetImages.

@Test
public void testGetImages() throws Exception {
    ImagesV4Response imagesV4Response = new ImagesV4Response();
    imagesV4Response.setFreeipaImages(List.of(anImageResponse()));
    when(imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, CATALOG_NAME, null, PLATFORM, null, null, false)).thenReturn(imagesV4Response);
    ImageSettingsRequest imageSettings = new ImageSettingsRequest();
    imageSettings.setCatalog(CATALOG_NAME);
    List<ImageWrapper> result = victim.getImages(imageSettings, "", PLATFORM);
    assertEquals(1, result.size());
    ImageWrapper imageWrapper = result.get(0);
    assertEquals(CATALOG_NAME, imageWrapper.getCatalogName());
    assertNull(imageWrapper.getCatalogUrl());
    Image image = imageWrapper.getImage();
    assertEquals(DATE, image.getDate());
    assertEquals(DESCRIPTION, image.getDescription());
    assertEquals(UUID, image.getUuid());
    assertEquals(OS_TYPE, image.getOsType());
    assertEquals(VM_IMAGE_REFERENCE, image.getImageSetsByProvider().get(PLATFORM).get(REGION));
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Test(org.junit.jupiter.api.Test)

Example 8 with ImagesV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.

the class CoreImageProvider method getImages.

@Override
public List<ImageWrapper> getImages(ImageSettingsRequest imageSettings, String region, String platform) {
    try {
        ImagesV4Response imagesV4Response = imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), null, platform, null, null, false);
        LOGGER.debug("Images received: {}", imagesV4Response);
        return Optional.ofNullable(imagesV4Response.getFreeipaImages()).orElseGet(List::of).stream().map(this::convert).flatMap(Optional::stream).map(img -> new ImageWrapper(img, null, imageSettings.getCatalog())).collect(Collectors.toList());
    } catch (WebApplicationException e) {
        String errorMessage = messageExtractor.getErrorMessage(e);
        LOGGER.warn("Fetching images failed with: {}", errorMessage, e);
        return List.of();
    } catch (Exception e) {
        LOGGER.warn("Fetching images failed", e);
        return List.of();
    }
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Logger(org.slf4j.Logger) ImageCatalogV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint) LoggerFactory(org.slf4j.LoggerFactory) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) List(java.util.List) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) WebApplicationException(javax.ws.rs.WebApplicationException) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) Optional(java.util.Optional) WebApplicationException(javax.ws.rs.WebApplicationException) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) WebApplicationException(javax.ws.rs.WebApplicationException)

Aggregations

ImagesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response)8 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)4 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)3 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)3 Test (org.junit.jupiter.api.Test)3 ImageCatalogV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint)2 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)2 Inject (javax.inject.Inject)2 ImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.ImageCatalogV4Request)1 UpdateImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request)1 BaseImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.BaseImageV4Response)1 ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)1 ImageCatalogV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Responses)1 ImageSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 WebApplicationExceptionMessageExtractor (com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 ImageCatalogGetImagesByNameAction (com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogGetImagesByNameAction)1 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)1