Search in sources :

Example 1 with Stack

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

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosOnKerberizedBlueprint.

@Test
public void testExtendBlueprintWithKerberosOnKerberizedBlueprint() throws IOException {
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-kerberized-test.bp");
    Blueprint blueprint = TestUtil.blueprint("name", expectedBlueprint);
    Stack stack = TestUtil.stack();
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, TestUtil.kerberosConfig());
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(BlueprintTestUtil.generalClusterConfigs()).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) JsonNode(com.fasterxml.jackson.databind.JsonNode) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 2 with Stack

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

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosCustomConfig.

@Test
public void testExtendBlueprintWithKerberosCustomConfig() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized.bp");
    Blueprint blueprint = TestUtil.blueprint("name", blueprintText);
    Stack stack = TestUtil.stack();
    KerberosConfig kerberosConfig = new KerberosConfig();
    kerberosConfig.setDescriptor("{\"kerberos-env\":{\"properties\":{\"install_packages\":false,\"realm\":\"REALM.BP\",\"kdc_type\":\"mit-kdc\"," + "\"kdc_hosts\":\"kdc_host.bp\",\"admin_server_host\":\"admin_server_host.bp\",\"encryption_types\":\"enc_types.bp\",\"ldap_url\":\"\"," + "\"container_dn\":\"\"}}}");
    kerberosConfig.setKrb5Conf("{\"krb5-conf\":{\"properties\":{\"domains\":\".domains.bp\",\"manage_krb5_conf\":\"true\",\"content\":\"content.bp\"}}}");
    kerberosConfig.setTcpAllowed(true);
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, kerberosConfig);
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(BlueprintTestUtil.generalClusterConfigs()).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized-custom-config-expected.bp");
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) JsonNode(com.fasterxml.jackson.databind.JsonNode) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 3 with Stack

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

the class ClusterHostServiceRunner method changePrimaryGateway.

public String changePrimaryGateway(Stack stack) throws CloudbreakException {
    GatewayConfig formerPrimaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
    Optional<GatewayConfig> newPrimaryCandidate = gatewayConfigs.stream().filter(gc -> !gc.isPrimary()).findFirst();
    if (newPrimaryCandidate.isPresent()) {
        GatewayConfig newPrimary = newPrimaryCandidate.get();
        Set<Node> allNodes = collectNodes(stack);
        try {
            hostOrchestratorResolver.get(stack.getOrchestrator().getType()).changePrimaryGateway(formerPrimaryGatewayConfig, newPrimary, gatewayConfigs, allNodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
            return newPrimary.getHostname();
        } catch (CloudbreakOrchestratorException ex) {
            throw new CloudbreakException(ex);
        }
    } else {
        throw new CloudbreakException("Primary gateway change is not possible because there is no available node for the action");
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) KerberosDetailService(com.sequenceiq.cloudbreak.blueprint.kerberos.KerberosDetailService) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) StringUtils(org.apache.commons.lang3.StringUtils) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) Map(java.util.Map) AmbariSecurityConfigProvider(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariSecurityConfigProvider) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) RdsView(com.sequenceiq.cloudbreak.blueprint.template.views.RdsView) Transactional(javax.transaction.Transactional) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Set(java.util.Set) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Collectors(java.util.stream.Collectors) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) ProxyConfigProvider(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigProvider) List(java.util.List) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) SmartSenseCredentialConfigService(com.sequenceiq.cloudbreak.service.SmartSenseCredentialConfigService) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) RdsType(com.sequenceiq.cloudbreak.api.model.rds.RdsType) HashMap(java.util.HashMap) HostGroupRepository(com.sequenceiq.cloudbreak.repository.HostGroupRepository) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) Collections.singletonMap(java.util.Collections.singletonMap) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Json(com.sequenceiq.cloudbreak.domain.json.Json) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.service.ClusterComponentConfigProvider) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ExposedServices(com.sequenceiq.cloudbreak.domain.ExposedServices) IOException(java.io.IOException) PostgresConfigService(com.sequenceiq.cloudbreak.core.bootstrap.service.container.postgres.PostgresConfigService) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ExecutorType(com.sequenceiq.cloudbreak.api.model.ExecutorType) Component(org.springframework.stereotype.Component) ExposedService(com.sequenceiq.cloudbreak.api.model.ExposedService) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) AmbariDatabaseMapper(com.sequenceiq.cloudbreak.converter.mapper.AmbariDatabaseMapper) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) Comparator(java.util.Comparator) Collections(java.util.Collections) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 4 with Stack

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

the class ClusterHostServiceRunner method saveSharedRangerService.

private void saveSharedRangerService(Stack stack, Map<String, SaltPillarProperties> servicePillar) {
    Long datalakeId = stack.getDatalakeId();
    if (datalakeId != null) {
        Stack dataLakeStack = stackRepository.findOne(datalakeId);
        Cluster dataLakeCluster = dataLakeStack.getCluster();
        Set<String> groupNames = blueprintProcessorFactory.get(dataLakeCluster.getBlueprint().getBlueprintText()).getHostGroupsWithComponent("RANGER_ADMIN");
        List<HostGroup> groups = dataLakeCluster.getHostGroups().stream().filter(hg -> groupNames.contains(hg.getName())).collect(Collectors.toList());
        Set<String> hostNames = new HashSet<>();
        groups.forEach(hg -> hostNames.addAll(hg.getHostMetadata().stream().map(HostMetadata::getHostName).collect(Collectors.toList())));
        Map<String, Object> rangerMap = new HashMap<>();
        rangerMap.put("servers", hostNames);
        rangerMap.put("port", "6080");
        servicePillar.put("datalake-services", new SaltPillarProperties("/datalake/init.sls", singletonMap("datalake-services", singletonMap("ranger", rangerMap))));
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) KerberosDetailService(com.sequenceiq.cloudbreak.blueprint.kerberos.KerberosDetailService) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) StringUtils(org.apache.commons.lang3.StringUtils) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) Map(java.util.Map) AmbariSecurityConfigProvider(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariSecurityConfigProvider) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) RdsView(com.sequenceiq.cloudbreak.blueprint.template.views.RdsView) Transactional(javax.transaction.Transactional) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Set(java.util.Set) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Collectors(java.util.stream.Collectors) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) ProxyConfigProvider(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigProvider) List(java.util.List) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) SmartSenseCredentialConfigService(com.sequenceiq.cloudbreak.service.SmartSenseCredentialConfigService) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) RdsType(com.sequenceiq.cloudbreak.api.model.rds.RdsType) HashMap(java.util.HashMap) HostGroupRepository(com.sequenceiq.cloudbreak.repository.HostGroupRepository) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) Collections.singletonMap(java.util.Collections.singletonMap) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Json(com.sequenceiq.cloudbreak.domain.json.Json) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.service.ClusterComponentConfigProvider) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ExposedServices(com.sequenceiq.cloudbreak.domain.ExposedServices) IOException(java.io.IOException) PostgresConfigService(com.sequenceiq.cloudbreak.core.bootstrap.service.container.postgres.PostgresConfigService) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ExecutorType(com.sequenceiq.cloudbreak.api.model.ExecutorType) Component(org.springframework.stereotype.Component) ExposedService(com.sequenceiq.cloudbreak.api.model.ExposedService) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) AmbariDatabaseMapper(com.sequenceiq.cloudbreak.converter.mapper.AmbariDatabaseMapper) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) Comparator(java.util.Comparator) Collections(java.util.Collections) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.cloudbreak.domain.Stack) HashSet(java.util.HashSet)

Example 5 with Stack

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

the class ClusterCredentialChangeHandler method accept.

@Override
public void accept(Event<ClusterCredentialChangeRequest> event) {
    ClusterCredentialChangeRequest request = event.getData();
    ClusterCredentialChangeResult result;
    try {
        Stack stack = stackService.getByIdWithLists(request.getStackId());
        switch(request.getType()) {
            case REPLACE:
                ambariClusterConnector.replaceUserNamePassword(stack, request.getUser(), request.getPassword());
                break;
            case UPDATE:
                ambariClusterConnector.updateUserNamePassword(stack, request.getPassword());
                break;
            default:
                throw new UnsupportedOperationException("Ambari credential update request not supported: " + request.getType());
        }
        result = new ClusterCredentialChangeResult(request);
    } catch (Exception e) {
        result = new ClusterCredentialChangeResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterCredentialChangeRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeRequest) ClusterCredentialChangeResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeResult) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14