Search in sources :

Example 1 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class InstallClusterHandler method accept.

@Override
public void accept(Event<InstallClusterRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.installCluster(stackId);
        response = new InstallClusterSuccess(stackId);
    } catch (RuntimeException | ClusterClientInitException | CloudbreakException e) {
        LOGGER.error("Failed to Install Cloudera Manager cluster: {}", e.getMessage());
        response = new InstallClusterFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : InstallClusterFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.InstallClusterFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) InstallClusterSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.InstallClusterSuccess)

Example 2 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException 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 3 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class ClouderaManagerSecurityService method createApiClient.

private ApiClient createApiClient() throws ClusterClientInitException, ClouderaManagerClientInitException, CloudbreakException {
    try {
        ApiClient client = clouderaManagerApiClientProvider.getDefaultClient(stack.getGatewayPort(), clientConfig, ClouderaManagerApiClientProvider.API_V_31);
        ToolsResourceApi toolsResourceApi = clouderaManagerApiFactory.getToolsResourceApi(client);
        toolsResourceApi.echo("TEST");
        LOGGER.debug("Cloudera Manager already running, old admin user's password has not been changed yet.");
        return client;
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    } catch (ApiException e) {
        if (org.springframework.http.HttpStatus.UNAUTHORIZED.value() == e.getCode()) {
            return createClientWithNewPassword();
        }
        LOGGER.debug("Cloudera Manager is not running.", e);
        throw new CloudbreakException("Cloudera Manager is not running. " + e.getMessage());
    }
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ToolsResourceApi(com.cloudera.api.swagger.ToolsResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 4 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException 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 5 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException 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

ClusterClientInitException (com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException)24 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)17 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)12 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)10 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)8 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)8 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)8 Map (java.util.Map)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 Test (org.junit.jupiter.api.Test)8 EventStatus (com.sequenceiq.cloudbreak.cloud.event.model.EventStatus)7 ClusterCommissionService (com.sequenceiq.cloudbreak.cluster.api.ClusterCommissionService)7 ClusterSetupService (com.sequenceiq.cloudbreak.cluster.api.ClusterSetupService)7 CloudbreakFlowMessageService (com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService)7 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)7 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)7