Search in sources :

Example 11 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class FreeIpaImageProviderTest method testGetImagesGivenAllInputNonExistentOS.

@Test
public void testGetImagesGivenAllInputNonExistentOS() {
    ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, CUSTOM_IMAGE_CATALOG_URL, NON_EXISTING_OS);
    List<ImageWrapper> images = underTest.getImages(is, DEFAULT_REGION, DEFAULT_PLATFORM);
    assertEquals(1, images.size());
    ImageWrapper imageWrapper = images.get(0);
    assertEquals(CUSTOM_IMAGE_CATALOG_URL, imageWrapper.getCatalogUrl());
    assertNull(imageWrapper.getCatalogName());
    Image image = imageWrapper.getImage();
    assertEquals(DEFAULT_OS, image.getOs());
    assertEquals(LATEST_DATE, image.getDate());
    assertEquals(IMAGE_UUID, image.getUuid());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Test(org.junit.jupiter.api.Test)

Example 12 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class FreeIpaCreationHandler method setImage.

private void setImage(EnvironmentDto environment, CreateFreeIpaRequest createFreeIpaRequest) {
    if (environment.getFreeIpaCreation() != null) {
        String imageCatalog = environment.getFreeIpaCreation().getImageCatalog();
        String imageId = environment.getFreeIpaCreation().getImageId();
        if (!Strings.isNullOrEmpty(imageId)) {
            LOGGER.info("FreeIPA creation with a pre-defined image catalog and image id: '{}', '{}'", imageCatalog, imageId);
            ImageSettingsRequest imageSettings = new ImageSettingsRequest();
            imageSettings.setCatalog(imageCatalog);
            imageSettings.setId(imageId);
            createFreeIpaRequest.setImage(imageSettings);
        } else {
            LOGGER.info("FreeIPA creation without pre-defined image settings. FreeIpa serivce is going to handle default settings.");
        }
    }
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)

Example 13 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class CoreImageProvider method getImage.

@Override
public Optional<ImageWrapper> getImage(ImageSettingsRequest imageSettings, String region, String platform) {
    try {
        ImageV4Response imageV4Response = imageCatalogV4Endpoint.getSingleImageByCatalogNameAndImageId(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), imageSettings.getId());
        Optional<Image> image = convert(imageV4Response);
        return image.map(i -> new ImageWrapper(i, defaultCatalogUrl, imageSettings.getCatalog()));
    } catch (Exception ex) {
        LOGGER.warn("Image lookup failed: {}", ex.getMessage());
        return Optional.empty();
    }
}
Also used : ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 14 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class FreeIpaImageProvider method retryAfterEvictingCache.

private Optional<Image> retryAfterEvictingCache(String region, String platform, String imageId, String catalogUrl, String imageOs) {
    LOGGER.debug("Image not found with the parameters: imageId: {}, imageOs: {}, region: {}, platform: {}", imageId, imageOs, region, platform);
    LOGGER.debug("Evicting image catalog cache to retry.");
    imageCatalogProvider.evictImageCatalogCache(catalogUrl);
    ImageCatalog renewedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl);
    return findImageForAppVersion(region, platform, imageId, imageOs, renewedImageCatalog);
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)

Example 15 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class ImageCatalogChangeService method changeImageCatalog.

public void changeImageCatalog(String environmentCrn, String accountId, String imageCatalog) {
    try {
        final Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
        MDCBuilder.buildMdcContext(stack);
        if (flowLogService.isOtherFlowRunning(stack.getId())) {
            throw new CloudbreakServiceException(String.format("Operation is running for stack '%s'. Please try again later.", stack.getName()));
        }
        final ImageSettingsRequest imageRequest = getImageSettingsRequestForNewCatalogWithCurrentImageSettings(imageCatalog, stack.getImage());
        imageService.changeImage(stack, imageRequest);
    } catch (ImageNotFoundException e) {
        LOGGER.info("Could not find current image in new catalog", e);
        throw new CloudbreakServiceException("Could not find current image in new catalog", e);
    }
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)32 Test (org.junit.jupiter.api.Test)28 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)27 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)21 Stack (com.sequenceiq.freeipa.entity.Stack)16 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 ImageInfoResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse)9 ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)7 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)4 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 FreeIpaVersions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions)3 List (java.util.List)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 Backup (com.sequenceiq.freeipa.api.model.Backup)2 Versions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions)2 UsedImagesListV1Response (com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response)2 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)2 ImageNotFoundException (com.sequenceiq.freeipa.service.image.ImageNotFoundException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1