use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response in project cloudbreak by hortonworks.
the class CoreImageProviderTest method anImageResponse.
private ImageV4Response anImageResponse() {
ImageV4Response response = new ImageV4Response();
response.setDate(DATE);
response.setDescription(DESCRIPTION);
response.setUuid(UUID);
response.setOsType(OS_TYPE);
response.setImageSetsByProvider(VM_IMAGES);
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response in project cloudbreak by hortonworks.
the class CoreImageProvider method getImage.
@Override
public Optional<ImageWrapper> getImage(ImageSettingsRequest imageSettings, String region, String platform) {
try {
ImageV4Response imageV4Response = imageCatalogV4Endpoint.getSingleImageByCatalogNameAndImageId(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), imageSettings.getId());
Optional<Image> image = convert(imageV4Response);
return image.map(i -> new ImageWrapper(i, defaultCatalogUrl, imageSettings.getCatalog()));
} catch (Exception ex) {
LOGGER.warn("Image lookup failed: {}", ex.getMessage());
return Optional.empty();
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response in project cloudbreak by hortonworks.
the class AwsCloudProvider method getPreviousPreWarmedImageID.
@Override
public String getPreviousPreWarmedImageID(TestContext testContext, ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient) {
if (awsProperties.getBaseimage().getImageId() == null || awsProperties.getBaseimage().getImageId().isEmpty()) {
try {
List<ImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, CloudPlatform.AWS.name(), null, null, false).getCdhImages();
ImageV4Response olderImage = images.get(images.size() - 2);
Log.log(LOGGER, format(" Image Catalog Name: %s ", imageCatalogTestDto.getRequest().getName()));
Log.log(LOGGER, format(" Image Catalog URL: %s ", imageCatalogTestDto.getRequest().getUrl()));
Log.log(LOGGER, format(" Selected Pre-warmed Image Date: %s | ID: %s | Description: %s | Stack Version: %s ", olderImage.getDate(), olderImage.getUuid(), olderImage.getStackDetails().getVersion(), olderImage.getDescription()));
awsProperties.getBaseimage().setImageId(olderImage.getUuid());
return olderImage.getUuid();
} catch (Exception e) {
LOGGER.error("Cannot fetch pre-warmed images of {} image catalog!", imageCatalogTestDto.getRequest().getName());
throw new TestFailException(" Cannot fetch pre-warmed images of " + imageCatalogTestDto.getRequest().getName() + " image catalog!", e);
}
} else {
Log.log(LOGGER, format(" Image Catalog Name: %s ", commonCloudProperties().getImageCatalogName()));
Log.log(LOGGER, format(" Image Catalog URL: %s ", commonCloudProperties().getImageCatalogUrl()));
Log.log(LOGGER, format(" Image ID for SDX create: %s ", awsProperties.getBaseimage().getImageId()));
return awsProperties.getBaseimage().getImageId();
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method getImageResponse.
private ImageV4Response getImageResponse() {
Map<String, Map<String, String>> imageSetsByProvider = new HashMap<>();
imageSetsByProvider.put("aws", null);
BaseStackDetailsV4Response stackDetails = new BaseStackDetailsV4Response();
stackDetails.setVersion("7.2.7");
ImageV4Response imageV4Response = new ImageV4Response();
imageV4Response.setImageSetsByProvider(imageSetsByProvider);
imageV4Response.setStackDetails(stackDetails);
return imageV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response in project cloudbreak by hortonworks.
the class ImageCatalogService method getImageResponseFromImageRequest.
public ImageV4Response getImageResponseFromImageRequest(ImageSettingsV4Request imageSettingsV4Request, CloudPlatform cloudPlatform) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
if (imageSettingsV4Request == null) {
return null;
}
ImageCatalogV4Endpoint imageCatalogV4Endpoint = cloudbreakInternalCrnClient.withInternalCrn().imageCatalogV4Endpoint();
try {
LOGGER.info("Calling cloudbreak to get image response for the given image catalog {} and image id {}", imageSettingsV4Request.getCatalog(), imageSettingsV4Request.getId());
ImagesV4Response imagesV4Response = null;
try {
if (StringUtils.isBlank(imageSettingsV4Request.getCatalog())) {
imagesV4Response = imageCatalogV4Endpoint.getImageByImageId(SdxService.WORKSPACE_ID_DEFAULT, imageSettingsV4Request.getId(), accountId);
} else {
imagesV4Response = imageCatalogV4Endpoint.getImageByCatalogNameAndImageId(SdxService.WORKSPACE_ID_DEFAULT, imageSettingsV4Request.getCatalog(), imageSettingsV4Request.getId(), accountId);
}
} catch (Exception e) {
LOGGER.error("Sdx service fails to get image using image id", e);
}
if (imagesV4Response == null) {
return null;
}
for (ImageV4Response imageV4Response : imagesV4Response.getCdhImages()) {
// find the image can be used on the cloud platform of the environment
if (imageV4Response.getImageSetsByProvider() != null) {
if (imageV4Response.getImageSetsByProvider().containsKey(cloudPlatform.name().toLowerCase())) {
return imageV4Response;
}
}
}
String errorMessage = String.format("SDX cluster is on the cloud platform %s, but the image requested with uuid %s:%s does not support it", cloudPlatform.name(), imageSettingsV4Request.getCatalog() != null ? imageSettingsV4Request.getCatalog() : "default", imageSettingsV4Request.getId());
LOGGER.error(errorMessage);
return null;
} catch (javax.ws.rs.NotFoundException e) {
LOGGER.info("Sdx cluster not found on CB side", e);
return null;
}
}
Aggregations