Search in sources :

Example 1 with ImageEntity

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

the class StackToCloudStackConverter method buildInstances.

public List<CloudInstance> buildInstances(Stack stack) {
    ImageEntity imageEntity = imageService.getByStack(stack);
    Optional<CloudFileSystemView> fileSystemView = buildFileSystemView(stack);
    List<Group> groups = buildInstanceGroups(stack, Lists.newArrayList(stack.getInstanceGroups()), Collections.emptySet(), imageEntity.getImageName(), fileSystemView);
    List<CloudInstance> cloudInstances = new ArrayList<>();
    for (Group group : groups) {
        cloudInstances.addAll(group.getInstances());
    }
    return cloudInstances;
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) ArrayList(java.util.ArrayList) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance)

Example 2 with ImageEntity

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

the class ImageToImageEntityConverter method convert.

public ImageEntity convert(Image source) {
    ImageEntity imageEntity = new ImageEntity();
    imageEntity.setImageId(source.getUuid());
    imageEntity.setOs(source.getOs());
    imageEntity.setOsType(source.getOsType());
    return imageEntity;
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity)

Example 3 with ImageEntity

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

the class FreeIpaDescribeServiceTest method describeAll.

@Test
void describeAll() {
    DescribeFreeIpaResponse describeResponse = mock(DescribeFreeIpaResponse.class);
    ImageEntity image = mock(ImageEntity.class);
    FreeIpa freeIpa = mock(FreeIpa.class);
    UserSyncStatus userSyncStatus = mock(UserSyncStatus.class);
    when(stackService.findMultipleByEnvironmentCrnAndAccountIdEvenIfTerminatedWithList(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID))).thenReturn(Collections.singletonList(stack));
    when(imageService.getByStack(any())).thenReturn(image);
    when(freeIpaService.findByStackId(any())).thenReturn(freeIpa);
    when(userSyncStatusService.findByStack(any())).thenReturn(Optional.of(userSyncStatus));
    when(stackToDescribeFreeIpaResponseConverter.convert(any(), any(), any(), any(), any())).thenReturn(describeResponse);
    when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
    assertEquals(List.of(describeResponse), underTest.describeAll(ENVIRONMENT_CRN, ACCOUNT_ID));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Test(org.junit.jupiter.api.Test)

Example 4 with ImageEntity

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

the class ImageServiceTest method testRevert.

@Test
public void testRevert() {
    ImageEntity originalImage = new ImageEntity();
    originalImage.setImageName(EXISTING_ID);
    originalImage.setImageId(IMAGE_UUID);
    originalImage.setImageCatalogName(IMAGE_CATALOG);
    originalImage.setImageCatalogUrl(IMAGE_CATALOG_URL);
    when(auditReader.find(ImageEntity.class, 2L, 3L)).thenReturn(originalImage);
    ImageEntity currentImage = new ImageEntity();
    currentImage.setId(2L);
    when(imageRepository.findById(2L)).thenReturn(Optional.of(currentImage));
    underTest.revertImageToRevision(2L, 3L);
    ArgumentCaptor<ImageEntity> captor = ArgumentCaptor.forClass(ImageEntity.class);
    verify(imageRepository).save(captor.capture());
    ImageEntity revertedImage = captor.getValue();
    assertEquals(2L, revertedImage.getId());
    assertEquals(IMAGE_UUID, revertedImage.getImageId());
    assertEquals(IMAGE_CATALOG, revertedImage.getImageCatalogName());
    assertEquals(IMAGE_CATALOG_URL, revertedImage.getImageCatalogUrl());
    assertEquals(EXISTING_ID, revertedImage.getImageName());
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Test(org.junit.jupiter.api.Test)

Example 5 with ImageEntity

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

the class UserDataServiceTest method updateJumpgateFlagOnly.

@Test
void updateJumpgateFlagOnly() {
    ImageEntity image = new ImageEntity();
    image.setUserdata("FLAG=foo\nIS_CCM_V2_JUMPGATE_ENABLED=false\nOTHER_FLAG=bar");
    when(imageService.getByStackId(STACK_ID)).thenReturn(image);
    underTest.updateJumpgateFlagOnly(STACK_ID);
    ArgumentCaptor<ImageEntity> imageCaptor = ArgumentCaptor.forClass(ImageEntity.class);
    verify(imageService, times(1)).save(imageCaptor.capture());
    assertThat(imageCaptor.getValue().getUserdata()).isEqualTo("FLAG=foo\nIS_CCM_V2_JUMPGATE_ENABLED=true\nOTHER_FLAG=bar");
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Test(org.junit.jupiter.api.Test)

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