Search in sources :

Example 31 with ImageEntity

use of com.sequenceiq.freeipa.entity.ImageEntity in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testCurrentImage.

@Test
public void testCurrentImage() {
    Stack stack = new Stack();
    stack.setId(1L);
    ImageEntity imageEntity = new ImageEntity();
    imageEntity.setImageId("1234-435");
    imageEntity.setImageName("imageName");
    imageEntity.setImageCatalogUrl("catalogUrl");
    imageEntity.setImageCatalogName("catName");
    imageEntity.setOs("linux");
    when(imageService.getByStackId(1L)).thenReturn(imageEntity);
    ImageInfoResponse imageInfoResponse = underTest.fetchCurrentImage(stack);
    assertEquals(imageEntity.getImageCatalogName(), imageInfoResponse.getCatalogName());
    assertEquals(imageEntity.getImageCatalogUrl(), imageInfoResponse.getCatalog());
    assertNull(imageInfoResponse.getDate());
    assertEquals(imageEntity.getImageId(), imageInfoResponse.getId());
    assertEquals(imageEntity.getOs(), imageInfoResponse.getOs());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 32 with ImageEntity

use of com.sequenceiq.freeipa.entity.ImageEntity in project cloudbreak by hortonworks.

the class StackToStackDetailsConverter method convertImage.

private void convertImage(StackDetails stackDetails, Stack stack) {
    Long stackId = stack.getId();
    try {
        ImageEntity image = imageService.getByStackId(stackId);
        stackDetails.setImage(imageEntityToImageDetailsConverter.convert(image));
    } catch (Exception e) {
        LOGGER.warn("Image not found! {}", e.getMessage());
    }
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity)

Example 33 with ImageEntity

use of com.sequenceiq.freeipa.entity.ImageEntity in project cloudbreak by hortonworks.

the class FreeIpaCreationService method launchFreeIpa.

public DescribeFreeIpaResponse launchFreeIpa(CreateFreeIpaRequest request, String accountId) {
    String userCrn = crnService.getUserCrn();
    Future<String> ownerFuture = initiateOwnerFetching(userCrn);
    Credential credential = credentialService.getCredentialByEnvCrn(request.getEnvironmentCrn());
    DetailedEnvironmentResponse environment = measure(() -> cachedEnvironmentClientService.getByCrn(request.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
    Stack stack = stackConverter.convert(request, environment, accountId, ownerFuture, userCrn, credential.getCloudPlatform());
    stack.setAppVersion(appVersion);
    GetPlatformTemplateRequest getPlatformTemplateRequest = templateService.triggerGetTemplate(stack, credential);
    Telemetry telemetry = stack.getTelemetry();
    if (telemetry != null) {
        telemetry.setRules(accountTelemetryService.getAnonymizationRules(accountId));
    }
    cloudStorageFolderResolverService.updateStorageLocation(telemetry, FluentClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setTelemetry(telemetry);
    Backup backup = stack.getBackup();
    backup = cloudBackupFolderResolverService.updateStorageLocation(backup, BackupClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setBackup(backup);
    fillInstanceMetadata(stack, environment);
    String template = templateService.waitGetTemplate(getPlatformTemplateRequest);
    stack.setTemplate(template);
    SecurityConfig securityConfig = tlsSecurityService.generateSecurityKeys(accountId);
    multiAzValidator.validateMultiAzForStack(stack.getPlatformvariant(), stack.getInstanceGroups());
    freeIpaRecommendationService.validateCustomInstanceType(stack, credential);
    try {
        Triple<Stack, ImageEntity, FreeIpa> stackImageFreeIpaTuple = transactionService.required(() -> {
            SecurityConfig savedSecurityConfig = securityConfigService.save(securityConfig);
            stack.setSecurityConfig(savedSecurityConfig);
            Stack savedStack = stackService.save(stack);
            ImageSettingsRequest imageSettingsRequest = request.getImage();
            ImageEntity image = imageService.create(savedStack, Objects.nonNull(imageSettingsRequest) ? imageSettingsRequest : new ImageSettingsRequest());
            FreeIpa freeIpa = freeIpaService.create(savedStack, request.getFreeIpa());
            return Triple.of(savedStack, image, freeIpa);
        });
        flowManager.notify(FlowChainTriggers.PROVISION_TRIGGER_EVENT, new StackEvent(FlowChainTriggers.PROVISION_TRIGGER_EVENT, stackImageFreeIpaTuple.getLeft().getId()));
        InMemoryStateStore.putStack(stack.getId(), PollGroup.POLLABLE);
        return stackToDescribeFreeIpaResponseConverter.convert(stackImageFreeIpaTuple.getLeft(), stackImageFreeIpaTuple.getMiddle(), stackImageFreeIpaTuple.getRight(), Optional.empty(), false);
    } catch (TransactionService.TransactionExecutionException e) {
        LOGGER.error("Creation of FreeIPA failed", e);
        throw new BadRequestException("Creation of FreeIPA failed: " + e.getCause().getMessage(), e);
    }
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Backup(com.sequenceiq.freeipa.api.model.Backup) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.freeipa.entity.Stack) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) GetPlatformTemplateRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest)

Example 34 with ImageEntity

use of com.sequenceiq.freeipa.entity.ImageEntity in project cloudbreak by hortonworks.

the class UpgradeImageService method fetchCurrentImage.

public ImageInfoResponse fetchCurrentImage(Stack stack) {
    ImageEntity imageEntity = imageService.getByStackId(stack.getId());
    ImageInfoResponse imageInfoResponse = new ImageInfoResponse();
    imageInfoResponse.setImageName(imageEntity.getImageName());
    imageInfoResponse.setCatalog(imageEntity.getImageCatalogUrl());
    imageInfoResponse.setCatalogName(imageEntity.getImageCatalogName());
    imageInfoResponse.setOs(imageEntity.getOs());
    imageInfoResponse.setId(imageEntity.getImageId());
    imageInfoResponse.setDate(imageEntity.getDate());
    LOGGER.info("Current image: {}", imageInfoResponse);
    return imageInfoResponse;
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity)

Example 35 with ImageEntity

use of com.sequenceiq.freeipa.entity.ImageEntity in project cloudbreak by hortonworks.

the class ImageService method createImageEntity.

private ImageEntity createImageEntity(Stack stack, Pair<ImageWrapper, String> imageWrapperAndNamePair) {
    ImageWrapper imageWrapper = imageWrapperAndNamePair.getLeft();
    ImageEntity imageEntity = imageConverter.convert(imageWrapper.getImage());
    imageEntity.setStack(stack);
    imageEntity.setImageName(imageWrapperAndNamePair.getRight());
    imageEntity.setImageCatalogUrl(imageWrapper.getCatalogUrl());
    imageEntity.setImageCatalogName(imageWrapper.getCatalogName());
    imageEntity.setDate(imageWrapper.getImage().getDate());
    return imageEntity;
}
Also used : ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity)

Aggregations

ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)39 Stack (com.sequenceiq.freeipa.entity.Stack)17 Test (org.junit.jupiter.api.Test)14 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)10 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)7 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)5 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)5 ImageChangeEvent (com.sequenceiq.freeipa.flow.stack.image.change.event.ImageChangeEvent)4 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)3 BootstrapParams (com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams)3 FlowParameters (com.sequenceiq.flow.core.FlowParameters)3 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)3 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)3 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)3 StackBasedExitCriteriaModel (com.sequenceiq.freeipa.orchestrator.StackBasedExitCriteriaModel)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 Authenticator (com.sequenceiq.cloudbreak.cloud.Authenticator)2 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)2 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2