Search in sources :

Example 1 with SaltPillarProperties

use of com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties in project cloudbreak by hortonworks.

the class AmbariClusterUpgradeService method upgradeCluster.

public void upgradeCluster(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackRepository.findOneWithLists(stackId);
    Cluster cluster = stack.getCluster();
    try {
        OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
        if (orchestratorType.hostOrchestrator()) {
            HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
            InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
            GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway().getEnableGateway());
            Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
            ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
            AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(cluster.getId());
            Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
            Map<String, Object> credentials = new HashMap<>();
            credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(cluster));
            credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(cluster));
            servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
            if (ambariRepo != null) {
                servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
            }
            SaltConfig pillar = new SaltConfig(servicePillar);
            hostOrchestrator.upgradeAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), pillar, exitCriteriaModel);
        } else {
            throw new UnsupportedOperationException("Ambari upgrade works only with host orchestrator");
        }
    } catch (CloudbreakException e) {
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with SaltPillarProperties

use of com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties 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 3 with SaltPillarProperties

use of com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties in project cloudbreak by hortonworks.

the class ProxyConfigProviderTest method testProxyCore.

private Map<String, Object> testProxyCore(ProxyConfig proxyConfig) {
    proxyConfig.setServerHost("test");
    proxyConfig.setServerPort(3128);
    proxyConfig.setProtocol("http");
    cluster.setProxyConfig(proxyConfig);
    proxyConfigProvider.decoratePillarWithProxyDataIfNeeded(servicePillar, cluster);
    SaltPillarProperties pillarProperties = servicePillar.get(ProxyConfigProvider.PROXY_KEY);
    assertNotNull(pillarProperties);
    assertEquals(ProxyConfigProvider.PROXY_SLS_PATH, pillarProperties.getPath());
    return (Map<String, Object>) pillarProperties.getProperties().get(ProxyConfigProvider.PROXY_KEY);
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 4 with SaltPillarProperties

use of com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method createSaltConfig.

private SaltConfig createSaltConfig(Stack stack, Cluster cluster, GatewayConfig primaryGatewayConfig, Iterable<GatewayConfig> gatewayConfigs) throws IOException, CloudbreakOrchestratorException {
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    saveDatalakeNameservers(stack, servicePillar);
    saveSharedRangerService(stack, servicePillar);
    if (cluster.isSecure() && kerberosDetailService.isAmbariManagedKerberosPackages(cluster.getKerberosConfig())) {
        Map<String, String> kerberosPillarConf = new HashMap<>();
        KerberosConfig kerberosConfig = cluster.getKerberosConfig();
        putIfNotNull(kerberosPillarConf, kerberosConfig.getMasterKey(), "masterKey");
        putIfNotNull(kerberosPillarConf, kerberosConfig.getAdmin(), "user");
        putIfNotNull(kerberosPillarConf, kerberosConfig.getPassword(), "password");
        if (StringUtils.isEmpty(kerberosConfig.getDescriptor())) {
            putIfNotNull(kerberosPillarConf, kerberosConfig.getUrl(), "url");
            putIfNotNull(kerberosPillarConf, kerberosConfig.getAdminUrl(), "adminUrl");
            putIfNotNull(kerberosPillarConf, kerberosConfig.getRealm(), "realm");
        } else {
            Map<String, Object> properties = kerberosDetailService.getKerberosEnvProperties(kerberosConfig);
            putIfNotNull(kerberosPillarConf, properties.get("kdc_hosts"), "url");
            putIfNotNull(kerberosPillarConf, properties.get("admin_server_host"), "adminUrl");
            putIfNotNull(kerberosPillarConf, properties.get("realm"), "realm");
        }
        putIfNotNull(kerberosPillarConf, cluster.getUserName(), "clusterUser");
        putIfNotNull(kerberosPillarConf, cluster.getPassword(), "clusterPassword");
        servicePillar.put("kerberos", new SaltPillarProperties("/kerberos/init.sls", singletonMap("kerberos", kerberosPillarConf)));
    }
    servicePillar.put("discovery", new SaltPillarProperties("/discovery/init.sls", singletonMap("platform", stack.cloudPlatform())));
    servicePillar.put("metadata", new SaltPillarProperties("/metadata/init.sls", singletonMap("cluster", singletonMap("name", stack.getCluster().getName()))));
    saveGatewayPillar(primaryGatewayConfig, cluster, servicePillar);
    AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(cluster.getId());
    if (ambariRepo != null) {
        servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
    }
    servicePillar.put("ambari-gpl-repo", new SaltPillarProperties("/ambari/gpl.sls", singletonMap("ambari", singletonMap("gpl", singletonMap("enabled", clusterComponentConfigProvider.getHDPRepo(cluster.getId()).isEnableGplRepo())))));
    decoratePillarWithAmbariDatabase(cluster, servicePillar);
    saveLdapPillar(cluster.getLdapConfig(), servicePillar);
    saveDockerPillar(cluster.getExecutorType(), servicePillar);
    saveHDPPillar(cluster.getId(), servicePillar);
    Map<String, Object> credentials = new HashMap<>();
    credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(stack.getCluster()));
    credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(stack.getCluster()));
    credentials.put("securityMasterKey", ambariSecurityConfigProvider.getAmbariSecurityMasterKey(cluster));
    servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
    if (smartSenseCredentialConfigService.areCredentialsSpecified()) {
        Map<String, Object> smartSenseCredentials = smartSenseCredentialConfigService.getCredentials();
        servicePillar.put("smartsense-credentials", new SaltPillarProperties("/smartsense/credentials.sls", smartSenseCredentials));
    }
    postgresConfigService.decorateServicePillarWithPostgresIfNeeded(servicePillar, stack, cluster);
    proxyConfigProvider.decoratePillarWithProxyDataIfNeeded(servicePillar, cluster);
    return new SaltConfig(servicePillar, createGrainProperties(gatewayConfigs));
}
Also used : HashMap(java.util.HashMap) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 5 with SaltPillarProperties

use of com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method saveHDPPillar.

private void saveHDPPillar(Long clusterId, Map<String, SaltPillarProperties> servicePillar) {
    StackRepoDetails hdprepo = clusterComponentConfigProvider.getHDPRepo(clusterId);
    servicePillar.put("hdp", new SaltPillarProperties("/hdp/repo.sls", singletonMap("hdp", hdprepo)));
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Aggregations

SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)12 HashMap (java.util.HashMap)7 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)5 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)4 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)3 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)3 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)3 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)3 RdsView (com.sequenceiq.cloudbreak.blueprint.template.views.RdsView)2 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 ExposedServices (com.sequenceiq.cloudbreak.domain.ExposedServices)2 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)2 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)2 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)2 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)2