Search in sources :

Example 11 with ImageCatalogV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint in project cloudbreak by hortonworks.

the class AzureCloudProvider method getPreviousPreWarmedImageID.

@Override
public String getPreviousPreWarmedImageID(TestContext testContext, ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient) {
    if (azureProperties.getBaseimage().getImageId() == null || azureProperties.getBaseimage().getImageId().isEmpty()) {
        try {
            List<ImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, CloudPlatform.AZURE.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()));
            azureProperties.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 ", azureProperties.getBaseimage().getImageId()));
        return azureProperties.getBaseimage().getImageId();
    }
}
Also used : ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 12 with ImageCatalogV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint in project cloudbreak by hortonworks.

the class GcpCloudProvider method getPreviousPreWarmedImageID.

@Override
public String getPreviousPreWarmedImageID(TestContext testContext, ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient) {
    if (gcpProperties.getBaseimage().getImageId() == null || gcpProperties.getBaseimage().getImageId().isEmpty()) {
        try {
            List<ImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, CloudPlatform.GCP.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()));
            gcpProperties.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 ", gcpProperties.getBaseimage().getImageId()));
        return gcpProperties.getBaseimage().getImageId();
    }
}
Also used : ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 13 with ImageCatalogV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint in project cloudbreak by hortonworks.

the class MockCloudProvider method getPreviousPreWarmedImageID.

@Override
public String getPreviousPreWarmedImageID(TestContext testContext, ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient) {
    if (mockProperties.getBaseimage().getRedhat7().getImageId() == null || mockProperties.getBaseimage().getRedhat7().getImageId().isEmpty()) {
        try {
            List<ImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, CloudPlatform.MOCK.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()));
            mockProperties.getBaseimage().getRedhat7().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 ", mockProperties.getBaseimage().getRedhat7().getImageId()));
        return mockProperties.getBaseimage().getRedhat7().getImageId();
    }
}
Also used : ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)6 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)6 ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)4 ImagesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response)4 ImageCatalogV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint)3 NotImplementedException (org.apache.commons.lang3.NotImplementedException)3 ImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.ImageCatalogV4Request)2 UpdateImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request)2 BaseImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.BaseImageV4Response)2 ImageCatalogV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Responses)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2 ImageCatalogGetImagesByNameAction (com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogGetImagesByNameAction)2 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)2 ImageCatalogTestClient (com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient)2 StackTestClient (com.sequenceiq.it.cloudbreak.client.StackTestClient)2 Description (com.sequenceiq.it.cloudbreak.context.Description)2 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)2 RunningParameter.expectedMessage (com.sequenceiq.it.cloudbreak.context.RunningParameter.expectedMessage)2 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)2 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)2