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));
}
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);
}
}
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());
}
}
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());
}
}
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);
}
Aggregations