Search in sources :

Example 6 with Component

use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.

the class StackService method addTemplateForStack.

private void addTemplateForStack(Stack stack, String template) {
    StackTemplate stackTemplate = new StackTemplate(template, cbVersion);
    try {
        Component stackTemplateComponent = new Component(ComponentType.STACK_TEMPLATE, ComponentType.STACK_TEMPLATE.name(), new Json(stackTemplate), stack);
        componentConfigProvider.store(stackTemplateComponent);
    } catch (JsonProcessingException e) {
        LOGGER.error("Could not create Cloudbreak details component.", e);
    }
}
Also used : StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) Json(com.sequenceiq.cloudbreak.domain.json.Json) Component(com.sequenceiq.cloudbreak.domain.Component) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 7 with Component

use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.

the class ImageService method getComponents.

private List<Component> getComponents(Stack stack, Map<InstanceGroupType, String> userData, com.sequenceiq.cloudbreak.cloud.model.catalog.Image imgFromCatalog, String imageName, String imageCatalogUrl, String imageCatalogName, String imageId) throws JsonProcessingException, CloudbreakImageCatalogException {
    List<Component> components = new ArrayList<>();
    Image image = new Image(imageName, userData, imgFromCatalog.getOsType(), imageCatalogUrl, imageCatalogName, imageId);
    Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    components.add(imageComponent);
    if (imgFromCatalog.getStackDetails() != null) {
        components.add(getAmbariComponent(stack, imgFromCatalog));
        StackDetails stackDetails = imgFromCatalog.getStackDetails();
        Component stackRepoComponent;
        if (!imgFromCatalog.getStackDetails().getRepo().getKnox().isEmpty()) {
            StackRepoDetails hdfRepo = createHDFRepo(stackDetails);
            stackRepoComponent = new Component(ComponentType.HDF_REPO_DETAILS, ComponentType.HDF_REPO_DETAILS.name(), new Json(hdfRepo), stack);
        } else {
            StackRepoDetails repo = createHDPRepo(stackDetails);
            stackRepoComponent = new Component(ComponentType.HDP_REPO_DETAILS, ComponentType.HDP_REPO_DETAILS.name(), new Json(repo), stack);
        }
        components.add(stackRepoComponent);
    }
    return components;
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ArrayList(java.util.ArrayList) StackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackDetails) Json(com.sequenceiq.cloudbreak.domain.json.Json) Component(com.sequenceiq.cloudbreak.domain.Component) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 8 with Component

use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.

the class ImageService method create.

@Transactional(TxType.NEVER)
public void create(Stack stack, PlatformParameters params, String imageCatalog, Optional<String> imageId, Optional<Blueprint> blueprint) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    try {
        Platform platform = platform(stack.cloudPlatform());
        String platformString = platform(stack.cloudPlatform()).value().toLowerCase();
        String region = stack.getRegion();
        SecurityConfig securityConfig = stack.getSecurityConfig();
        String cbPrivKey = securityConfig.getCloudbreakSshPrivateKeyDecoded();
        byte[] cbSshKeyDer = PkiUtil.getPublicKeyDer(cbPrivKey);
        String sshUser = stack.getStackAuthentication().getLoginUserName();
        String cbCert = securityConfig.getClientCertRaw();
        Map<InstanceGroupType, String> userData = userDataBuilder.buildUserData(platform, cbSshKeyDer, sshUser, params, securityConfig.getSaltBootPassword(), cbCert);
        StatedImage imgFromCatalog = determineImageFromCatalog(imageId, platformString, imageCatalog, blueprint);
        LOGGER.info("Determined image from catalog: {}", imgFromCatalog);
        String imageName = determineImageName(platformString, region, imgFromCatalog.getImage());
        LOGGER.info("Selected VM image for CloudPlatform '{}' and region '{}' is: {} from: {} image catalog", platformString, region, imageName, imgFromCatalog.getImageCatalogUrl());
        List<Component> components = getComponents(stack, userData, imgFromCatalog.getImage(), imageName, imgFromCatalog.getImageCatalogUrl(), imgFromCatalog.getImageCatalogName(), imgFromCatalog.getImage().getUuid());
        componentConfigProvider.store(components);
    } catch (JsonProcessingException e) {
        throw new CloudbreakServiceException("Failed to create json", e);
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) Component(com.sequenceiq.cloudbreak.domain.Component) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Transactional(javax.transaction.Transactional)

Example 9 with Component

use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.

the class ComponentConfigProvider method store.

public Component store(Component component) {
    LOGGER.debug("Component is going to be saved: {}", component);
    Component ret = componentRepository.save(component);
    LOGGER.debug("Component saved: stackId: {}, component: {}", ret.getStack().getId(), ret);
    return ret;
}
Also used : Component(com.sequenceiq.cloudbreak.domain.Component)

Aggregations

Component (com.sequenceiq.cloudbreak.domain.Component)9 Json (com.sequenceiq.cloudbreak.domain.json.Json)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 IOException (java.io.IOException)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)3 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Sets (com.google.common.collect.Sets)1 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)1 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 InstanceGroupType (com.sequenceiq.cloudbreak.api.model.InstanceGroupType)1 BlueprintUtils (com.sequenceiq.cloudbreak.blueprint.utils.BlueprintUtils)1 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)1