Search in sources :

Example 56 with Cluster

use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.

the class ClouderaManagerSecurityService method createClientWithNewPassword.

private ApiClient createClientWithNewPassword() throws ClouderaManagerClientInitException {
    LOGGER.debug("Cloudera Manager already running, old admin user's password has been changed.");
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    return clouderaManagerApiClientProvider.getV40Client(stack.getGatewayPort(), user, password, clientConfig);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 57 with Cluster

use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.

the class ClouderaManagerSecurityService method changeOriginalCredentialsAndCreateCloudbreakUser.

@Override
public void changeOriginalCredentialsAndCreateCloudbreakUser(boolean ldapConfigured) throws CloudbreakException {
    LOGGER.debug("change original admin user and create cloudbreak user");
    try {
        ApiClient client = createApiClient();
        UsersResourceApi usersResourceApi = clouderaManagerApiFactory.getUserResourceApi(client);
        ApiUser2List userList = usersResourceApi.readUsers2("SUMMARY");
        ApiUser2 oldAdminUser = getOldAdminUser(userList).orElseThrow(() -> new CloudbreakException("Can't find original admin user"));
        Cluster cluster = stack.getCluster();
        createNewUser(usersResourceApi, oldAdminUser.getAuthRoles(), cluster.getCloudbreakAmbariUser(), cluster.getCloudbreakAmbariPassword(), userList);
        createNewUser(usersResourceApi, oldAdminUser.getAuthRoles(), cluster.getDpAmbariUser(), cluster.getDpAmbariPassword(), userList);
        if (ADMIN_USER.equals(cluster.getUserName())) {
            oldAdminUser.setPassword(cluster.getPassword());
            usersResourceApi.updateUser2(oldAdminUser.getName(), oldAdminUser);
        } else if (cluster.getUserName() != null) {
            createUserSuppliedCMUser(userList, oldAdminUser, cluster);
        }
        removeDefaultAdminUser(ldapConfigured, Optional.ofNullable(cluster.getUserName()));
    } catch (ApiException | ClusterClientInitException | ClouderaManagerClientInitException e) {
        LOGGER.info("Can't replace original admin user due to: ", e);
        throw new CloudbreakException("Can't replace original admin user due to: " + e.getMessage());
    }
}
Also used : UsersResourceApi(com.cloudera.api.swagger.UsersResourceApi) ApiUser2List(com.cloudera.api.swagger.model.ApiUser2List) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiUser2(com.cloudera.api.swagger.model.ApiUser2) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 58 with Cluster

use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method addNoProxyHosts.

private void addNoProxyHosts(ProxyConfig proxyConfig, ApiConfigList proxyConfigList) {
    if (StringUtils.isNotBlank(proxyConfig.getNoProxyHosts())) {
        Cluster cluster = stack.getCluster();
        ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(cluster.getId());
        if (isVersionNewerOrEqualThanLimited(clouderaManagerRepoDetails::getVersion, CLOUDERAMANAGER_VERSION_7_6_0)) {
            proxyConfigList.addItemsItem(new ApiConfig().name("parcel_no_proxy_list").value(proxyConfig.getNoProxyHosts()));
        }
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ApiConfig(com.cloudera.api.swagger.model.ApiConfig)

Example 59 with Cluster

use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method installCluster.

@Override
public void installCluster(String template) {
    Cluster cluster = stack.getCluster();
    try {
        Optional<ApiCluster> cmCluster = getCmClusterByName(cluster.getName());
        boolean prewarmed = isPrewarmed(cluster.getId());
        Optional<ClusterCommand> importCommand = clusterCommandRepository.findTopByClusterIdAndClusterCommandType(cluster.getId(), ClusterCommandType.IMPORT_CLUSTER);
        if (cmCluster.isEmpty() || importCommand.isEmpty()) {
            ApiClusterTemplate apiClusterTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
            cluster.setExtendedBlueprintText(getExtendedBlueprintText(apiClusterTemplate));
            ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
            LOGGER.info("Generated Cloudera cluster template: {}", AnonymizerUtil.anonymize(template));
            // addRepositories - if true the parcels repositories in the cluster template
            // will be added.
            ApiCommand apiCommand = clouderaManagerResourceApi.importClusterTemplate(calculateAddRepositories(apiClusterTemplate, prewarmed), apiClusterTemplate);
            ClusterCommand clusterCommand = new ClusterCommand();
            clusterCommand.setClusterId(cluster.getId());
            clusterCommand.setCommandId(apiCommand.getId());
            clusterCommand.setClusterCommandType(ClusterCommandType.IMPORT_CLUSTER);
            importCommand = Optional.of(clusterCommandRepository.save(clusterCommand));
            LOGGER.debug("Cloudera cluster template has been submitted, cluster install is in progress");
        }
        importCommand.ifPresent(cmd -> clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(stack, apiClient, cmd.getCommandId()));
    } catch (ApiException e) {
        String msg = "Installation of CDP with Cloudera Manager has failed: " + extractMessage(e);
        throw new ClouderaManagerOperationFailedException(msg, e);
    } catch (CloudStorageConfigurationFailedException e) {
        LOGGER.info("Error while configuring cloud storage. Message: {}", e.getMessage(), e);
        throw new ClouderaManagerOperationFailedException(mapStorageError(e, stack.getResourceCrn(), stack.cloudPlatform(), cluster), e);
    } catch (Exception e) {
        throw mapException(e);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiException(com.cloudera.api.swagger.client.ApiException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ClusterCommand(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommand) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 60 with Cluster

use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method waitForHosts.

@Override
public ExtendedPollingResult waitForHosts(Set<InstanceMetaData> hostsInCluster) throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    ApiClient client;
    try {
        client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
    List<String> privateIps = hostsInCluster.stream().map(InstanceMetaData::getPrivateIp).collect(Collectors.toList());
    return clouderaManagerPollingServiceProvider.startPollingCmHostStatus(stack, client, privateIps);
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Aggregations

Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)407 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)248 Test (org.junit.jupiter.api.Test)125 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)60 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)58 Optional (java.util.Optional)51 Test (org.junit.Test)50 List (java.util.List)49 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)47 Set (java.util.Set)43 Json (com.sequenceiq.cloudbreak.common.json.Json)39 Map (java.util.Map)39 Collectors (java.util.stream.Collectors)39 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)37 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)36 Inject (javax.inject.Inject)36 Logger (org.slf4j.Logger)36 LoggerFactory (org.slf4j.LoggerFactory)36 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)35