use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageProvider method mergeSourceImageAndCustomImageProperties.
public StatedImage mergeSourceImageAndCustomImageProperties(StatedImage statedImage, CustomImage customImage, String imageCatalogUrl, String catalogName) {
Image image = statedImage.getImage();
Image result = new Image(image.getDate(), customImage.getCreated(), customImage.getCreated(), customImage.getDescription(), image.getOs(), customImage.getName(), image.getVersion(), getRepoWithCustomBaseUrl(image.getRepo(), customImage.getBaseParcelUrl()), getImageSetsByProvider(image.getImageSetsByProvider(), customImage.getVmImage()), getStackDetailsWithCustomBaseUrl(image.getStackDetails(), customImage.getBaseParcelUrl()), image.getOsType(), image.getPackageVersions(), getPreWarmParcelsWithCustomBaseUrl(image.getPreWarmParcels(), customImage.getBaseParcelUrl()), getPreWarmCsdWithCustomBaseUrl(image.getPreWarmCsd(), customImage.getBaseParcelUrl()), image.getCmBuildNumber(), image.isAdvertised(), customImage.getBaseParcelUrl(), customImage.getCustomizedImageId());
return StatedImage.statedImage(result, imageCatalogUrl, catalogName);
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogToCustomImageCatalogV4GetResponseConverter method getImage.
private CustomImageCatalogV4ImageListItemResponse getImage(CustomImage source) {
CustomImageCatalogV4ImageListItemResponse result = new CustomImageCatalogV4ImageListItemResponse();
result.setImageId(source.getName());
result.setImageType(source.getImageType() != null ? source.getImageType().name() : null);
result.setSourceImageId(source.getCustomizedImageId());
result.setImageDate(source.getCreated());
try {
Image image = imageCatalogService.getSourceImageByImageType(source).getImage();
result.setSourceImageDate(image.getCreated());
result.setVersions(imageVersionsConverter.convert(image));
result.setCloudProvider(image.getImageSetsByProvider().keySet().stream().findFirst().orElse(null));
} catch (Exception ex) {
throw new ConversionException(ex.getMessage());
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogV4Controller method createCustomImage.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.EDIT_IMAGE_CATALOG)
public CustomImageCatalogV4CreateImageResponse createCustomImage(@ResourceName String name, @Valid CustomImageCatalogV4CreateImageRequest request, @AccountId String accountId) {
String creator = ThreadBasedUserCrnProvider.getUserCrn();
CustomImage customImage = customImageCatalogV4CreateImageRequestToCustomImageConverter.convert(request);
CustomImage savedCustomImage = customImageCatalogService.createCustomImage(restRequestThreadLocalService.getRequestedWorkspaceId(), accountId, creator, name, customImage);
return customImageToCustomImageCatalogV4CreateImageResponseConverter.convert(savedCustomImage);
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4CreateImageResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() {
CustomImage customImage = new CustomImage();
customImage.setName(IMAGE_ID);
customImage.setImageType(ImageType.RUNTIME);
customImage.setBaseParcelUrl(BASE_PARCEL_URL);
customImage.setCustomizedImageId(SOURCE_IMAGE_ID);
customImage.setVmImage(Collections.singleton(getVmImage(REGION, IMAGE_REFERENCE)));
CustomImageCatalogV4CreateImageResponse result = victim.convert(customImage);
assertEquals(IMAGE_ID, result.getImageId());
assertEquals(SOURCE_IMAGE_ID, result.getSourceImageId());
assertEquals(BASE_PARCEL_URL, result.getBaseParcelUrl());
assertEquals(ImageType.RUNTIME.name(), result.getImageType());
assertEquals(1, result.getVmImages().size());
CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().stream().findFirst().get();
assertEquals(REGION, vmImage.getRegion());
assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4DeleteImageResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() {
CustomImage customImage = new CustomImage();
customImage.setName(IMAGE_ID);
CustomImageCatalogV4DeleteImageResponse result = victim.convert(customImage);
assertEquals(IMAGE_ID, result.getImageId());
}
Aggregations