Search in sources :

Example 46 with Image

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

the class ImageCatalogGeneratorService method generate.

public GenerateImageCatalogResponse generate(String environmentCrn, String accountId) {
    final Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
    MDCBuilder.buildMdcContext(stack);
    LOGGER.info("Generating image catalog for environment {} stack {}", environmentCrn, stack.getId());
    final ImageCatalog imageCatalog = imageService.generateImageCatalogForStack(stack);
    final GenerateImageCatalogResponse response = new GenerateImageCatalogResponse();
    response.setImageCatalog(imageCatalog);
    return response;
}
Also used : GenerateImageCatalogResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.imagecatalog.GenerateImageCatalogResponse) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 47 with Image

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

the class ImageCatalogProvider method getVersions.

private Versions getVersions(ImageCatalog catalog) {
    if (catalog.getVersions() == null || catalog.getVersions().getFreeIpaVersions() == null) {
        LOGGER.debug("FreeIPA versions are missing from the image catalog, generating it based on the current svc version and on advertised flags.");
        List<String> advertisedImageUuids = catalog.getImages().getFreeipaImages().stream().filter(Image::isAdvertised).map(Image::getUuid).collect(Collectors.toList());
        List<FreeIpaVersions> versionList = List.of(new FreeIpaVersions(List.of(freeIpaVersion), List.of(), advertisedImageUuids));
        Versions versions = new Versions(versionList);
        LOGGER.debug("Generated versions: '{}'", versions);
        return versions;
    } else {
        return catalog.getVersions();
    }
}
Also used : FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) Versions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)

Example 48 with Image

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

the class ImageCatalogProvider method filterImagesByOsType.

private ImageCatalog filterImagesByOsType(ImageCatalog catalog) {
    LOGGER.debug("Filtering images by OS type {}", getEnabledLinuxTypes());
    if ((CollectionUtils.isEmpty(getEnabledLinuxTypes()) || Objects.isNull(catalog.getImages())) && Objects.nonNull(catalog.getVersions())) {
        return catalog;
    }
    List<Image> catalogImages = catalog.getImages().getFreeipaImages();
    List<Image> filterImages = filterImages(catalogImages, enabledOsPredicate());
    List<FreeIpaVersions> filteredVersions = filterVersions(catalog, filterImages);
    return new ImageCatalog(new Images(filterImages), new Versions(filteredVersions));
}
Also used : FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) Versions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions) Images(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)

Example 49 with Image

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

the class ImageService method getImageForStack.

private Image getImageForStack(Stack stack) {
    final ImageEntity imageEntity = getByStack(stack);
    final ImageSettingsRequest imageSettings = imageEntityToImageSettingsRequest(imageEntity);
    final ImageWrapper imageWrapper = getImage(imageSettings, stack.getRegion(), getPlatformString(stack));
    return imageWrapper.getImage();
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper)

Example 50 with Image

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

the class StackToDescribeFreeIpaResponseConverter method convert.

public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus, Boolean includeAllInstances) {
    DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse();
    describeFreeIpaResponse.setName(stack.getName());
    describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn());
    describeFreeIpaResponse.setCrn(stack.getResourceCrn());
    describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform());
    describeFreeIpaResponse.setVariant(stack.getPlatformvariant());
    describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication()));
    Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i)));
    Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f)));
    describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack));
    describeFreeIpaResponse.setPlacement(convertToPlacementResponse(stack));
    describeFreeIpaResponse.setTunnel(stack.getTunnel());
    describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups(), includeAllInstances));
    describeFreeIpaResponse.setAvailabilityStatus(stackToAvailabilityStatusConverter.convert(stack));
    describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus());
    describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString());
    describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason());
    decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups());
    decorateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa);
    describeFreeIpaResponse.setAppVersion(stack.getAppVersion());
    decorateWithCloudStorageAndTelemetry(stack, describeFreeIpaResponse);
    Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u)));
    return describeFreeIpaResponse;
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)

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