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, Optional<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);
userSyncStatus.ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u)));
return describeFreeIpaResponse;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UsedImagesTest method verifyImagesAreUsed.
private <T extends CloudbreakTestDto> T verifyImagesAreUsed(TestContext testContext, T testDto) {
testContext.given(UsedImagesTestDto.class).when(utilTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
List<UsedImageStacksV4Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
UsedImageStacksV4Response usedImageStacksV4Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(sdxImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("SDX image is NOT in use with ID:: %s", sdxImageUuid)));
LOGGER.info("Used SDX image ID:: {}", usedImageStacksV4Response.getImage().getImageId());
return usedImagesTestDto;
}).given(FreeipaUsedImagesTestDto.class).when(freeIpaTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
List<UsedImageStacksV1Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
UsedImageStacksV1Response usedImageStacksV1Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(freeipaImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("FreeIpa image is NOT in use with ID:: %s", freeipaImageUuid)));
LOGGER.info("Used FreeIpa image ID:: {}", usedImageStacksV1Response.getImage().getImageId());
return usedImagesTestDto;
}).validate();
return testDto;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image 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));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesNoNewerImage.
@Test
public void testFindTargetImagesNoNewerImage() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-07-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesImageWithSameId.
@Test
public void testFindTargetImagesImageWithSameId() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("1234-456");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
}
Aggregations