use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException 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.cm.client.ClouderaManagerClientInitException 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);
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method createApiClient.
private ApiClient createApiClient() throws ClusterClientInitException {
ApiClient client = null;
try {
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) {
return returnClientBasedOnApiError(client, e);
}
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSetupServiceTest method testWaitForHostsWhenDropClouderaManagerClientInitExceptionShouldReturnClusterClientInitException.
@Test
public void testWaitForHostsWhenDropClouderaManagerClientInitExceptionShouldReturnClusterClientInitException() throws Exception {
doThrow(new ClouderaManagerClientInitException()).when(clouderaManagerApiClientProvider).getV31Client(anyInt(), anyString(), anyString(), any(HttpClientConfig.class));
ClusterClientInitException actual = assertThrows(ClusterClientInitException.class, () -> underTest.waitForHosts(Set.of()));
assertEquals(ClusterClientInitException.class, actual.getClass());
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method initApiClient.
@PostConstruct
public void initApiClient() throws ClusterClientInitException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
apiClient = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
} catch (ClouderaManagerClientInitException e) {
throw new ClusterClientInitException(e);
}
}
Aggregations