Search in sources :

Example 6 with CloudbreakImageNotFoundException

use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.

the class StackToStackV2RequestConverter method prepareImage.

private void prepareImage(Stack source, StackV2Request stackV2Request) {
    try {
        Image image = componentConfigProvider.getImage(source.getId());
        ImageSettings is = new ImageSettings();
        is.setImageId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
        is.setImageCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
        stackV2Request.setImageSettings(is);
    } catch (CloudbreakImageNotFoundException e) {
        LOGGER.error(e.toString());
    }
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ImageSettings(com.sequenceiq.cloudbreak.api.model.v2.ImageSettings)

Example 7 with CloudbreakImageNotFoundException

use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method convert.

public CloudStack convert(Stack stack, Collection<String> deleteRequestedInstances) {
    Image image = null;
    List<Group> instanceGroups = buildInstanceGroups(stack.getInstanceGroupsAsList(), stack.getStackAuthentication(), deleteRequestedInstances);
    try {
        image = imageService.getImage(stack.getId());
    } catch (CloudbreakImageNotFoundException e) {
        LOGGER.info(e.getMessage());
    }
    Network network = buildNetwork(stack);
    StackTemplate stackTemplate = componentConfigProvider.getStackTemplate(stack.getId());
    InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stack.getStackAuthentication());
    String template = null;
    if (stackTemplate != null) {
        template = stackTemplate.getTemplate();
    }
    return new CloudStack(instanceGroups, network, image, stack.getParameters(), getUserDefinedTags(stack), template, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack)

Example 8 with CloudbreakImageNotFoundException

use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.

the class ImageCatalogService method getImage.

public StatedImage getImage(String catalogUrl, String catalogName, String imageId) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    Images images = imageCatalogProvider.getImageCatalogV2(catalogUrl).getImages();
    Optional<? extends Image> image = getImage(imageId, images);
    if (!image.isPresent()) {
        images = imageCatalogProvider.getImageCatalogV2(catalogUrl, true).getImages();
        image = getImage(imageId, images);
    }
    if (!image.isPresent()) {
        throw new CloudbreakImageNotFoundException(String.format("Could not find any image with id: '%s'.", imageId));
    }
    return statedImage(image.get(), catalogUrl, catalogName);
}
Also used : Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StatedImages.statedImages(com.sequenceiq.cloudbreak.service.image.StatedImages.statedImages) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)

Example 9 with CloudbreakImageNotFoundException

use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.

the class ImageCatalogService method getImageByCatalogName.

public StatedImage getImageByCatalogName(String imageId, String catalogName) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    StatedImage image;
    if (StringUtils.isEmpty(catalogName)) {
        image = getImage(imageId);
    } else {
        ImageCatalog imageCatalog = get(catalogName);
        if (imageCatalog != null) {
            image = getImage(imageCatalog.getImageCatalogUrl(), imageCatalog.getImageCatalogName(), imageId);
        } else {
            String msg = String.format("The specified image catalog '%s' could not be found.", catalogName);
            LOGGER.error(msg);
            throw new CloudbreakImageNotFoundException(msg);
        }
    }
    return image;
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 10 with CloudbreakImageNotFoundException

use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.

the class StackToStackResponseConverter method convert.

@Override
public StackResponse convert(Stack source) {
    StackResponse stackJson = new StackResponse();
    try {
        Image image = imageService.getImage(source.getId());
        stackJson.setImage(getConversionService().convert(image, ImageJson.class));
    } catch (CloudbreakImageNotFoundException exc) {
        LOGGER.info(exc.getMessage());
    }
    stackJson.setName(source.getName());
    stackJson.setOwner(source.getOwner());
    stackJson.setAccount(source.getAccount());
    stackJson.setPublicInAccount(source.isPublicInAccount());
    stackJson.setStackAuthentication(conversionService.convert(source.getStackAuthentication(), StackAuthenticationResponse.class));
    stackJson.setId(source.getId());
    if (source.getCredential() == null) {
        stackJson.setCloudPlatform(null);
        stackJson.setCredentialId(null);
    } else {
        stackJson.setCloudPlatform(source.cloudPlatform());
        stackJson.setCredentialId(source.getCredential().getId());
        stackJson.setCredential(getConversionService().convert(source.getCredential(), CredentialResponse.class));
    }
    stackJson.setStatus(source.getStatus());
    stackJson.setStatusReason(source.getStatusReason());
    stackJson.setRegion(source.getRegion());
    stackJson.setAvailabilityZone(source.getAvailabilityZone());
    stackJson.setOnFailureAction(source.getOnFailureActionAction());
    List<InstanceGroupResponse> templateGroups = new ArrayList<>(convertInstanceGroups(source.getInstanceGroups()));
    stackJson.setInstanceGroups(templateGroups);
    if (source.getCluster() != null) {
        stackJson.setCluster(getConversionService().convert(source.getCluster(), ClusterResponse.class));
    } else {
        stackJson.setCluster(new ClusterResponse());
    }
    if (source.getFailurePolicy() != null) {
        stackJson.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicyResponse.class));
    }
    if (source.getNetwork() == null) {
        stackJson.setNetworkId(null);
    } else {
        stackJson.setNetworkId(source.getNetwork().getId());
        stackJson.setNetwork(getConversionService().convert(source.getNetwork(), NetworkResponse.class));
    }
    stackJson.setParameters(Maps.newHashMap(source.getParameters()));
    stackJson.setPlatformVariant(source.getPlatformVariant());
    if (source.getOrchestrator() != null) {
        stackJson.setOrchestrator(getConversionService().convert(source.getOrchestrator(), OrchestratorResponse.class));
    }
    stackJson.setCreated(source.getCreated());
    stackJson.setGatewayPort(source.getGatewayPort());
    stackJson.setCustomDomain(source.getCustomDomain());
    stackJson.setCustomHostname(source.getCustomHostname());
    stackJson.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
    stackJson.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
    addNodeCount(source, stackJson);
    putSubnetIdIntoResponse(source, stackJson);
    putVpcIdIntoResponse(source, stackJson);
    putS3RoleIntoResponse(source, stackJson);
    convertComponentConfig(stackJson, source);
    convertTags(stackJson, source.getTags());
    addFlexSubscription(stackJson, source);
    return stackJson;
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ArrayList(java.util.ArrayList) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) Image(com.sequenceiq.cloudbreak.cloud.model.Image) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) FailurePolicyResponse(com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) NetworkResponse(com.sequenceiq.cloudbreak.api.model.NetworkResponse) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse)

Aggregations

CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)11 Image (com.sequenceiq.cloudbreak.cloud.model.Image)7 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)2 ClusterResponse (com.sequenceiq.cloudbreak.api.model.ClusterResponse)1 CredentialResponse (com.sequenceiq.cloudbreak.api.model.CredentialResponse)1 FailurePolicyResponse (com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse)1 ImageJson (com.sequenceiq.cloudbreak.api.model.ImageJson)1 InstanceGroupResponse (com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse)1 NetworkResponse (com.sequenceiq.cloudbreak.api.model.NetworkResponse)1 OrchestratorResponse (com.sequenceiq.cloudbreak.api.model.OrchestratorResponse)1 StackAuthenticationResponse (com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 ImageSettings (com.sequenceiq.cloudbreak.api.model.v2.ImageSettings)1 CheckImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)1 CheckImageResult (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult)1 PrepareImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest)1 SetupResult (com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult)1 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)1