Search in sources :

Example 51 with Cluster

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

the class ClouderaManagerModificationService method callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751.

private void callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751(ClustersResourceApi clustersResourceApi) throws ApiException, CloudbreakException {
    ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(stack.getCluster().getId());
    String currentCMVersion = clouderaManagerRepo.getVersion();
    Versioned baseCMVersion = CLOUDERAMANAGER_VERSION_7_5_1;
    if (isVersionNewerOrEqualThanLimited(currentCMVersion, baseCMVersion)) {
        LOGGER.debug("Cloudera Manager version {} is newer than {} hence calling post runtime upgrade command using /v45 API", currentCMVersion, baseCMVersion.getVersion());
        eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), ResourceEvent.CLUSTER_UPGRADE_START_POST_UPGRADE);
        waitForRestartCommandIfThereIsAny(clustersResourceApi);
        Cluster cluster = stack.getCluster();
        String user = cluster.getCloudbreakAmbariUser();
        String password = cluster.getCloudbreakAmbariPassword();
        try {
            ApiClient v45Client = clouderaManagerApiClientProvider.getV45Client(stack.getGatewayPort(), user, password, clientConfig);
            ClustersResourceApi clustersResourceV45Api = clouderaManagerApiFactory.getClustersResourceApi(v45Client);
            clouderaManagerUpgradeService.callPostRuntimeUpgradeCommand(clustersResourceV45Api, stack, v45Client);
        } catch (ClouderaManagerClientInitException e) {
            LOGGER.info("Couldn't build CM v45 client", e);
            throw new CloudbreakException(e);
        }
    } else {
        LOGGER.debug("Cloudera Manager version {} is older than {} hence NOT calling post runtime upgrade command", currentCMVersion, baseCMVersion.getVersion());
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi)

Example 52 with Cluster

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

the class ClouderaManagerDiagnosticsService method initApiClient.

@PostConstruct
public void initApiClient() throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String cloudbreakAmbariUser = cluster.getCloudbreakAmbariUser();
    String cloudbreakAmbariPassword = cluster.getCloudbreakAmbariPassword();
    try {
        client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), cloudbreakAmbariUser, cloudbreakAmbariPassword, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) PostConstruct(javax.annotation.PostConstruct)

Example 53 with Cluster

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

the class ClouderaManagerKerberosService method configureKerberosViaApi.

public void configureKerberosViaApi(ApiClient client, HttpClientConfig clientConfig, Stack stack, KerberosConfig kerberosConfig) throws ApiException, CloudbreakException {
    Cluster cluster = stack.getCluster();
    if (kerberosDetailService.isAdJoinable(kerberosConfig) || kerberosDetailService.isIpaJoinable(kerberosConfig)) {
        ClouderaManagerModificationService modificationService = applicationContext.getBean(ClouderaManagerModificationService.class, stack, clientConfig);
        ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
        modificationService.stopCluster(false);
        ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(client);
        ApiCommand configureForKerberos = clustersResourceApi.configureForKerberos(cluster.getName(), new ApiConfigureForKerberosArguments());
        clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, configureForKerberos.getId());
        ApiCommand generateCredentials = clouderaManagerResourceApi.generateCredentialsCommand();
        clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, generateCredentials.getId());
        List<ApiCommand> commands = clustersResourceApi.listActiveCommands(stack.getName(), SUMMARY).getItems();
        BigDecimal deployClusterConfigId = clouderaManagerCommonCommandService.getDeployClientConfigCommandId(stack, clustersResourceApi, commands);
        clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, deployClusterConfigId);
        modificationService.startCluster();
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiConfigureForKerberosArguments(com.cloudera.api.swagger.model.ApiConfigureForKerberosArguments) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) BigDecimal(java.math.BigDecimal)

Example 54 with Cluster

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

the class ClouderaManagerKerberosService method deleteCredentials.

public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
        clouderaManagerConfigService.disableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, client, stack.getName());
        ClouderaManagerModificationService modificationService = applicationContext.getBean(ClouderaManagerModificationService.class, stack, clientConfig);
        modificationService.stopCluster(false);
        ClouderaManagerClusterDecommissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecommissionService.class, stack, clientConfig);
        decomissionService.removeManagementServices();
        ClouderaManagerResourceApi apiInstance = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
        ApiCommand command = apiInstance.deleteCredentialsCommand("all");
        clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, command.getId());
    } catch (ApiException | CloudbreakException | ClouderaManagerClientInitException e) {
        LOGGER.info("Failed to remove Kerberos credentials", e);
        throw new ClouderaManagerOperationFailedException("Failed to remove Kerberos credentials", e);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 55 with Cluster

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

the class ClouderaManagerSecurityService method processHostCertsBatchResponse.

private void processHostCertsBatchResponse(ApiClient client, ApiBatchResponse apiBatchResponse) {
    if (apiBatchResponse != null && apiBatchResponse.getSuccess() != null && apiBatchResponse.getItems() != null && apiBatchResponse.getSuccess()) {
        List<BigDecimal> ids = apiBatchResponse.getItems().stream().map(bre -> new Json((String) bre.getResponse()).getSilent(ApiCommand.class).getId()).collect(Collectors.toList());
        ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCommandList(stack, client, ids, "Rotate host certificates");
        if (pollingResult.isExited()) {
            throw new CancellationException("Cluster was terminated during rotation of host certificates");
        } else if (pollingResult.isTimeout()) {
            throw new ClouderaManagerOperationFailedException("Timeout while Cloudera Manager rotates the host certificates.");
        }
    } else {
        throw new ClouderaManagerOperationFailedException("Host certificates rotation batch operation failed: " + apiBatchResponse);
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) KeyPair(java.security.KeyPair) ApiBatchRequestElement(com.cloudera.api.swagger.model.ApiBatchRequestElement) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) LoggerFactory(org.slf4j.LoggerFactory) ToolsResourceApi(com.cloudera.api.swagger.ToolsResourceApi) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) StringUtils(org.apache.commons.lang3.StringUtils) ApiAuthRoleRef(com.cloudera.api.swagger.model.ApiAuthRoleRef) Scope(org.springframework.context.annotation.Scope) ApiException(com.cloudera.api.swagger.client.ApiException) ClouderaManagerPollingServiceProvider(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider) Inject(javax.inject.Inject) BigDecimal(java.math.BigDecimal) ClouderaManagerApiClientProvider(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerApiClientProvider) UsersResourceApi(com.cloudera.api.swagger.UsersResourceApi) BatchResourceApi(com.cloudera.api.swagger.BatchResourceApi) Service(org.springframework.stereotype.Service) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) ApiBatchRequest(com.cloudera.api.swagger.model.ApiBatchRequest) Retryable(org.springframework.retry.annotation.Retryable) Logger(org.slf4j.Logger) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiBatchResponse(com.cloudera.api.swagger.model.ApiBatchResponse) ApiUser2List(com.cloudera.api.swagger.model.ApiUser2List) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) URLUtils(com.sequenceiq.cloudbreak.util.URLUtils) ClusterSecurityService(com.sequenceiq.cloudbreak.cluster.api.ClusterSecurityService) ApiGenerateHostCertsArguments(com.cloudera.api.swagger.model.ApiGenerateHostCertsArguments) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Collectors(java.util.stream.Collectors) ApiUser2(com.cloudera.api.swagger.model.ApiUser2) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) HTTPMethod(com.cloudera.api.swagger.model.HTTPMethod) PkiUtil(com.sequenceiq.cloudbreak.certificate.PkiUtil) DatalakeDto(com.sequenceiq.cloudbreak.dto.datalake.DatalakeDto) Optional(java.util.Optional) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) Json(com.sequenceiq.cloudbreak.common.json.Json) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) BigDecimal(java.math.BigDecimal)

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