Search in sources :

Example 11 with AmbariRepo

use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo 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 12 with AmbariRepo

use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo in project cloudbreak by hortonworks.

the class ClusterToClusterResponseConverter method convertComponentConfig.

private void convertComponentConfig(ClusterResponse response, Cluster source) {
    try {
        AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(source.getComponents());
        if (ambariRepo != null) {
            AmbariRepoDetailsJson ambariRepoDetailsJson = getConversionService().convert(ambariRepo, AmbariRepoDetailsJson.class);
            response.setAmbariRepoDetailsJson(ambariRepoDetailsJson);
        }
        StackRepoDetails stackRepoDetails = componentConfigProvider.getStackRepo(source.getComponents());
        if (stackRepoDetails != null) {
            AmbariStackDetailsResponse ambariRepoDetailsJson = getConversionService().convert(stackRepoDetails, AmbariStackDetailsResponse.class);
            response.setAmbariStackDetails(ambariRepoDetailsJson);
        }
    } catch (RuntimeException e) {
        LOGGER.error("Failed to convert dynamic component.", e);
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) AmbariStackDetailsResponse(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsResponse) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) AmbariRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)

Example 13 with AmbariRepo

use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo in project cloudbreak by hortonworks.

the class ImageToAmbariRepoConverter method convert.

@Override
public AmbariRepo convert(Image image) {
    AmbariRepo ambariRepo = new AmbariRepo();
    ambariRepo.setPredefined(Boolean.TRUE);
    ambariRepo.setVersion(image.getVersion());
    ambariRepo.setBaseUrl(image.getRepo().get(image.getOsType()));
    return ambariRepo;
}
Also used : AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Example 14 with AmbariRepo

use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo in project cloudbreak by hortonworks.

the class ImagesToImagesResponseJsonConverter method getBaseImageResponses.

private List<BaseImageResponse> getBaseImageResponses(Images source) {
    List<StackDetailsJson> defaultHdpStacks = getDefaultStackInfos(defaultHDPEntries.getEntries().values());
    List<StackDetailsJson> defaultHdfStacks = getDefaultStackInfos(defaultHDFEntries.getEntries().values());
    List<BaseImageResponse> baseImages = source.getBaseImages().stream().filter(i -> defaultAmbariRepoService.getDefault(i.getOsType()) != null).map(i -> {
        BaseImageResponse imgJson = new BaseImageResponse();
        copyImageFieldsToJson(i, imgJson);
        imgJson.setHdpStacks(defaultHdpStacks);
        imgJson.setHdfStacks(defaultHdfStacks);
        imgJson.setVersion(defaultAmbariRepoService.getVersion());
        AmbariRepo ambariRepo = defaultAmbariRepoService.getDefault(i.getOsType());
        Map<String, String> repoJson = new HashMap<>();
        repoJson.put("baseurl", ambariRepo.getBaseUrl());
        repoJson.put("gpgkey", ambariRepo.getGpgKeyUrl());
        imgJson.setRepo(repoJson);
        return imgJson;
    }).collect(Collectors.toList());
    return baseImages;
}
Also used : AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) DefaultHDFEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDFEntries) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackRepoDetails) HashMap(java.util.HashMap) StackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackDetails) Collectors(java.util.stream.Collectors) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ImagesResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImagesResponse) List(java.util.List) Component(org.springframework.stereotype.Component) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) StackRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackRepoDetailsJson) DefaultHDPEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDPEntries) ImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImageResponse) Map(java.util.Map) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StackInfo(com.sequenceiq.cloudbreak.cloud.model.component.StackInfo) DefaultAmbariRepoService(com.sequenceiq.cloudbreak.service.DefaultAmbariRepoService) StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with AmbariRepo

use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo in project cloudbreak by hortonworks.

the class AmbariRepositoryVersionService method getRepositoryVersion.

public String getRepositoryVersion(long clusterId, Orchestrator orchestrator) throws CloudbreakException {
    StackRepoDetails stackRepoDetails = getStackRepoDetails(clusterId, orchestrator);
    AmbariRepo ambariRepoDetails = clusterComponentConfigProvider.getAmbariRepo(clusterId);
    String result = "";
    if (stackRepoDetails != null && isVersionNewerOrEqualThanLimited(ambariRepoDetails::getVersion, AMBARI_VERSION_2_6_0_0)) {
        Optional<String> repositoryVersion = Optional.ofNullable(stackRepoDetails.getStack().get(StackRepoDetails.REPOSITORY_VERSION));
        result = repositoryVersion.orElse("");
    }
    return result;
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Aggregations

AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)16 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)7 HashMap (java.util.HashMap)4 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)2 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 AmbariStackDetailsResponse (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsResponse)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)1 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)1 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)1 UserNamePasswordJson (com.sequenceiq.cloudbreak.api.model.UserNamePasswordJson)1