Search in sources :

Example 16 with RDSConfig

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

the class StackRequestToBlueprintPreparationObjectConverter method convert.

@Override
public BlueprintPreparationObject convert(StackV2Request source) {
    try {
        IdentityUser identityUser = userDetailsService.getDetails(source.getOwner(), UserFilterField.USERID);
        FlexSubscription flexSubscription = getFlexSubscription(source);
        String smartsenseSubscriptionId = getSmartsenseSubscriptionId(source, flexSubscription);
        KerberosConfig kerberosConfig = getKerberosConfig(source);
        LdapConfig ldapConfig = getLdapConfig(source, identityUser);
        FileSystemConfigurationView fileSystemConfigurationView = getFileSystemConfigurationView(source);
        Set<RDSConfig> rdsConfigs = getRdsConfigs(source, identityUser);
        Blueprint blueprint = getBlueprint(source, identityUser);
        BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(blueprint.getBlueprintText());
        Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
        BlueprintView blueprintView = new BlueprintView(blueprint.getBlueprintText(), blueprintStackInfo.getVersion(), blueprintStackInfo.getType());
        GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, identityUser);
        return BlueprintPreparationObject.Builder.builder().withFlexSubscription(flexSubscription).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withBlueprintView(blueprintView).withStackRepoDetailsHdpVersion(blueprintStackInfo.getVersion()).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withSmartSenseSubscriptionId(smartsenseSubscriptionId).withLdapConfig(ldapConfig).withKerberosConfig(kerberosConfig).build();
    } catch (BlueprintProcessingException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException) GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) IOException(java.io.IOException) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) FileSystemConfigurationView(com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)

Example 17 with RDSConfig

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

the class RdsConfigController method createRdsConfig.

private RDSConfigResponse createRdsConfig(IdentityUser user, RDSConfigRequest rdsConfigJson, boolean publicInAccount) {
    RDSConfig rdsConfig = conversionService.convert(rdsConfigJson, RDSConfig.class);
    rdsConfig.setPublicInAccount(publicInAccount);
    try {
        rdsConfig = rdsConfigService.create(user, rdsConfig);
        notify(user, ResourceEvent.RDS_CONFIG_CREATED);
    } catch (DataIntegrityViolationException ex) {
        String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.RDS_CONFIG, getProperSqlErrorMessage(ex));
        throw new BadRequestException(msg);
    }
    return conversionService.convert(rdsConfig, RDSConfigResponse.class);
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException)

Example 18 with RDSConfig

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

the class RdsConfigController method getPrivates.

@Override
public Set<RDSConfigResponse> getPrivates() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<RDSConfig> rdsConfigs = rdsConfigService.retrievePrivateRdsConfigs(user);
    return toJsonList(rdsConfigs);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig)

Example 19 with RDSConfig

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

the class ClusterDecorator method prepareConnectedClusterParameters.

private void prepareConnectedClusterParameters(Cluster requestedCluster, IdentityUser user, ConnectedClusterRequest connectedClusterRequest) {
    if (connectedClusterRequest != null) {
        Long stackId;
        Stack publicStack;
        if (!Strings.isNullOrEmpty(connectedClusterRequest.getSourceClusterName())) {
            publicStack = stackService.getPublicStack(connectedClusterRequest.getSourceClusterName(), user);
            stackId = publicStack.getId();
        } else {
            stackId = connectedClusterRequest.getSourceClusterId();
            publicStack = stackService.get(connectedClusterRequest.getSourceClusterId());
        }
        // We should set the ldap to the source cluster ldap
        requestedCluster.setLdapConfig(publicStack.getCluster().getLdapConfig());
        // We should set the ranger metastore to the source cluster ranger metastore if exist!
        RDSConfig rangerRds = rdsConfigService.findByClusterIdAndType(publicStack.getOwner(), publicStack.getAccount(), publicStack.getCluster().getId(), RdsType.RANGER);
        if (rangerRds != null) {
            requestedCluster.getRdsConfigs().add(rangerRds);
        }
        try {
            Set<BlueprintParameterJson> requests = new HashSet<>();
            Json blueprintAttributes = requestedCluster.getBlueprint().getInputParameters();
            if (blueprintAttributes != null && StringUtils.isNoneEmpty(blueprintAttributes.getValue())) {
                BlueprintInputParameters inputParametersObj = blueprintAttributes.get(BlueprintInputParameters.class);
                for (BlueprintParameter blueprintParameter : inputParametersObj.getParameters()) {
                    BlueprintParameterJson blueprintParameterJson = new BlueprintParameterJson();
                    blueprintParameterJson.setName(blueprintParameter.getName());
                    blueprintParameterJson.setReferenceConfiguration(blueprintParameter.getReferenceConfiguration());
                    blueprintParameterJson.setDescription(blueprintParameter.getDescription());
                    requests.add(blueprintParameterJson);
                }
            }
            ConfigsResponse configsResponse = clusterService.retrieveOutputs(stackId, requests);
            Map<String, String> newInputs = requestedCluster.getBlueprintInputs().get(Map.class);
            for (BlueprintInputJson blueprintInputJson : configsResponse.getInputs()) {
                newInputs.put(blueprintInputJson.getName(), blueprintInputJson.getPropertyValue());
            }
            requestedCluster.setBlueprintInputs(new Json(newInputs));
        } catch (IOException e) {
            LOGGER.error("Could not propagate cluster input parameters", e);
            throw new BadRequestException("Could not propagate cluster input parameters: " + e.getMessage());
        }
    }
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) ConfigsResponse(com.sequenceiq.cloudbreak.api.model.ConfigsResponse) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) BlueprintParameter(com.sequenceiq.cloudbreak.domain.BlueprintParameter) Json(com.sequenceiq.cloudbreak.domain.json.Json) BlueprintParameterJson(com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) IOException(java.io.IOException) BlueprintInputParameters(com.sequenceiq.cloudbreak.domain.BlueprintInputParameters) Stack(com.sequenceiq.cloudbreak.domain.Stack) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) BlueprintParameterJson(com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson) HashSet(java.util.HashSet)

Example 20 with RDSConfig

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

the class AmbariConfigurationService method createAmbariDefaultRdsConf.

private RDSConfig createAmbariDefaultRdsConf(Stack stack, Cluster cluster) {
    RDSConfig rdsConfig = new RDSConfig();
    rdsConfig.setName(ambariDatabaseMapper.mapName(stack, cluster));
    rdsConfig.setConnectionUserName(userName);
    rdsConfig.setConnectionPassword(PasswordUtil.generatePassword());
    rdsConfig.setConnectionURL("jdbc:postgresql://" + host + ":" + port + "/" + name);
    rdsConfig.setDatabaseEngine(databaseEngine);
    rdsConfig.setType(RdsType.AMBARI.name());
    rdsConfig.setStatus(ResourceStatus.DEFAULT);
    rdsConfig.setCreationDate(new Date().getTime());
    rdsConfig.setOwner(stack.getOwner());
    rdsConfig.setAccount(stack.getAccount());
    rdsConfig.setClusters(Collections.singleton(cluster));
    rdsConfig.setConnectionDriver("org.postgresql.Driver");
    return rdsConfigService.create(rdsConfig);
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Date(java.util.Date)

Aggregations

RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)47 Test (org.junit.Test)16 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)6 RDSConfigRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)5 Date (java.util.Date)5 HashSet (java.util.HashSet)5 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)4 Json (com.sequenceiq.cloudbreak.domain.json.Json)4 IOException (java.io.IOException)4 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)3 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)2 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)2 ConfigsResponse (com.sequenceiq.cloudbreak.api.model.ConfigsResponse)2 RdsView (com.sequenceiq.cloudbreak.blueprint.template.views.RdsView)2 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)2